The Hierarchical Layout allows you to
specify the level index and the position index of a node.
In CSS
Specify the level and position index of a node with ID “
node1
” in the following way:
#node1 { SpecNodeLevelIndex: "5"; SpecNodePositionIndex: "33"; }
In Java™
You specify the level and position index
of a graphic node in the following way:
layout.setSpecNodeLevelIndex(node, 5); layout.setSpecNodePositionIndex(node, 33);
How these indexes are used depends on the graph topology and the
additional constraints. For example, the specified level index
can be in conflict with some IlvLevelRangeConstraint or IlvSameLevelConstraint. In this case, the
constraint priorities determine how the conflict is resolved (see
Constraint
priorities (HL)). If the incremental mode is enabled, the
specified node level and position index are ignored, since the
incremental mode tries to preserve old node positions. It is also
possible to obtain the indexes of nodes that were calculated
during layout.
Calculated level index
The layout algorithm allows you to access
the level index that was calculated for a node by a previous
layout. Use the method:
int getCalcNodeLevelIndex(Object node)
If the node was never laid out, this method returns
-1
. Otherwise, it returns the previous level index of the node.
In an application that specifies layout
parameters entirely in Java, the method can be used to specify
the level index for the next layout in the following way:
int index = layout.getCalcNodeLevelIndex(node); layout.setSpecNodeLevelIndex(node, index);
It ensures that the node is placed at the
same level as in the previous layout.
If the graph is detached from the layout algorithm, the
calculated level index of a node is set back to
-1
.
Note
Be aware of the difference between the methods getCalcNodeLevelIndex and getSpecNodeLevelIndex. The first one
returns the level index calculated by the previous layout. The
second one returns the specified level index, even if there
was no previous layout.
For instance, consider two nodes A and B. Node A has no
specified level index and node B has a specified level index
5. Before the first layout, the method
getCalcNodeLevelIndex
returns -1 for both nodes because the levels have not been
calculated yet. However,
getSpecNodeLevelIndex
returns -1 for A and 5 for B. After the first layout, node A
can be placed at level 4. Now,
getCalcNodeLevelIndex
returns 4 for node A and 5 for node B and
getSpecNodeLevelIndex
still returns -1 for A and 5 for B.
Calculated position index
The layout algorithm allows you to access
the position index within a level that was calculated for a node
by a previous layout. Use the method:
If the node was never laid out, this
method returns -1. Otherwise, it returns the previous position
index of the node within its level.
To ensure that the node is placed at the
same level at the same relative position as in the previous
layout, use the following code in an application that specifies
layout parameters entirely in Java:
layout.setSpecNodeLevelIndex(node, layout.getCalcNodeLevelIndex(node));
This example code works only if the generic connected component
layout is disabled and the port sides
EAST
or
WEST
are not used in the layout.
If the graph is detached from the layout
algorithm, the calculated position index of a node is set back to
-1.
Note
Be aware of the difference between the methods getCalcNodePositionIndex and setSpecNodePositionIndex.The first one
returns the position index calculated by the previous layout
and -1 if there was no previous layout. The second one returns
the specified position index even if there was no previous
layout. This behavior is similar to the behavior of the
specified and calculated level index (see Calculated level index).