public class IlvRelativePositionConstraint extends IlvRelativeConstraint
IlvRelativePositionConstraint
is a constraint
to place a node relative to another node that belongs to the same
level. It does not affect the order of nodes that belong to different
levels. It forces a node to be placed after another node within the
same level. The constraint can also be applied to groups of nodes.
Nodes are organized in horizontal or vertical levels. Within each level, the nodes are placed sequentially at relative positions numbered from 0 to "n". If the link flow direction is from top to bottom, the node with position index 0 is placed leftmost within its level, and the nodes with higher position indexes are placed farther to the right. If the link flow direction is from right to left, the node with position index 0 is placed topmost within its level, and the nodes with higher position indexes are placed below. The constraint specifies that a node is placed at a higher position index than another node. The constraint is ignored, if both nodes do not belong to the same level.
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 side by side constraints, that is, if a node A and B must be placed side by side, then a node C cannot be forced to be at a higher position than A but at a lower position than B at the same time. The node C cannot be forced to be placed in between A and B. The constraint is also dominated by specified position indexes, i.e. it does not change the order of nodes that have specified position indexes, and by swimlane constraints, that is, it is not able to break swimlanes apart.
The relative constraints have priorities. Conflicting relative position constraints are resolved by removing the constraint with the smallest priority.
The automatic conflict resolution can handle conflicting constraints. However, to speed up 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 position 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 position
constraint containing nodes of different subgraphs.
Constructor and Description |
---|
IlvRelativePositionConstraint(IlvInputStream stream)
Creates a new
IlvRelativePositionConstraint from an
IlvInputStream . |
IlvRelativePositionConstraint(IlvRelativePositionConstraint source)
Creates a new
IlvRelativePositionConstraint by copying an
existing one. |
IlvRelativePositionConstraint(Object lowerNodeOrGroup,
Object higherNodeOrGroup,
float priority)
Creates a new
IlvRelativePositionConstraint . |
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 IlvRelativePositionConstraint(Object lowerNodeOrGroup, Object higherNodeOrGroup, float priority)
IlvRelativePositionConstraint
.
The following example shows how to use the constraint:
layout.addConstraint( new IlvRelativePositionConstraint(node1, node2, priority));If node1 and node2 are placed at the same level, then this forces node2 to be placed at a higher position index than node1. If the flow direction is top down, this means that node2 is placed to the right of node1.
In order to apply the constraint to a groups of nodes, you can use this:
layout.addConstraint( new IlvRelativePositionConstraint( new IlvNodeGroup(nodeVector1), new IlvNodeGroup(nodeVector2), priority));This forces the nodes of nodeVector2 to be placed at a higher position index than the nodes of nodeVector1 that belong to the same level.
lowerNodeOrGroup
- A node, or a group of type IlvNodeGroup
that is placed at lower positions than the second node or group.higherNodeOrGroup
- A node, or a group of type IlvNodeGroup
that is placed at higher positions than the first node or group.priority
- The priority of the constraint.IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
public IlvRelativePositionConstraint(IlvRelativePositionConstraint source)
IlvRelativePositionConstraint
by copying an
existing one.
source
- The origin of the copy.public IlvRelativePositionConstraint(IlvInputStream stream) throws IOException, IlvReadFileException
IlvRelativePositionConstraint
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()
The subject is either the constraint node, or the instance of IlvNodeGroup
that describes a group of nodes.
public final Object getHigherSubject()
The subject is either the constraint node, or the instance of IlvNodeGroup
that describes a group of nodes.
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.