Perforce JViews Diagrammer Code Example: Recursive Layout
Description
This sample illustrates how to perform a layout of nested
graphers.
It shows the usage of the Recursive Layout algorithm on nested graphers.
This sample uses the graphic framework, but it does not use
the IlvDiagrammer
component or CSS.
How to Use the Code Example
- The JViews Graph Layout algorithms work on nested graphers. A nested grapher is a grapher with subgraphers as nodes. Most layout algorithms work on flat graphers. In order to apply these layout algorithms on a nested grapher, the Recursive Layout algorithm is used. This layout algorithm is just a facility to manage the sublayouts used for each subgrapher. When the Recursive Layout is performed, it traverses the subgraphers of a nested grapher and applies the sublayouts to the subgraphers. Any graph layout for flat graphers can be used as sublayout.
-
This application shows a manager view that displays a grapher read from an
IVL
file. You may change the grapher sample using the Select Graphlist at the top of the application window. - The application also has interactor buttons on the top of the window. They are: pan, select, zoom box, zoom in, zoom out, and show all (fit to contents).
- The Recursive Layout has several layout modes: In the reference layout mode, the reference layout is applied to all subgraphers. This means the same layout style with the same global parameters is used everywhere. In the internal provider mode, the reference layout allows you to specify a different layout for each individual subgraph. The checkbox at the top right allows to switch from reference layout mode (same layout everywhere selected) to internal provider mode (same layout everywhere deselected).
-
Below the graph selector is the sublayouts list (Select Layout).
The options are "tree", "radial", "tip-over"
and "uniform". They correspond
to specific settings of
IlvTreeLayout
andIlvUniformLengthEdgesLayout
. In reference layout mode (Same layout everywhere is selected), you can use this selector to choose the reference layout that is used for all subgraphs. In internal provider mode (Same layout everywhere is unselected), you can select a specific subgraph by clicking on the subgraph, then use the selector to choose the layout for this subgraph. If no subgraph is selected when you use the selector, you choose the layout of the top level graph. After changing the selection, the layout is performed automatically. - The status line at the bottom of the window displays a message indicating which action was performed. During layout, the status line shows the percentage of the layout task that has been completed.
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,
recursivelayout.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
- Recursive Layout in Java Code
- Nested Graphs
Installation Directory
The Recursive Layout code example is installed here.