Class Diagram Operations
To use UMLGraph class drawing facility you need to have
javadoc
and
Graphviz
installed on your computer.
Both programs are freely available, from Sun and AT&T respectively,
for many platforms including Unix and Windows.
UMLGraph's input follows the Java syntax and semantics.
However,
since the main purpose of UMLGraph is the declarative specification of
UML diagrams there is no need to flesh-out each class's methods,
to completely specify each class, or to specify package information.
You only specify the details you want to appear on the graph.
If you wish your (Java) implementation to evolve together with the
design feel free to include code or additional details.
You can hide these details from the UML diagram using the javadoc
@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 is not designed for this purpose;
the resulting graphs may be large and unwieldy.
UMLGraph is implemented as a javadoc doclet (a program satisfying the
doclet API that specifies the content and format of the output
generated by the javadoc tool).
Javadoc is part of the Sun JDK, so a typical JDK installation will also
include javadoc.
Before running javadoc you need to place the UmlGraph.jar
file in a location accessible by javadoc
(e.g. the Java class path or the current directory).
You then run javadoc with arguments -doclet UmlGraph
-docletpath /path/to/UmlGraph.jar
and append at the end the file(s) that contain your diagram
specification.
You can of course use any of the javadoc general options;
-private is usually needed to avoid having to explicitly
specify public elements.
Specifying 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.
Example:
javadoc -docletpath UmlGraph.jar -doclet UmlGraph -private Simple.java
javadoc will create by default a file named graph.dot
in the current directory; option to
this is a text file that can be processed by the Graphviz
dot program to layout and draw the graph.
A command line like the following will convert the graph.dot
file into Postscript:
dot -Tps -ograph.ps graph.dot
Refer to the dot documentation for information on creating other file formats
or adjusting the UMLGraph output.
Note that when you use dot for generating SVG diagrams your
should specify the -outputencoding UML8 option to UMLGraph.
This option will correctly render the stereotype guillemot characters
in the dot output and the corresponding SVG file.