public class IlvGroupSpreadConstraint extends IlvHierarchicalConstraint
IlvGroupSpreadConstraint
is a constraint that
forces a group of nodes to be placed no more than a specified number
of levels apart.
Nodes are organized in horizontal or vertical levels numbered from 0 to "n". If the link flow direction is from top to bottom, the nodes with level index 0 are placed in the topmost level, and the nodes with higher level indexes are placed in the levels below. If the link flow direction is from left to right, the nodes with level index 0 are placed in the leftmost level, and the nodes with higher level indexes are placed in the levels farther to the right.
For instance, a constraint with spread size 2 forces the group to be placed such that the group node with smallest level index is no more than 2 levels apart from the group node with largest level index. All remaining nodes are placed in between. Assume that the group consists of the nodes A, B, and C. The group spread constraint is satisfied if the levels of A, B and C are 1, 2, 3. It is also satisfied if the levels of A, B and C are 10, 9, 8, or 10, 10, 12 or 10, 11, 11, or 10, 10, 10. But it is not satisfied if the levels of A, B and C are 10, 13, 12, because the highest node B is in this case more than 2 levels apart from the lowest node A.
The constraint is evaluated, if the incremental mode is disabled. If the incremental mode is enabled, the constraint is only evaluated if the nodes of the group are marked for incremental recalculation, because otherwise, the incremental positions of the nodes are dominant.
Among the constraints, this kind has the highest priority. If several conflicting constraints are specified (such as two nodes must be placed no more than 2 number of levels apart, but in level 1 and 10), the constraints with lower priority are ignored during layout.
The automatic conflict resolution can handle conflicting constraints. However, to speedup the layout, it is recommended to specify constraints in a way such that there are no conflicts.
The group spread constraint has the same priority as the same level constraint, because both cannot be conflicting. In fact, there are two ways of forcing two nodes to the same level: use the same level constraint, or use a group spread constraint of a group of two nodes with spread size 0.
In recursive layout mode (see IlvHierarchicalLayout.setRecursiveLayoutMode(boolean)
), all nodes of a group
spread constraint must belong to the same subgraph, and the constraint
must be installed at the layout instance that is attached to this
subgraph. It is not possible to have a group spread constraint
containing nodes of different subgraphs.
Constructor and Description |
---|
IlvGroupSpreadConstraint(IlvGroupSpreadConstraint source)
Creates a new
IlvGroupSpreadConstraint by copying an
existing one. |
IlvGroupSpreadConstraint(IlvInputStream stream)
Creates a new
IlvGroupSpreadConstraint from an
IlvInputStream . |
IlvGroupSpreadConstraint(IlvNodeGroup groupArg,
int sizeArg)
Creates a new
IlvGroupSpreadConstraint . |
Modifier and Type | Method and Description |
---|---|
IlvHierarchicalConstraint |
copy()
Copies the constraint.
|
IlvNodeGroup |
getGroup()
Returns the group of this constraint.
|
int |
getSpreadSize()
Returns the spread size of this constraint.
|
void |
setSpreadSize(int spreadSize)
Sets the spread size of the group.
|
void |
write(IlvOutputStream stream)
Writes the constraint to the output stream.
|
getPriority, setPriority
public IlvGroupSpreadConstraint(IlvNodeGroup groupArg, int sizeArg)
IlvGroupSpreadConstraint
.
The following examples show how to use the constraint:
layout.addConstraint( new IlvGroupSpreadConstraint(new IlvNodeGroup(nodeVector), 2));This forces the nodes of nodeVector to be placed no more than 2 levels apart.
groupArg
- The node group.sizeArg
- The maximum number of levels two nodes of the group can
be apart.setSpreadSize(int)
,
IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
public IlvGroupSpreadConstraint(IlvGroupSpreadConstraint source)
IlvGroupSpreadConstraint
by copying an
existing one.
source
- The origin of the copy.public IlvGroupSpreadConstraint(IlvInputStream stream) throws IOException, IlvReadFileException
IlvGroupSpreadConstraint
from an
IlvInputStream
.
stream
- The input stream from which the property must be read.IlvReadFileException
- if an error occurs while reading.IOException
public IlvHierarchicalConstraint copy()
copy
in class IlvHierarchicalConstraint
public void write(IlvOutputStream stream) throws IOException
write
in interface IlvPersistentObject
write
in class IlvHierarchicalConstraint
stream
- The output stream.IOException
- standard IO error.public final IlvNodeGroup getGroup()
public final int getSpreadSize()
setSpreadSize(int)
public final void setSpreadSize(int spreadSize)
spreadSize
- The maximum number of levels two nodes of the group
can be apart.getSpreadSize()
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.