本文翻译自:How to generate UML diagrams (especially sequence diagrams) from Java code?

如何从现有Java代码生成UML图(尤其是序列图)?


#1楼

参考:https://stackoom.com/question/DTG/如何从Java代码生成UML图-尤其是序列图


#2楼

EDIT: If you're a designer then Papyrus is your best choice it's very advanced and full of features, but if you just want to sketch out some UML diagrams and easy installation then ObjectAid is pretty cool and it doesn't require any plugins I just installed it over Eclipse-Java EE and works great !. 编辑:如果你是一名设计师,那么Papyrus是你最好的选择它非常先进且功能齐全,但是如果你只是想要勾勒出一些UML图并且易于安装,那么ObjectAid非常酷,它不需要任何插件我刚刚将它安装在Eclipse-Java EE上并且工作得很好!


UPDATE Oct 11th, 2013 更新2013年10月11日

My original post was in June 2012 a lot of things have changed many tools has grown and others didn't. 我的原始帖子是在2012年6月,许多事情发生了变化,许多工具已经增长,而其他工具则没有。 Since I'm going back to do some modeling and also getting some replies to the post I decided to install papyrus again and will investigate other possible UML modeling solutions again. 由于我要回去做一些建模并得到一些回复,我决定再次安装纸莎草纸,并将再次研究其他可能的UML建模解决方案。 UML generation (with synchronization feature) is really important not to software designer but to the average developer. UML生成(具有同步功能)对于软件设计者而言对于普通开发人员来说非常重要。

I wish papyrus had straightforward way to Reverse Engineer classes into UML class diagram and It would be super cool if that reverse engineering had a synchronization feature, but unfortunately papyrus project is full of features and I think developers there have already much at hand since also many actions you do over papyrus might not give you any response and just nothing happens but that's out of this question scope anyway. 我希望papyrus能够直接将Reverse Engineer类转换为UML类图,如果逆向工程具有同步功能,那将是非常酷的,但不幸的是,papyrus项目充满了各种功能,我认为那里的开发人员已经有了很多东西。你对纸莎草所采取的行动可能不会给你任何回应而且没有任何反应,但无论如何都不会出现这个问题范围。

The Answer (Oct 11th, 2013) 答案 (2013年10月11日)

Tools 工具

  1. Download Papyrus 下载纸莎草纸
  2. Go to Help -> Install New Software... 转到帮助 - >安装新软件...
  3. In the Work with: drop-down, select --All Available Sites-- Work with:下拉列表中,选择- 所有可用站点 -
  4. In the filter, type in Papyrus 在过滤器中,键入纸莎草纸
  5. After installation finishes restart Eclipse 安装完成后重启Eclipse
  6. Repeat steps 1-3 and this time, install Modisco 重复步骤1-3,这次安装Modisco

