You can add constraints to the Hierarchical Layout by
allocating a new constraint object and calling this method on the ibm_ilog.graphlayout.hierarchical.HierarchicalLayout instance:
layout.addConstraint(constraint);
You can add as many constraints as you want. The constraints
are respected during the subsequent layout calls until you remove
them. To remove the most recent constraint, call:
layout.removeMostRecentConstraint();
To remove a specific constraint, call:
layout.removeConstraint(constraint);
To remove all existing constraints, call:
layout.removeAllConstraints();
You can retrieve the constraints that were added to a
Hierarchical Layout with the method:
var constraints = layout.getConstraints(); while(constraints.hasNext()){ var constraint = constraints.next(); // ... }
Node groups
Some constraints affect single nodes. Other constraints
affect groups of nodes. The class ibm_ilog.graphlayout.hierarchical.HierarchicalNodeGroup is
a convenient way to specify a group of nodes. You can create a group
of nodes in the following way:
group = new ibm_ilog.graphlayout.hierarchical.HierarchicalNodeGroup(); while (...) { group.add(node); }
A node group has a similar functionality to a vector.
You can ask for the size and elements of the group, remove elements
from the group, or check whether a node already belongs to the group.
You can also convert a vector of nodes into a group:
group.add(node) |
Adds a node to the group. |
group.remove(node) |
Removes a node from the group. |
group.contains(node) |
Checks whether a node is in the group. |
group.size() |
Returns the number of nodes in the group. |
group.elements() |
Returns the nodes of the group as a simple
cursor (IIterator). |
group = new ibm_ilog.graphlayout.hierarchical.HierarchicalNodeGroup(array) |
Creates a group that contains the nodes stored
in the input array. |