Generating Sequence Diagrams from source code

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  UML Diagrams > Behavioral Diagrams > Sequence Diagram >

Generating Sequence Diagrams from source code

UModel is able to create sequence diagram models directly from code.

 

The example below shows how to automatically create a sequence diagram by using an existing method. You can, of course, use the same approach on your own code. The method is available in the OrgChart package which was imported using the Project | Import Source Directory command in the tutorial. Please see Round-trip engineering (code - model - code) in the tutorial for more information on importing code.

 

1.Having imported the code, right-click the main method of the OrgChartTest class, in the Model Tree and select Generate Sequence Diagram... .

seq-from-code1

This opens the Sequence Diagram Generation dialog box in which you define the generation settings.

seq-from-code2pro

2.Select the presentation and layout options, then click OK to generate the diagram. The settings shown above produce the sequence diagram below.

seq-from-code3

Notes:

 

You can assign a special color to the non-displayable invocations.
The maximum invocation depth defines the recursion depth to be used in the diagram.
The Type names to ignore option allows you to define a comma delimited list of types that should not appear in the sequence diagram when it is generated.
The Operation names to ignore option allows you define a comma delimited list of operations that should not appear in the generated sequence diagram (initComponents are automatically added as a default). Adding the operation names to the list e.g. "InitComponents" causes the complete operation to be ignored. Prepending a + character to the operation in the list e.g. +InitComponent, causes the operation calls  to be shown in the diagram, but without their content.
The Split into smaller diagrams where appropriate option automatically splits sequence diagrams into smaller sub-diagrams, and automatically generates hyperlinks between them for easy navigation.

 

Sequence diagrams are automatically updated when you update the complete UModel project. Sequence diagrams are not updated if you update classes, or individual files, externally. You can however change this setting by clicking on the diagram background and clicking the Automatic Update check box.

seq-from-code5

Clicking the ic-more icon of the Automatic Update field, opens the Sequence Diagram Generation dialog box allowing you to change the sequence diagram generation settings.


© 2019 Altova GmbH