UML Diagrams

jGRASP can produce a UML diagram for Java code. The diagram is generated for classes in the source, class, and jar files in the current project. These diagrams are generated directly from the class (or jar) files. If a class file is missing but the source is available, disconnected class nodes will be shown if the source can be parsed, while a <source.java> node will be shown when the source can not be parsed.

Object instances can be created and static methods invoked directly from the UML diagram, by using the context menu. Objects created in this way are put on the debugger workbench, and can then be operated on in various ways. For information on the workbench see Integrated Java Debugger and Workbench.


 
 

UML Window

This window displays the UML diagram.


 
 

File Menu

UML Print - print the diagram. The scale of the printout is based on the scale of the image. 100 pixels of image will be 1 inch on the printout.

UML Print Preview - preview the printout. The preview should be a close approximation of the printed result, but there may be minor differences because of scaling.

UML Print Settings - opens a print settings dialog for workspace or project level settings, and selects the "UML" tab.

Escape Virtual Desktop / Enter Virtual Desktop - moves this window to/from a desktop frame to a free-floating frame.


 
 

Project Menu

Except as noted below, basically a duplicate of the control panel active project menu, but actions apply to the project corresponding to the UML window rather than the active project.

UML Generation Settings - this additional item brings up the UML settings dialog.


 
 

Layout Menu

Tree Down - lays out selected objects, dependents of selected objects, or all objects in a vertically oriented tree. Only inheritance links are considered.

Tree Right - lays out selected objects, dependents of selected objects, or all objects in a horizontally oriented tree. Only inheritance links are considered.

Spring - lays out selected objects or all objects using a spring embedding layout algorithm. All links are considered.


 
 

Edit Menu

Delete Selected Edge Bends - the tree layout algorithms will insert bends in inheritance edges. This will delete them.

Remove From Project - removes selected or unselected files from the project. That is, for each selected or unselected object in the diagram, the source file from which that object was generated will be removed from the project. Also removes any project documentation corresponding to Java source files that are removed. Note that external objects do not have a corresponding source file.

Add To Project - add selected or unselected external object files to the project. All package root directories for files in the project will be searched, and if exactly one source file for a particular external object is found, that file will be added to the project.

Select - extend the current selection by selecting any objects related in a particular way to the currently selected objects. For example, "Recursive Relations" will select all objects directly or indirectly related in any way to the currently selected objects.

UML Generation Settings - brings up the UML settings dialog.


 
 

View Menu

Visible Objects - controls the types of objects that are shown. For example, you can hide non-public objects, or external objects (objects that are not in the project).

Visible Dependencies - controls the types of dependencies that are shown. For example, you can limit the view to inheritance dependency edges only.

Hide / Show - hide selected or unselected objects, or show all objects.

Info - controls various properties of the info display. If "Show Inheritance Within Project" is on and a class is selected, the info window will display accessible fields and methods inherited from classes in the project, but not from other classes.

Legend - controls various properties of the legend display.

Appearance - controls various visual properties of the diagram, such as bold fonts and borders, and antialiasing.


 
 

Compiler Menu

Compile All - using known dependency information, attempts to recompile all Java files in the project using the fewest number of compile commands possible.

Debug Mode - if on, compile in debug mode. This is a global setting in jGRASP.

Compiler Settings - brings up a csd window settings dialog for the current workspace or project, and selects the "Compiler" tab, which allows changing and editing compiler environments.


 
 

Run Menu

Items here have essentially the same function as in the CSD window Run Menu, except that a main() method or an applet will be searched for in the Java classes. If the project contains more than one main() or more than one applet, you must select one of them.


 
 

Workbench Menu

Create New Instance of Class - allows the user to create a new instance of an arbitrary class.

Invoke Static Method - allows the user to invoke a static method on an arbitrary class.

Create Array - allows the user to create an array of arbitrary type.


 
 

Diagram Display

This window displays the UML diagram. A legend shows the meanings of the various object colors and edge styles and colors. Objects that need to be compiled based on source and class file modification times are shown with red crosshatches. Objects with dependencies that need to be compiled are shown with red single hatches (diagonal lines).

The object labels display the class name and package name (if any). If the class is abstract, the class name is italicized in the label. Unparseable source files are shown as objects with the label format <source.java> .

A scroller window at the upper left allows the view to be scrolled quickly.

A scale control allows the magnification of the view to be changed. Due to uneven scaling of fonts, the spacing between objects may change slightly as the scale is changed.

Objects can be selected using the mouse. Left click on an object to select it. Left click and drag a selection rectangle in the window to select multiple objects. Hold down the shift key while selecting to add to the current selection. To select the reverse direction of bi-directional edge, click it again.

When an edge is selected, the dependencies it represents are shown in the info window. Only uses of fields, methods, and constructors of the class are shown. Uses of the class as a whole, for example as method parameters, as fields, or in assignments, are not shown.

When an object that is a part of the project is selected, its members (fields and methods) are shown in the info window.


 
 

Editing the Diagram

To move objects: select then drag one or more objects with the left mouse button.

To move/remove an edge bend: select the edge, then left click and drag the bend. Hitting the delete key while dragging will remove the bend.

To add an edge bend: left click on the edge while holding down the Shift key.


 
 

Info Window

This window displays the fields, constructors (actually <init> methods), and methods for the currently selected edge (dependency) or node (class or interface). For dependencies, only uses of fields, methods, and constructors of the class are shown. Uses of the class as a whole, for example as method parameters, as fields, or in assignments, are not shown.

Primitive types are shown with a triangle icon, objects with a square, and constructors and methods with a CSD "method" unit symbol.

These are the actual dependencies or members from the class file. Some may be generated implicitly, as ("string" + int_variable) will use several StringBuffer methods. Others may be entirely synthetic, such as the "access$" methods used to access private members of a class from its inner class and vice-versa. If the "real" dependency behind a synthetic method can be determined, it will be shown, with the synthetic reference name noted at the end. Synthetic methods for a class are shown with a leading asterisk, as *someMethod(). Synthetic classes and synthetic methods of a class or interface are not shown by default. Synthetic methods can be shown by changing the "View"/"Info"/"Show Synthetic Methods" setting. The display of synthetic classes is controlled by a setting in the UML settings dialog. If shown, synthetic class names also have a leading asterisk.

Double clicking on an item in the list will take you to the first/next definition or use in the source file, if known. All uses will be highlighted. A popup menu (right click on most systems) provides several UML-to-source navigation options. Note that the "List Uses" option in this list will work even if the source file is not known. For a method, the "definition" is the first executable line of the method. For a field, the definition will show up as a use if there is an initializer, otherwise it is not possible to navigate to it. If the class file has line numbers stripped, the navigation will not work.


 
 

Goto Window

This window displays all the nodes (objects) currently in the diagram. Clicking on one will center the diagram on that object. The intention is to make navigating a large diagram easier.


 
 

Run Topmost

If on, windows created by your code will be in "always on top" mode. If your application needs to control the Z-order of windows, or if it launches other gui applications, then you may want to turn this off.


 
 

UML Settings Dialog

Settings for the UML diagram. All of these settings take effect when the diagram is updated.

Exclude By Type of Use - external objects (dependencies of objects in the project that are not themselves in the project) can be left out of the diagram.

Exclude By Type of Class - JDK classes and interfaces, just the class java.lang.Object, and synthetic classes (those generated by the compiler that don't correspond to any source code class), can be left out of the diagram.

New Node Layout - specifies which layout is applied to objects as they are added to the project.