The examples and explanations above assume that you work with a
flat manager. Rogue Wave® JViews
Diagrammer allows you to nest a grapher as a node into another
grapher. You can create a hierarchy of nested graphers (see the
following figure); see also Nested graphers in Advanced
Features of JViews
Framework
).
You can apply a recursive graph layout to
the nested grapher hierarchy by calling:
graphLayout.performLayout(true, true, true);
However, it usually makes no sense to apply
a label layout alone to nested graphers. When labels are placed in
a subgrapher, this will likely change the bounds of the subgrapher;
hence the node positions in its parent grapher will no longer be
up-to-date and a new graph layout will be necessary.
It makes sense to apply a label layout in
combination with another graph layout to nested graphers.
- First, the graph layout is applied to arrange the nodes and links nicely.
- Then the label layout is applied to position the labels according to the node and link positions.
- When this is finished for all subgraphers, then it can be done for the parent grapher.
To perform a graph layout and a label layout together, you can use
the Multiple Layout class. This is a subclass of
IlvGraphLayout
that allows combining graph layouts with a label layout. The
following sample shows how to apply a Tree Layout and an Annealing
Label Layout in combination on a subgrapher.
IlvTreeLayout treeLayout = new IlvTreeLayout(); IlvAnnealingLabelLayout labelLayout = new IlvAnnealingLabelLayout(); IlvGraphLayout multipleLayout = new IlvMultipleLayout(treeLayout, null, labelLayout); // Now set the parameters for tree layout and label layout ... // Finally, perform a recursive layout that handles tree layout and label // layout together try { multipleLayout.performLayout(true, true, true); } catch (IlvGraphLayoutException e) { ... }
Thus, the label layout does not provide a separate mechanism for a
recursive layout on submanagers. By incorporating the label layout
into a multiple graph layout, you can use all the graph layout
facilities that are available for nested graphs (see also Nested layouts).
![A graph
with subgraphs, showing label layout](../../../GraphLayout/_media/layout-Annealing-nesting4_default.gif)
Nested subgraphers with labels