Tuesday, January 30, 2007

Interaction Diagrams


I've been searching for an easy way to do open source interaction diagrams for a while now. I've finally stumbled across an old yet easy way to do it. You 'code' the interaction in a language called PIC which was developed in days gone by at bell labs. The only part of UMLGraph that's needed is the sequence.pic file. As well as sequence.pic, you will also need pic2plot installed (available for windows here). From there you can transform your .pic files to svg and gif images:
"C:\Program Files\GnuWin32\bin\pic2plot.exe" -Tsvg diagram.pic > diagram.svg



PIC has a few quirks:- 1. don't add spaces between your to and from objects. 2. end the file with a UNIX end of file character. Ant can do this for you:



<fixcrlf srcdir="." eol="unix" eof="add" includes="**/*.pic" />


3. do NOT have a UNIX end of file character at the end of the sequence.pic.

The example pic file:

.PS
copy "sequence.pic";
# Define the objects
object(O,"o:Toolkit");
placeholder_object(P);
step();

# Message sequences
active(O);
step();
active(O);
message(O,O,"callbackLoop()");
inactive(O);
create_message(O,P,"p:Peer");
message(O,P,"handleExpose()");
active(P);
return_message(P,O,"");
inactive(P);
destroy_message(O,P);
inactive(O);

# Complete the lifelines
step();
complete(O);

.PE

No comments: