Level range constraints (HL)

In Step 1 of the layout algorithm (the leveling phase), the nodes are partitioned into levels. These levels are indexed starting from 0. For instance, when the flow direction is to the bottom, the nodes of the level index 0 are placed at the topmost horizontal level line and the nodes with larger level index are placed at a position lower than the nodes with smaller level index (see Level and position indexes). The layout algorithm calculates these level indexes automatically.
You can choose how the levels are partitioned by specifying the range of the level index for some nodes. The nodes are placed in the levels whose index is in the specified range. You have to specify the minimum and maximum index of the level.
To specify the minimum and maximum index of the level:
Call:
layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalLevelRangeConstraint(node, 5, 7));
If you want to place the node exactly at level 5, call:
layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalLevelRangeConstraint(node, 5, 5));
Alternatively, you can call:
layout.setSpecNodeLevelIndex(node, 5);
which has the same meaning.
If you want to force the node to level 5 and above, set UNSPECIFIED as the maximum level.
Call:
layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalLevelRangeConstraint(node, 5, ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.UNSPECIFIED));
If you want to force the node to level 5 and below (that is, level 0, ..., 5), set UNSPECIFIED as the minimum level. For example:
layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalLevelRangeConstraint(node, ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.UNSPECIFIED, 5));
In this particular case, you could also use zero (0) as the minimum level because the level indexes start at 0.
You can apply the constraint to a group of several nodes at once. It has the same effect as specifying the constraint for each single node of the group, but it is more memory efficient and convenient. For instance, if you want to force the group of three nodes to the levels 5 - 7:
To specify these parameters:
Create a NodeGroup object (see Node groups) of the three nodes and add it to the constraint in the following way:
layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalLevelRangeConstraint(nodeGroup, 5, 7));