public class IlvSideBySideConstraint extends IlvHierarchicalConstraint
IlvSideBySideConstraint
is a constraint that
forces a group of nodes that belong to the same level to be placed
side by side. It prohibits that other nodes of the same level are
placed in the middle of the group. By this, the relative positions of
the nodes of the group are close together. It does not affect the
order of nodes that belong to different levels.
Nodes are organized in horizontal or vertical levels. Within each level, the nodes are placed sequentially at relative positions numbered from 0 to "n". The constraint specifies that those nodes of the group that belong to the same level are placed in subsequent positions within the level. The constraint is ignored, if all nodes of the group belong to different levels.
For instance, assume the group consists of nodes A, B, C, D, E. If A, B and C belong to one level and D and E to another level, then the side by side constraint forces the nodes A, B, C to be placed side by side, and D and E to be placed side by side. The constraint is satisfied if the positions of A, B, C are 5, 6, 7 and the positions of D and E are 1 and 2. The constraint affects only the nodes that belong to the same level, therefore the constraint affects the subgroup ( A, B, C ) and the subgroup ( D, E ) individually, not the entire group ( A, B, C, D, E ) as a unit. The constraint is not satisfied if the positions of A, B and C are 5, 7 and 8, because in this case, there must be a node between A and B that does not belong to the same group. The node between A and B cannot be D or E, because D and E belong to a different level.
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.
This kind of constraint dominates the relative position constraints. The constraints have priorities. If several conflicting constraints are specified (such as a node must be side by side to three different groups), the constraints with lower priority are ignored during layout. The constraint is 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 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)
), all nodes of the group
of a side by side 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 side by side constraint
containing a group of nodes of different subgraphs.
Constructor and Description |
---|
IlvSideBySideConstraint(IlvInputStream stream)
Creates a new
IlvSideBySideConstraint from an
IlvInputStream . |
IlvSideBySideConstraint(IlvNodeGroup groupArg,
float priorityArg)
Creates a new
IlvSideBySideConstraint . |
IlvSideBySideConstraint(IlvSideBySideConstraint source)
Creates a new
IlvSideBySideConstraint by copying an
existing one. |
Modifier and Type | Method and Description |
---|---|
IlvHierarchicalConstraint |
copy()
Copies the constraint.
|
IlvNodeGroup |
getGroup()
Returns the group of this constraint.
|
void |
write(IlvOutputStream stream)
Writes the constraint to the output stream.
|
getPriority, setPriority
public IlvSideBySideConstraint(IlvNodeGroup groupArg, float priorityArg)
IlvSideBySideConstraint
.
The following examples show how to use the constraint:
layout.addConstraint( new IlvSideBySideConstraint(new IlvNodeGroup(nodeVector), priority));This forces those nodes of nodeVector that belong to the same level to be placed side by side.
groupArg
- The node group.priorityArg
- The priority of the constraint.IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
public IlvSideBySideConstraint(IlvSideBySideConstraint source)
IlvSideBySideConstraint
by copying an
existing one.
source
- The origin of the copy.public IlvSideBySideConstraint(IlvInputStream stream) throws IOException, IlvReadFileException
IlvSideBySideConstraint
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()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.