Steps 脚步

  1. In your java project (assume it's called MyProject) create a folder eg UML 在你的java项目中(假设它叫做MyProject)创建一个文件夹,例如UML
  2. 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. 右键单击项目名称 - > Discovery - > Discoverer - >从Java项目中发现Java和库存模型,将生成一个名为MyProject_kdm.xmi的文件。
  3. Right click project name file --> new --> papyrus model -> and call it MyProject. 右键单击项目名称文件 - >新建 - >纸莎草模型 - >并将其命名为MyProject。
  4. Move the three generated files MyProject.di , MyProject.notation, MyProject.uml to the UML folder 将三个生成的文件MyProject.di,MyProject.notation,MyProject.uml移动到UML文件夹
  5. 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 右键单击MyProject_kdm.xmi - > Discovery - > Discoverer - >再次从KDM代码中发现UML模型,您将获得一个属性对话框,将序列化道具设置为TRUE以生成名为MyProject.uml的文件

  6. Move generated MyProject.uml which was generated at root, to UML folder, Eclipse will ask you If you wanted to replace it click yes. 将生成的生成的MyProject.uml移动到UML文件夹,Eclipse将询问您如果要替换它,请单击是。 What we did in here was that we replaced an empty model with a generated one. 我们在这里所做的是我们用生成的模型替换了一个空模型。

  7. ALT+W -> show view -> papyrus -> model explorer ALT + W - >显示视图 - >纸莎草 - >模型浏览器

  8. In that view, you'll find your classes like in the picture 在该视图中,您将在图片中找到您的课程

  9. In the view Right click root model -> New diagram 在视图中右键单击根模型 - >新图

  10. Then start grabbing classes to the diagram from the view 然后从视图开始抓取图表中的类

Some features 一些功能

  • To show the class elements (variables, functions etc) Right click on any class -> Filters -> show/hide contents Voila !! 要显示类元素(变量,函数等)右键单击任何类 - >过滤器 - >显示/隐藏内容Voila !!

  • You can have default friendly color settings from Window -> pereferences -> papyrus -> class diagram 您可以从Window - > pereferences - > papyrus - >类图中获得默认的友好颜色设置

  • 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. 据我所知,您需要手动导入任何新类,因此无法进行同步。

That's all, And don't buy commercial products unless you really need it, papyrus is actually great and sophisticated instead donate or something. 这就是全部,除非你真的需要它,否则不要购买商品,纸莎草实际上是伟大而复杂的,而不是捐赠或其他东西。

Disclaimer: I've no relation to the papyrus people, in fact, I didn't like papyrus at first until I did lots of research and experienced it with some patience. 免责声明:我与纸莎草纸人没有关系,事实上,我一开始并不喜欢纸莎草纸,直到我做了很多研究并且耐心地体验了它。 And will get back to this post again when I try other free tools. 当我尝试其他免费工具时,我会再次回到这篇文章。


#3楼

By far the best tool I have used for reverse engineering, and round tripping java -> UML is Borland's Together . 到目前为止,我用于逆向工程的最佳工具,以及Java-> UML的圆形跳闸是Borland的Together 。 It is based on Eclipse (not just a single plugin) and really works well. 它基于Eclipse(不仅仅是一个插件),而且效果很好。


#4楼

I suggest PlantUML. 我建议PlantUML。 this tools is very usefull and easy to use. 这个工具非常有用且易于使用。 PlantUML have a plugin for Netbeans that you can create UML diagram from your java code. PlantUML有一个Netbeans插件,你可以从你的java代码创建UML图。

you can install PlantUML plugin in the netbeans by this method: 你可以通过这种方法在netbeans中安装PlantUML插件:

Netbeans Menu -> Tools -> Plugin Netbeans菜单 - >工具 - >插件

Now select Available Plugins and then find PlantUML and install it. 现在选择Available Plugins,然后找到PlantUML并安装它。

For more information go to website: www.plantuml.com 欲了解更多信息,请访问网站:www.plantuml.com


#5楼

I developed a maven plugin that can both, be run from CLI as a plugin goal, or import as dependency and programmatically use the parser, @see Main#main() to get the idea on how. 我开发了一个maven插件,既可以从CLI作为插件目标运行,也可以作为依赖项导入,并以编程方式使用解析器,@ @see Main#main()来了解如何使用。

It renders PlantUML src code of desired packages recursively that you can edit manually if needed (hopefully you won't). 递归地呈现所需包的PlantUML src代码 ,您可以根据需要手动编辑(希望您不会)。 Then, by pasting the code in the plantUML page, or by downloading plant's jar you can render the UML diagram as a png image. 然后,通过粘贴plantUML页面中的代码,或者通过下载工厂的jar,您可以将UML图表渲染为png图像。

Check it out here https://github.com/juanmf/Java2PlantUML 在这里查看https://github.com/juanmf/Java2PlantUML

Example output diagram: 示例输出图:

Any contribution is more than welcome. 任何贡献都非常受欢迎。 It has a set of filters that customize output but I didn't expose these yet in the plugin CLI params. 它有一组自定义输出的过滤器,但我还没有在插件CLI参数中公开它们。

It's important to note that it's not limited to your *.java files, it can render UML diagrams src from you maven dependencies as well. 重要的是要注意它不仅限于你的* .java文件,它也可以从maven依赖项中呈现UML图表src。 This is very handy to understand libraries you depend on. 这对于理解您所依赖的库非常方便。 It actually inspects compiled classes with reflection so no source needed 它实际上用反射检查编译的类,因此不需要源

Be the 1st to star it at GitHub :P 成为第一个在GitHub上演的明星:P


#6楼

How about PlantUML ? PlantUML怎么样 ? It's not for reverse engineering!!! 它不适用于逆向工程! It's for engineering before you code. 在编码之前,它是用于工程的。

如何从Java代码生成UML图(尤其是序列图)?相关推荐

  1. java测试类要画UML图吗,如何从Java代码生成UML图(尤其是序列图)?

    如何从Java代码生成UML图(尤其是序列图)? 如何从现有Java代码生成UML图(尤其是序列图)? 14个解决方案 249 votes ObjectAid UML Explorer 是我用过的. ...

  2. UML模型中的图-行为图【交互图-序列图、协作图】

    前言 上一篇博文小编为大家分享了UML建模中行为图里面的状态图和活动图,今天继续为大家分享行为图中的内容- 交互图 .在UML建模中,交互图包括两种- 序列图.协作图 正文 六.序列图     序列图 ...

  3. UML图系列之序列图

    UML图系列之序列图 UML-Unified Modeling Language 统一建模语言,又称标准建模语言,是用来对软件密集系统进行可视化建模的一种语言.时序图(Sequence Diagram ...

  4. Visual Paradigm 教程[UML]:如何在序列图中应用消息编号?

    下载Visual Paradigm最新试用版 已加入在线订购,现在抢购立享特别优惠>> 在本教程中,我们将介绍两种主要方式:基于图表和基于框架.当我们将"scope"指 ...

  5. Visual Paradigm 教程[UML]:如何在序列图中使用持续时间约束?

    2019独角兽企业重金招聘Python工程师标准>>> 下载Visual Paradigm最新试用版 在UML序列图中,持续时间消息用于表示消息的时间流逝.当您想要建模实时系统时,它 ...

  6. UML画图文档——序列图

    在UML中,用例的实现用交互图来指定和说明.交互图通过显示对象之间的关系和对象之间处理的消息来对系统的动态特性建模.有两种交互图:序列图和协作图.侧重点不同,但语义是等价的,可以相互转换.本次只介绍一 ...

  7. UML图学习之五 序列图(顺序图)和协作图

    在面向对象动态建模,用于建立行为的实体间行为交互的四种图:状态图(Stage Diagram),序列图(Sequence Diagram),协作图(Communication Diagram),活动图 ...

  8. Laya动画,整图动画,序列图动画,时间轴动画,龙骨动画

    Laya动画基础 Egret帧动画工具类 版本:2.1.1.1 序列图动画 白鹭的序列图动画,使用TexureMerger合图,然后使用MovieClip类播放. Laya的话,使用图集打包工具合图, ...

  9. Laya的动画制作,整图动画,序列图动画,时间轴动画,龙骨动画

    参考: Laya动画基础 Egret帧动画工具类 序列图动画 白鹭的序列图动画,使用TexureMerger合图,然后使用MovieClip类播放. Laya的话,使用图集打包工具合图,然后使用Ani ...

最新文章

  1. C++中std::function和std::bind
  2. Java多线程(2)—线程同步
  3. 通读AFN②--AFN的上传和下载功能分析、SessionTask及相应的session代理方法的使用细节...
  4. 打开AzureRay园子的大门,欢迎大家串门哟~
  5. 前端笔记—第15篇js中的DOM操作
  6. ETL的数据同步工具调研(持续更新中)
  7. 分享memcache和memcached安装过程(转)
  8. Go-如何读取yaml,json,ini等配置文件
  9. 正则表达式的运算符优先级
  10. argument list too long 错误的处理
  11. libevent:信号、超时、回调
  12. springcahce集成redis 设置过期时间
  13. 基于javaweb+mysql的+JPA学生宿舍学生住宿申请管理系统(管理员、学生)
  14. 数字人实业应用场景,远远不止屏幕互动
  15. 交通灯控制系统C语言代码,《C语言代码-交通灯控制器》.doc
  16. 8种隔夜食物千万不要吃
  17. 黑马程序员--java简介
  18. 线性嵌套实例(三个小实例)
  19. 爬取豆瓣电影前十页的好评一般差评
  20. vue源码分析系列一:new Vue的初始化过程

热门文章

  1. 芯烨网口打印机用安卓手机端修改IP
  2. 三星借力“音叉效应”构筑高端电视市场“防火墙”
  3. 网站漏洞渗透安全测试重点检测方法
  4. ECSHOP快递物流单号查询追踪插件
  5. 高德地图开发设置细节概览
  6. miui android5,MIUI论坛安卓版
  7. 鸿蒙系统小米miui12,MIUI12系统
  8. 五、科大软件工程(孟宁)(5:多线程)
  9. Arc GIS(MAP)绘制地区温度变化图
  10. #yyds这些技巧盘点#使用Python分析网易云歌曲信息,通过可视化处理我发现了有趣的规律评论