如何从现有的Java代码生成UML图(特别是序列图)?


当前回答

ObjectAid UML Explorer

是我用的。它很容易从存储库安装:

Name:     ObjectAid UML Explorer
Location: http://www.objectaid.com/update/current

并生成相当不错的UML图:

网站描述:

The ObjectAid UML Explorer is different from other UML tools. It uses the UML notation to show a graphical representation of existing code that is as accurate and up-to-date as your text editor, while being very easy to use. Several unique features make this possible: Your source code and libraries are the model that is displayed, they are not reverse engineered into a different format. If you update your code in Eclipse, your diagram is updated as well; there is no need to reverse engineer source code. Refactoring updates your diagram as well as your source code. When you rename a field or move a class, your diagram simply reflects the changes without going out of sync. All diagrams in your Eclipse workspace are updated with refactoring changes as appropriate. If necessary, they are checked out of your version control system. Diagrams are fully integrated into the Eclipse IDE. You can drag Java classes from any other view onto the diagram, and diagram-related information is shown in other views wherever applicable.

其他回答

ObjectAid UML Explorer

是我用的。它很容易从存储库安装:

Name:     ObjectAid UML Explorer
Location: http://www.objectaid.com/update/current

并生成相当不错的UML图:

网站描述:

The ObjectAid UML Explorer is different from other UML tools. It uses the UML notation to show a graphical representation of existing code that is as accurate and up-to-date as your text editor, while being very easy to use. Several unique features make this possible: Your source code and libraries are the model that is displayed, they are not reverse engineered into a different format. If you update your code in Eclipse, your diagram is updated as well; there is no need to reverse engineer source code. Refactoring updates your diagram as well as your source code. When you rename a field or move a class, your diagram simply reflects the changes without going out of sync. All diagrams in your Eclipse workspace are updated with refactoring changes as appropriate. If necessary, they are checked out of your version control system. Diagrams are fully integrated into the Eclipse IDE. You can drag Java classes from any other view onto the diagram, and diagram-related information is shown in other views wherever applicable.

另一个Java建模工具是我的网站GitUML。 从存储在GitHub存储库中的Java或Python代码生成UML图。

GitUML的一个关键思想是解决“文档化”的一个问题:图总是过时的。使用GitUML,当您使用git推送代码时,图表会自动更新。

浏览社区UML图,有一些Java设计模式。浏览流行的GitHub存储库,并可视化其中的架构和模式。

使用指向和单击创建图表。没有拖放编辑器,只需点击你想要可视化的存储库树中的类:

底层技术是基于PlantUML的,这意味着您可以使用额外的PlantUML标记来改进您的图表。

有一个名为binarydoc的免费工具,它可以从Java方法的字节码(而不是源代码)生成UML序列图或控制流图(CFG)。

下面是为java方法java.net.AbstractPlainSocketImpl.getInputStream生成的示例图binarydoc:

方法控制流图:

方法的UML序列图:

我注意到Intellij的SequenceDiagram插件也是一个不错的选择。

您可以使用Eclipse 3.5的EclipseUML的30天评估版本:http://www.uml2.org/eclipse-java-galileo-SR2-win32_eclipseUML2.2_package_may2010.zip 这不是最新的3.6版本,但是非常好,并且不需要您购买它来进行测试和逆向工程。

反向工程:http://www.forum-omondo.com/documentation_eclipseuml_2008/reverse/reverse/reverse_engineering_example.html

现场flash演示:http://www.ejb3.org/reverse.swf

EclipseUML Omondo是世界上最好的Java工具。在这个实时java同步市场上,似乎只有eUML可以与之竞争,但是eUML在代码中添加了模型标签,这真的非常非常糟糕,对我来说是一个绝对的失败。