To force a node to the first level, you can
specify:
layout.setSpecNodeLevelIndex(node, 0);
However, you cannot specify a level index
for the last level because it is unknown at the beginning of layout
how many levels are created. It is unwise to specify:
layout.setSpecNodeLevelIndex(node, java.lang.Integer.MAX_VALUE);
because it creates many empty levels between
the levels used and the last one. Even though these empty levels
are removed in postprocessing steps, it influences the speed and
quality of the layout. (In fact, the algorithm runs out of memory
if you set the specified level index unreasonably high.)
By using constraints you can achieve the
same effect more efficiently.
To force a node to the first level:
In CSS
In the constraint file, specify:
ExtremityConstraint { node: node side: NORTH }
In Java
In Java™ , call:
layout.addConstraint( new IlvExtremityConstraint(node, IlvHierarchicalLayout.NORTH));
To force a node to the last level:
In CSS
In the constraint file, specify:
ExtremityConstraint { node: node side: SOUTH }
In Java
Call:
layout.addConstraint( new IlvExtremityConstraint(node, IlvHierarchicalLayout.SOUTH));
With compass directions as a convenient reference (see Port sides parameter (HL)), the first level
indicates the north pole and the last level indicates the south
pole. You can also specify extremity constraints for the east and
west sides:
layout.addConstraint( new IlvExtremityConstraint (node1, IlvHierarchicalLayout.EAST)); layout.addConstraint( new IlvExtremityConstraint (node2, IlvHierarchicalLayout.WEST));
The west extremity constraint forces the
node to the lowest position index within its level, and the east
extremity constraint forces the node to the highest position
index within its level. The position indexes specify the relative
position within the level. For instance, a node with west
extremity constraint is the leftmost node within its level, if
the flow direction is towards the bottom. However, it does not
affect other levels; there can be a node in another level that is
still placed farther to the left.
The following figure illustrates some
extremity constraints.
![Example
of Hierarchical Layout illustrating the extremity contraint](../../../GraphLayout/_media/layout-Hierarchical-extrconst107_default.gif)
Sketch of Extremity Constraints