Orthogonal Layout of Hierarchically Organized Graphs

Class OrthogonalGroupLayouter is an orthogonal layout provider specialized for laying out hierarchically organized graphs.

Those parts of a graph that belong to the same group will be placed in a way that they share a common rectangular area in the layout space. The positions and sizes of these group nodes will be calculated by the algorithm.

The layout algorithm is well suited for medium-sized sparse graphs. It produces compact drawings with no overlaps, few crossings, and few bends.

Figure 5.48. Sample group layouts produced by class OrthogonalGroupLayouter

Sample group layouts produced by class OrthogonalGroupLayouter
Sample group layouts produced by class OrthogonalGroupLayouter
A diagram with four groups and edges connecting nodes within these groups. A diagram with grouped groups.

Supplemental Layout Data

Class OrthogonalGroupLayouter knows a number of data provider keys which are used to retrieve supplemental layout data for a graph's elements. The data is bound to the graph by means of a data provider, which is registered using a given look-up key. Table 5.24, “Data provider look-up keys” lists all look-up keys for OrthogonalGroupLayouter.

Binding supplemental layout data to a graph is described in the section called “Providing Supplemental Layout Data”.

Table 5.24. Data provider look-up keys

Key Element Type Value Type Description
GROUP_DPKEY Node boolean For each node a boolean value indicating whether it is a group node or not.
NODE_ID_DPKEY Node Object For each node an Object that serves as a unique ID.
PARENT_NODE_ID_DPKEY Node Object For each node an Object indicating the group node it belongs to. The Object matches the unique ID of a group node that is in the same graph.
GROUP_NODE_INSETS_DPKEY Node Insets For each group node a java.awt.Insets object that encodes the group node's insets.

Setup of a graph's hierarchical organization and using the grouping keys (GROUP_DPKEY, NODE_ID_DPKEY, and PARENT_NODE_ID_DPKEY) is described in detail in the section called “Setup for Layout”.

Layout Options

Unlike the more general orthogonal layout algorithm this specialized layout algorithm provides only a few options.

Grid (see API)

Defines the virtual grid spacing used by the layouter. Each node will be placed in such a way that its center point lies on a grid point. Edges will be routed in such a way that their segments lie on grid lines, if the terminal nodes of the edges allow to place the ports accordingly.

Layout Quality (see API)

Sets the desired layout quality. Higher values result in less connection crossings and smaller layout area, but also increased computation time.

The additional size requirements of group nodes (e.g., special insets or space for custom labels) can be specified by the use of a data provider that provides java.awt.Insets objects for each group node. The data provider must be registered with the input graph using the key GROUP_NODE_INSETS_DPKEY.

Tutorial Demo Code

Layout module OrthogonalLayoutModule.java presents the setup of class OrthogonalGroupLayouter in an application context.