Working with absolute node position indexes is inconvenient
in certain situations. For example, if two nodes belong to the same
level, you might want to force one node to a position with a lower
index than the other node without fixing the absolute positions of
the nodes. You can achieve it by using a relative position constraint.
The relative position constraint forces a specific order
upon the nodes of a level, but it does not specify which nodes are
directly neighbored. For instance, a relative position constraint
can force
nodeA
to be placed somewhere
at a lower position than nodeB
, but there
can be many nodes between nodeA
and nodeB
. Call:
layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalRelativePositionConstraint(nodeA,nodeB,priority));
This forces
nodeA
to a lower
position than nodeB
. If the flow direction
is towards the bottom, the nodes are in horizontal levels; hence the
constraint means that nodeA
is placed at
the left side of nodeB
. If the flow direction
is towards the right, the nodes are in vertical levels; hence the
constraint means that nodeA
is placed below nodeB
. The relative position constraint has an effect only if
both nodes actually belong to the same level. To achieve it, you can,
for instance, use a same level constraint in addition. There is no
way to influence the relative position of nodes that belong to different
levels.
Similar to the relative level constraint, the relative
position constraint can be applied to node groups. These constraints
also have priorities that indicate which constraints dominate if a
constraint conflict occurs. The higher the priority, the more likely
the constraint is satisfied when resolving constraint conflicts.