public class IlvSameLevelConstraint extends IlvHierarchicalConstraint
IlvSameLevelConstraint
is a constraint that
forces two nodes to be placed at the same level.
The constraint is evaluated, if the incremental mode is disabled. If the incremental mode is enabled, the constraint is only evaluated if at least one of the nodes is 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 the node must be placed in a lower level than another node and at the same level as this other node), 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 same level constraint has the same priority as the group spread 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)
), both nodes of the same
level 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 same level constraint
containing nodes of different subgraphs.
Constructor and Description |
---|
IlvSameLevelConstraint(IlvInputStream stream)
Creates a new
IlvSameLevelConstraint from an
IlvInputStream . |
IlvSameLevelConstraint(IlvSameLevelConstraint source)
Creates a new
IlvSameLevelConstraint by copying an
existing one. |
IlvSameLevelConstraint(Object node1,
Object node2)
Creates a new
IlvSameLevelConstraint . |
Modifier and Type | Method and Description |
---|---|
IlvHierarchicalConstraint |
copy()
Copies the constraint.
|
Object |
getFirstNode()
Returns the first node of this constraint.
|
Object |
getSecondNode()
Returns the second node of this constraint.
|
void |
write(IlvOutputStream stream)
Writes the constraint to the output stream.
|
getPriority, setPriority
public IlvSameLevelConstraint(Object node1, Object node2)
IlvSameLevelConstraint
.
The following example shows how to use the constraint:
layout.addConstraint(new IlvSameLevelConstraint(node1, node2));This forces node1 to be placed at the same level as node2.
node1
- The one node.node2
- The other node.IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
public IlvSameLevelConstraint(IlvSameLevelConstraint source)
IlvSameLevelConstraint
by copying an
existing one.
source
- The origin of the copy.public IlvSameLevelConstraint(IlvInputStream stream) throws IOException, IlvReadFileException
IlvSameLevelConstraint
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 Object getFirstNode()
public final Object getSecondNode()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.