I have tried a lot of such tools before. This one (SequenceDiagram:: JetBrains Plugin Repository) is the best one and I am using it. To be honest, I found reverse engineering code into sequence diagram is not really a good idea. The result is not. Go through the wizard steps to import the source code as a Java project. For more information about this step, see Reverse Engineering (from Code to Model). Having imported the code, right-click the main method of the OrgChartTest class in the Model Tree and select Generate Sequence Diagram from Code. From the context menu.
This example shows you how to generate a Sequence diagram from a method. The project containing this method will be reverse-engineered from Java source code. You can find the Java source code at the following path: C:Users<user>DocumentsAltovaUModel2021UModelExamplesOrgChart.zip. First, unzip the OrgChart.zip archive to the same location (for example, right-click the archive in Windows Explorer and select Extract All).
1.On the Project menu, click Import Source Directory, and select the directory unzipped previously.
2.Go through the wizard steps to import the source code as a Java project. For more information about this step, see Reverse Engineering (from Code to Model).
3.Having imported the code, right-click the main method of the OrgChartTest class in the Model Tree and select Generate Sequence Diagram from Code... from the context menu.
This opens the Sequence Diagram Generation dialog box in which you define the generation settings.
4.Select the presentation and layout options, and then click OK to generate the diagram. The settings shown above produce the sequence diagram below.
Sequence diagram generation options
The table below lists the generation options pertaining to Sequence diagrams.
You can set this option when generating a diagram for the first time. For existing diagrams, this information is read-only.
Click the Ellipsis button to select the owner package of the diagram. Otherwise, the option [autoselect] places the diagram in the default package.
Automatically update diagram when model is updated from code
When you perform reverse engineering (from code to model), sequence diagrams are re-generated automatically in the model, provided that you have selected the option Automatically update diagram when model is updated from code when generating the diagram for the first time.
For existing diagrams, you can change this option as follows:
1.Select the Sequence diagram in the Model Tree or in the Diagram Tree.
2.In the Properties window, select the update on reverse engineering check box.
If you select the use for forward engineering check box, the synchronization from model to code will generate code based on the sequence diagram, when you perform forward engineering (from model to code), see also Generate Code from Sequence Diagram.
If the two 'engineering' check boxes are missing, it is likely that this diagram is just a fragment of a bigger diagram, or perhaps you have created the diagram from a non reverse-engineered operation.
Show code in notes
Select this check box to generate the diagram with notes (callouts) that contain program code.
Also show code of messages displayed directly below
Even when it is possible to show a piece of code as UML Message on the diagram, this option still displays the code of that message as a note.
Use special color for non-displayable invocations
Assigns a color of your choice to non-displayable invocations.
Show empty Combined Fragments
Keeps the Combined Fragment blocks on the diagram, even if they don't contain anything.
Shown unknown invocations
When selected, this option also displays messages for operations or constructors which could not be resolved (that is, not found in the model).
Split into smaller diagrams where appropriate
Automatically splits sequence diagrams into smaller sub-diagrams, and automatically generates hyperlinks between them for easy navigation.
Maximum invocation depth
Defines the call depth to be used in the diagram. For example, if method1() calls method2() which calls method3(), and the invocation depth is set to 2, then only method2 is shown, and method3 is no longer shown.
Type names to ignore
Lets you define a comma delimited list of types that should not appear in the sequence diagram when it is generated.
Operation names to ignore
Lets you define a comma delimited list of operations that should not appear in the generated sequence diagram. Adding the operation names to the list causes the complete operation to be ignored. Prepending a '+' character to the operation in the list (for example, +InitComponent) causes the operation calls to be shown in the diagram, but without their content.
Use dedicated Lifeline for static calls
If there are static methods calls, and if there is already an instance of that object on the diagram, messages are normally drawn to that existing lifeline. With this option enabled, the diagram generator uses a dedicated new lifeline just for static method calls for that classifier.
© 2015-2021 Altova GmbH
Quick and Easy Class and Sequence Diagrams in Eclipse
“Everyone has different learning styles” says my wife the teacher. I think this also applies to how we look at code. I tend to be a big picture person and need to understand the lay of the land before I can dive into the details. What are the architectural layers? How is the code structured? What are the main components of the application? One would think this would be obvious across similar domains, but it’s suprisingly not. When diving into a new codebase it’s often very handy to be able to get a big picture view quickly. One easy way to do so is with a sequence diagraming tool that can generate a sequence diagram for you. One such tool is Object Aid.
Object Aid provides two plug-ins for Eclipse: a class diagramming tool and a sequence diagramming tool. Both can reverse engineer from your code. The class diagramming tool is free, the sequence diagramming tool is an inexpensive $19 at the time of this writing. This is the best bang for your UML buck I’ve found. Register on their site to get a free trial.
Installation is easy, so we’ll skip that and dive right in.
Sequence Diagram Tool
Class diagrams are saved as files within any of your Eclipse projects. They can sit right alongside the code in your source tree, in a seperate folder in your project or in a separate project on it’s own. I generally use one of the latter two approaches. If one keeps a class diagram within a package in the source tree that would indicate to the poor sap maintaining your code that the diagram contains only classes from the package it’s saved in. That’s not likely to be a very useful or interesting diagram.
Creating a class diagram is a simple matter of creating a new file in Eclipse. Once done, you can drag any class visible in Eclipse to the diagram. Associations will automatically displayed between classes that have them. Tip: in the project explorer or navigator view keep the “sync with editor option” unselected. Otherwise when you start to drag a class that class will become visible in the editor if it happens to be open.
There are lots of visibility options you can explore. Here’s a sample class diagram:
The fun really starts with sequence diagrams. This is my secret weapon when I’m looking at a new code base.
Sequence diagrams can be generated from many different sources:
- manually in the diagram by dragging a message from a lifeline, by selecting a method, or dragging a method from the project explorer or navigator views.
- java stack trace console
- debugger stack frames
- dragging methods from the call hierarchy view
The most useful to me is from the debugger. Quite often one know the entry point to a server call. From there stepping through the code dives deeper into the code. Once in the target class it can be tought to see the forest from the trees. Here’s where the sequence diagram shines.
Sequence Diagram Example
How To Generate Sequence Diagram
In a new sequence diagram right-click the debugger stack and select “add to sequence diagram”. The entire stack frame will be put on the diagram.
Java Code To Sequence Diagram online, free
On very complex apps, especially those using JEE or Spring there are often quite a lot of layers and proxy classes. These are not very useful in a sequence diagram. In the preference one specify filters and filter the unwanted classes from the diagram.