如何从现有的Java代码生成UML图(特别是序列图)?
当前回答
你的代码库是什么?Java还是c++ ?
eUML2 for Java is a powerful UML modeler designed for Java developper in Eclipse. The free edition can be used for commercial use. It supports the following features: CVS and Team Support Designed for large project with multiple and customizable model views Helios Compliant Real-time code/model synchronization UML2.1 compliant and support of OMG XMI JDK 1.4 and 1.5 support The commercial edition provides: Advanced reversed engineering Powerful true dependency analyze tools UML Profile and MDD Database tools Customizable template support
其他回答
你的代码库是什么?Java还是c++ ?
eUML2 for Java is a powerful UML modeler designed for Java developper in Eclipse. The free edition can be used for commercial use. It supports the following features: CVS and Team Support Designed for large project with multiple and customizable model views Helios Compliant Real-time code/model synchronization UML2.1 compliant and support of OMG XMI JDK 1.4 and 1.5 support The commercial edition provides: Advanced reversed engineering Powerful true dependency analyze tools UML Profile and MDD Database tools Customizable template support
另一个Java建模工具是我的网站GitUML。 从存储在GitHub存储库中的Java或Python代码生成UML图。
GitUML的一个关键思想是解决“文档化”的一个问题:图总是过时的。使用GitUML,当您使用git推送代码时,图表会自动更新。
浏览社区UML图,有一些Java设计模式。浏览流行的GitHub存储库,并可视化其中的架构和模式。
使用指向和单击创建图表。没有拖放编辑器,只需点击你想要可视化的存储库树中的类:
底层技术是基于PlantUML的,这意味着您可以使用额外的PlantUML标记来改进您的图表。
编辑: 如果你是一个设计师,那么Papyrus是你最好的选择,它非常先进,功能齐全,但如果你只是想绘制一些UML图和易于安装,那么ObjectAid是非常酷的,它不需要任何插件,我只是在Eclipse-Java EE上安装了它,工作得很好!
2013年10月11日更新
我最初的帖子是在2012年6月发布的,很多事情都发生了变化,许多工具已经发展起来,而其他工具没有。因为我要回去做一些建模,也得到一些回复,我决定再次安装papyrus,并将再次研究其他可能的UML建模解决方案。UML生成(带有同步特性)对软件设计人员来说并不重要,对普通开发人员来说却很重要。
我希望papyrus有直接的方法将类逆向工程到UML类图,如果逆向工程有同步功能,那将是超级酷的,但不幸的是,papyrus项目充满了功能,我认为开发人员已经有了很多,因为你在papyrus上做的许多操作可能不会给你任何响应,只是什么都没有发生,但这已经超出了这个问题的范围。
答案(2013年10月11日)
工具
下载纸莎草 去帮助->安装新软件… 在Work with:下拉菜单中,选择—All Available Sites— 在过滤器中,输入Papyrus 安装完成后重新启动Eclipse 重复步骤1-3,这一次,安装Modisco
步骤
In your java project (assume it's called MyProject) create a folder e.g UML Right click over the project name -> Discovery -> Discoverer -> Discover Java and inventory model from java project, a file called MyProject_kdm.xmi will be generated. Right click project name file --> new --> papyrus model -> and call it MyProject. Move the three generated files MyProject.di , MyProject.notation, MyProject.uml to the UML folder Right click on MyProject_kdm.xmi -> Discovery -> Discoverer -> Discover UML model from KDM code again you'll get a property dialog set the serialization prop to TRUE to generate a file named MyProject.uml Move generated MyProject.uml which was generated at root, to UML folder, Eclipse will ask you If you wanted to replace it click yes. What we did in here was that we replaced an empty model with a generated one. ALT+W -> show view -> papyrus -> model explorer In that view, you'll find your classes like in the picture In the view Right click root model -> New diagram Then start grabbing classes to the diagram from the view
一些功能
To show the class elements (variables, functions etc) Right click on any class -> Filters -> show/hide contents Voila !! You can have default friendly color settings from Window -> pereferences -> papyrus -> class diagram one very important setting is Arrange when you drop the classes they get a cramped right click on any empty space at a class diagram and click Arrange All Arrows in the model explorer view can be grabbed to the diagram to show generalization, realization etc After all of that your settings will show diagrams like Synchronization isn't available as far as I know you'll need to manually import any new classes.
就是这样,除非你真的需要,否则不要购买商业产品,莎草纸实际上是很好的和复杂的,可以捐赠或其他东西。
免责声明:我和纸莎草人没有关系,事实上,我一开始并不喜欢纸莎草,直到我做了大量的研究,并耐心地体验了它。当我尝试其他免费工具时,我会再次回到这篇文章。
您也可以尝试使用netbeans UML建模器。我用它来生成我在eclipse项目中使用的javcode。您甚至可以在netbeans中导入eclipse项目,并保持eclipse设置与netbeans项目设置同步。
我尝试了几个用于eclipse的UML建模器,但都不满意。它们要么不稳定,要么复杂,要么丑陋不堪。: -)
您可以使用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在代码中添加了模型标签,这真的非常非常糟糕,对我来说是一个绝对的失败。
推荐文章
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数
- 从现有模式生成表关系图(SQL Server)
- c#和Java中的泛型有什么不同?和模板在c++ ?
- 在Java中,流相对于循环的优势是什么?
- Jersey在未找到InjectionManagerFactory时停止工作
- 在Java流是peek真的只是调试?
- Recyclerview不调用onCreateViewHolder