在 Linux 中运行的免费实用程序,用于从 Java 源文件创建 UML 类图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/737431/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Free utility which runs in Linux to create a UML class diagram from Java source files
提问by
I prefer to jot down UML-diagrams on paper and then implement them using Java. It would be nice to have a utility which could create UML-diagrams for me which I may share on-line and include in the digital documentation. In other words: I want to create UML diagrams from Java source code.
我更喜欢在纸上记下 UML 图,然后使用 Java 实现它们。如果有一个实用程序可以为我创建 UML 图表,我可以在线共享并包含在数字文档中,那就太好了。换句话说:我想从 Java 源代码创建 UML 图。
The utility must be able to:
该实用程序必须能够:
- Run in Linux.
- Handle Generics, i.e show List<Foo> correctly in parameters and return type.
- Show class inheritance and interface implementations.
- 在 Linux 中运行。
- 处理泛型,即在参数和返回类型中正确显示 List<Foo>。
- 显示类继承和接口实现。
It's nice if the utility is able to:
如果该实用程序能够:
- Run in Windows and Mac OS X.
- Display enums in some nice manner.
- Generate output in a diagram format which I may modify using some other utility.
- Run from the command line.
- Restrict the UML generation to a set of packages which I may specify.
- Handle classes/interfaces which are not part of my source code. It could include the first class/interface which is external in the UML diagram. Perhaps in another color to indicate it being a library/framework created by someone else.
- Focuses on this task and doesn't try to solve the whole issue of documentation.
- 在 Windows 和 Mac OS X 中运行。
- 以某种不错的方式显示枚举。
- 以图表格式生成输出,我可以使用其他一些实用程序对其进行修改。
- 从命令行运行。
- 将 UML 生成限制为我可能指定的一组包。
- 处理不属于我的源代码的类/接口。它可以包括 UML 图中外部的第一个类/接口。也许用另一种颜色表示它是由其他人创建的库/框架。
- 专注于这项任务,并不试图解决整个文档问题。
回答by Pierre
A few monthes ago, I wrote a simpletool named "java2dot". It doesn't handle all you requirements but it might helps.
几个月前,我写了一个名为“java2dot”的简单工具。它不能满足您的所有要求,但可能会有所帮助。
http://plindenbaum.blogspot.com/2008/10/javadoc-is-not-enough-java2dia.html
http://plindenbaum.blogspot.com/2008/10/javadoc-is-not-enough-java2dia.html
回答by jmcecil
It's not clear if you want to create code from UML or reverse Engineer code into UML. If you want to create code from UML, the Netbeans UML project type is probably the easiest set of tools for Java.
不清楚您是想从 UML 创建代码还是将逆向工程代码转换为 UML。如果您想从 UML 创建代码,Netbeans UML 项目类型可能是最简单的 Java 工具集。
If you want stand alone
如果你想独处
StarUMLis an older UML modeling tool. It follow most of the UML guidelines pre 2. It can handle generics, but only if you manually type them in. However, I don't think it correctly generates the generics if I remember correctly. You have to adjust the code after generation.
StarUML是一种较旧的 UML 建模工具。它遵循大多数 UML 指南 pre 2。它可以处理泛型,但前提是您手动输入它们。但是,如果我没记错的话,我认为它不会正确生成泛型。您必须在生成后调整代码。
Although not free, I personnaly think that Umodelis worth the money if you do UML regularly.
虽然不是免费的,但我个人认为如果你经常做 UML ,Umodel是物有所值的。
回答by Bob Cross
One method that we've experimented with is a combination of UMLGraphand GraphViz. What we were doing at the time was making the UML creation an automatic part of our CruiseControl build: the javadoc would be built with UML diagrams built in. It is pretty slick.
我们试验过的一种方法是结合使用UMLGraph和GraphViz。我们当时正在做的是让 UML 创建成为我们 CruiseControl 构建的自动部分:javadoc 将使用内置的 UML 图构建。它非常巧妙。
I think you'll find that the UMLGraph documentationanswers pretty much all of your questions. Specifically, you should be able to create the class diagram that you want from the command line.
我想您会发现UMLGraph 文档几乎回答了您的所有问题。具体来说,您应该能够从命令行创建所需的类图。