When the Recursive Layout is attached, you
can conveniently access all layouts that will be used during
layout. This works in all layout modes:
Enumeration getLayouts(boolean preOrder)
As explained in Internal mechanism, the
getLayouts
method returns an enumeration of instances of
IlvGraphLayout
. If the
preOrder
flag is
true
, the layout of the parent graph occurs before the layout of its
child nodes in the enumeration.
If the
preorder
flag is
false
, the layout of the parent graph occurs after the layout of its
child nodes. For example, in the graph in the following figure, the
call
getLayouts(true)
returns the layouts for the subgraphs in this order: L1, L1.1,
L1.1.1, L1.1.2, L1.2; the call
getLayouts(false)
returns the layouts for the subgraphs in this order: L1.1.1,
L1.1.2, L1.1, L1.2, L1.
![Nested
graph with recursive layouts shown from upper to lower part of the
figure on the left: L1, L1.1, L1.1.1, L1.1.2. Subgraph layout L1.2
is shown on the right.](../../../GraphLayout/_media/layout-Recursive-prepostorder5_default.gif)
Nesting structure in a graph
Note
In specified provider mode, the enumeration returned by
getLayouts
contains the instances that are delivered by the specified
provider. If the specified provider returns a different instance
in each call of
getGraphLayout(IlvGraphModel)
, then the enumeration does not contain the instances that are
later used during layout. Hence it is recommended to use layout
providers that store the layout instances internally and return
the same instance for the same graph model. The predefines
IlvDefaultLayoutProvider
and
IlvRecursiveLayoutProvider
store the layout instances internally.
Convenience method for setting reference layout mode
The class
IlvGraphLayout
contains a convenience method. To perform a recursive layout
recursively, you can use:
int performLayout(boolean force, boolean redraw, boolean traverse)
If the
traverse
flag is
true
, it traverses the nested graph and performs the layout on each
subgraph. This is a shortcut for the reference mode of Recursive
Layout. The statement:
flatLayout.performLayout(force, redraw, true);
is equivalent to creating a Recursive Layout in reference mode
that uses the
flatLayout
as reference layout:
IlvRecursiveLayout recursiveLayout = new IlvRecursiveLayout(flatLayout); recursiveLayout.performLayout(force, redraw);