@hidden
tag applied to classes, methods, and fields.
In theory you can also use UMLGraph to reverse engineer existing
Java code.
Note however that UMLGraph was not originally designed for this purpose;
the resulting graphs may be large and unwieldy.
There are various ways to invoke UmlGraph,
each providing a different balance between convenience and flexibility.
umlgraph
(or umlgraph.bat
) is correctly
installed,
you can run UmlGraph by simply specifying the basename of
the Java file containing the diagram specification and the file type of
the generated diagram (e.g. gif, ps, png, svg).
Example:
umlgraph Test pngAny additional UmlGraph or javadoc arguments can be added at the end of the command line. This command will read the specification file (e.g. Test.java) and generate directly a diagram of the appropriate type (e.g. Test.png).
tools.jar
.
You can accomplish this in two ways.
tools.jar
as a part of Java's classpath
and specify the full name of the UmlGraph doclet as an argument to Java.
This is an invocation example under Windows
java -classpath "lib/UmlGraph.jar;c:\program files\java\jdk1.6.0_02\lib\Tools.jar" org.umlgraph.doclet.UmlGraph -package Test.javaand under Unix
java -classpath '/usr/share/lib/UmlGraph.jar:/opt/Java-1.6/lib/tools.jar' \ org.umlgraph.doclet.UmlGraph -package Test.java
UmlGraph.jar
file in a directory that also contains the Java SDK tools.jar
file.
You can accomplish this either by copying UmlGraph.jar
to the SDK
lib
directory where tools.jar
resides,
or by copying the JDK tools.jar
file into the directory
where you installed UmlGraph.
You then run
java -jar /path/to/UmlGraph.jar yourfile1.java ...
-private
is usually needed to avoid having to explicitly
specify public elements.
Example:
java -jar /usr/jvm/java-1.5.0/lib/UmlGraph.jar -private Simple.javaSpecifying some packages before the list of source files will designate those packages as local. When you specify a package list, the SVG output UmlGraph generates will contain local hyperlinks for the local classes and hyperlinks to the Sun Java API documentation for all other classes.
-doclet org.umlgraph.doclet.UmlGraph
-docletpath /path/to/UmlGraph.jar
and append at the end the file(s) that contain your diagram
specification.
Example:
javadoc -docletpath UmlGraph.jar -doclet org.umlgraph.doclet.UmlGraph -private Simple.java
graph.dot
in the current directory.
A command line like the following will convert the graph.dot
file into Postscript:
dot -Tps -ograph.ps graph.dotor PNG
dot -Tpng -ograph.png graph.dotRefer to the dot documentation for information on creating other file formats or adjusting the UMLGraph output. You also can pipe the result of UMLGraph directly into dot:
java -jar /.../UmlGraph.jar -private -output - Simple.java | dot -Tgif -ograph.gifNote that when you use dot for generating SVG diagrams your should specify the
-outputencoding UTF-8
option to UMLGraph.
This option will correctly render the stereotype guillemot characters
in the dot output and the corresponding SVG file.
Contents | « Previous Next (Class Modelling) » |