public class IlvRelativeLevelConstraint extends IlvRelativeConstraint
IlvRelativeLevelConstraint
is a constraint to
place a node relative to another node. It forces a node to be placed
at a level with higher index than another node. The constraint can
also be applied to groups of nodes.
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.
The constraint is evaluated, if the incremental mode is disabled. If the incremental mode is enabled, the constraint is only evaluated for those nodes that are marked for incremental recalculation, because otherwise, the incremental positions of the nodes are dominant.
Among the constraints, this kind is dominated by level range constraints, that is, if the level range for node A is below the level range of node B, then A cannot be forced to be placed in a higher level than B. This kind of constraint is also dominated by the same level constraints, that is, if both nodes A and B are forced to be at the same level, then A cannot be forced to be placed in a higher level than B.
The relative constraints have priorities. Conflicting relative level constraints are resolved by removing the constraint with the smallest priority. Relative level constraints also compete with the links of the graph. Each link acts like a constraint (with the same priority as the link) that forces that the target node is placed in a higher level than the source node.
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.
In recursive layout mode (see IlvHierarchicalLayout.setRecursiveLayoutMode(boolean)
), both nodes of the
relative 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 relative level
constraint containing nodes of different subgraphs.
Constructor and Description |
---|
IlvRelativeLevelConstraint(IlvInputStream stream)
Creates a new
IlvRelativeLevelConstraint from an
IlvInputStream . |
IlvRelativeLevelConstraint(IlvRelativeLevelConstraint source)
Creates a new
IlvRelativeLevelConstraint by copying an
existing one. |
IlvRelativeLevelConstraint(Object lowerNodeOrGroup,
Object higherNodeOrGroup,
float priority)
Creates a new
IlvRelativeLevelConstraint . |
Modifier and Type | Method and Description |
---|---|
IlvHierarchicalConstraint |
copy()
Copies the constraint.
|
Object |
getHigherSubject()
Returns the subject of this constraint that is placed at the levels
with higher index than the other subject.
|
Object |
getLowerSubject()
Returns the subject of this constraint that is placed at the levels
with lower index than the other subject.
|
void |
write(IlvOutputStream stream)
Writes the constraint to the output stream.
|
getPriority, setPriority
public IlvRelativeLevelConstraint(Object lowerNodeOrGroup, Object higherNodeOrGroup, float priority)
IlvRelativeLevelConstraint
. The following
example shows how to use the constraint:
layout.addConstraint( new IlvRelativeLevelConstraint(node1, node2, priority));This forces node2 to be placed at a level with higher index than node1.
In order to apply the constraint to a groups of nodes, you can use this:
layout.addConstraint( new IlvRelativeLevelConstraint( new IlvNodeGroup(nodeVector1), new IlvNodeGroup(nodeVector2), priority));This forces the nodes of nodeVector2 to be placed at a level with higher index than the nodes of nodeVector1.
lowerNodeOrGroup
- A node, or a group of type IlvNodeGroup
that is placed in levels below the second node or group.higherNodeOrGroup
- A node, or a group of type IlvNodeGroup
that is placed in levels above the first node or group.priority
- The priority of the constraint.IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
public IlvRelativeLevelConstraint(IlvRelativeLevelConstraint source)
IlvRelativeLevelConstraint
by copying an
existing one.
source
- The origin of the copy.public IlvRelativeLevelConstraint(IlvInputStream stream) throws IOException, IlvReadFileException
IlvRelativeLevelConstraint
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 IlvRelativeConstraint
stream
- The output stream.IOException
- standard IO error.public final Object getLowerSubject()
IlvNodeGroup
that
describes a group of nodes.public final Object getHigherSubject()
IlvNodeGroup
that
describes a group of nodes.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.