Perforce JViews Diagrammer Code Example: Filtering Links in Complex Diagrams (Java SDK Version)
Description
This code example shows how to layout and display a very large, dense diagram that
has many links.
If all the links are displayed at the same time, the display is too cluttered.
However, some links can be filtered out and a Tree Layout algorithm applied.
The nontree links are displayed only when exploring the diagram
by moving the mouse pointer over the nodes.
This code example uses the graphic framework, but does not use
the IlvDiagrammer
component or CSS.
How to Use the Code Example
- This code example shows the static compile time dependencies of 1,538 Java classes from JDK 1.4. This is a very large and very dense graph with 8,032 links between the nodes. This is too many links to display at the same time, otherwise the display will be too cluttered no matter which layout algorithm is used. However, the application can display the links in a filtered way.
- The nodes in the diagram represent the Java classes. The nodes are clustered into subgraphs representing the Java packages. A link represents the fact that the target Java class requires the source Java class when being compiled.
- This application shows a manager view with the graph in the left pane. The subgraphs (Java packages) are laid out by the Grid Layout algorithm. The nodes (Java classes inside a package) are laid out by the Tree Layout algorithm. Both algorithms are very fast and can handle very large graphs.
- The checkbox at the top of the view allows you to select whether all links are filtered or whether all links are displayed. When the checkbox is selected, all links are displayed and the view is cluttered and unusable. When the checkbox is deselected, only the links of the spanning tree are displayed. Other links are hidden and the view is readable.
- The buttons at the top of the view allow you to pan and zoom the diagram.
- The S button activates the Show Links interactor. When this button is selected, moving the mouse over the diagram displays the hidden links. This allows you to explore the graph interactively.
-
in the right pane is the detail view that is filled by the
Show Links interactor.
The Show Links interactor works as follows:
- When the mouse points to a node, the incoming links appear in red and the outgoing links appear in blue.
- A textual explanation appears in the detail view stating: the Java class corresponding to that node, the Java classes needed to compile this class, and the Java classes that require this class for compilation. This corresponds to the highlighted links.
- When you click a node, the interactor freezes so that the highlighted links do not change when moving the mouse. This allows you to scroll or zoom to see the details of the current node or the highlighted links. To return to the normal state, click in the view again.
How to Run the Code Example as an Application
This code example can
be run as an application.
The installation directory contains
an executable JAR file,
filterlinks.jar
,
that allows you to execute the code example with a double click from a
file browser. Note that if you are using Internet Explorer, you can
open the installation directory
and execute the JAR file from the browser. This
technique may not work in other Web browsers.
Alternatively, you
can run the code example application from the command line.
First check that the Ant utility is properly configured. If not, see the
instructions on how to configure Ant for Perforce JViews.
Then, go to the installation directory
of the code example and type:
ant run
Topics Covered
- Grapher
- Graph Layout
- Layout Graphic Filter
- Recursive Layout in Java Code
- Grid Layout in Java Code
- Tree Layout in Java Code
Installation Directory
The Filtering Links in Complex Diagrams (Java SDK Version) code example is installed here.
Classes Involved
- ilog.views.graphlayout.IlvLayoutGraphicFilter
- ilog.views.graphlayout.recursive.IlvRecursiveLayout
- ilog.views.graphlayout.tree.IlvTreeLayout
- ilog.views.graphlayout.grid.IlvGridLayout
- ilog.views.IlvGrapher
- ilog.views.IlvManagerView
- ilog.views.IlvManagerViewInteractor