public class IlvLevelRangeConstraint extends IlvHierarchicalConstraint
IlvLevelRangeConstraint
is a constraint that
forces the node to be placed at a level with index within the
specified range.
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 level range constraint with minimum index 5 and
maximum index 7 causes the node to be placed at level with index 5, 6,
or 7. A level range with minimum index 6 and maximum index 6 causes
the node to be placed exactly at level 6. This has the same effect as
specifying the node level index 6 by IlvHierarchicalLayout.setSpecNodeLevelIndex(Object, int)
.
The constraint is evaluated, if the incremental mode is disabled. If the incremental mode is enabled, the constraint is only evaluated if the constraint node is marked for incremental recalculation, because otherwise, the incremental positions of the nodes are dominant.
This kind of constraint is dominated by same level constraints and group spread constraints, that is, two nodes cannot have different level ranges while being forced to the same level. The constraint has higher priority than any relative level constraints.
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.
Note that empty levels are invisible after layout. For instance a node with level range constraint to be placed at level 2 may appear to be placed in the topmost level, if level 0 and 1 don't contain any other nodes.
In recursive layout mode (see IlvHierarchicalLayout.setRecursiveLayoutMode(boolean)
), all nodes of the group of a level 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 level spread constraint containing a group of nodes of different subgraphs.
Constructor and Description |
---|
IlvLevelRangeConstraint(IlvInputStream stream)
Creates a new
IlvLevelRangeConstraint from an
IlvInputStream . |
IlvLevelRangeConstraint(IlvLevelRangeConstraint source)
Creates a new
IlvLevelRangeConstraint by copying an
existing one. |
IlvLevelRangeConstraint(Object nodeOrGroup,
int minLevel,
int maxLevel)
Creates a new
IlvLevelRangeConstraint . |
Modifier and Type | Method and Description |
---|---|
IlvHierarchicalConstraint |
copy()
Copies the constraint.
|
int |
getMaxLevel()
Returns the maximum level index suitable for the subject of this
constraint (that is, for the node or the group of nodes).
|
int |
getMinLevel()
Returns the minimum level index suitable for the subject of this
constraint (that is, for the node or the group of nodes).
|
Object |
getSubject()
Returns the subject of this constraint.
|
void |
setLevelRange(int minLevel,
int maxLevel)
Sets the level range suitable for the subject of this constraint (that
is, for the node or the group of nodes).
|
void |
setMaxLevel(int maxLevel)
Sets the maximum level index suitable for the subject of this
constraint, that is, for the node or the group of nodes.
|
void |
setMinLevel(int minLevel)
Sets the minimum level index suitable for the subject of this
constraint, that is, for the node or the group of nodes.
|
void |
write(IlvOutputStream stream)
Writes the constraint to the output stream.
|
getPriority, setPriority
public IlvLevelRangeConstraint(Object nodeOrGroup, int minLevel, int maxLevel)
IlvLevelRangeConstraint
.
The following examples show how to use the constraint:
layout.addConstraint(new IlvLevelRangeConstraint(node1, 5, 7)); layout.addConstraint(new IlvLevelRangeConstraint(node2, 5, IlvHierarchicalLayout.UNSPECIFIED)); layout.addConstraint(new IlvLevelRangeConstraint(node3, IlvHierarchicalLayout.UNSPECIFIED, 7));This forces node1 to be in level 5, 6, or 7, and node2 to be in a level with index greater or equal to 5, and node3 to be in a level with index smaller or equal to 7.
nodeOrGroup
- A node, or a group of type IlvNodeGroup
, that
should be placed in the specified level range.minLevel
- The lower bound of the level range, or IlvHierarchicalLayout.UNSPECIFIED
if no lower bound is needed.maxLevel
- The upper bound of the level range, or IlvHierarchicalLayout.UNSPECIFIED
if no upper bound is needed.setLevelRange(int, int)
,
IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
public IlvLevelRangeConstraint(IlvLevelRangeConstraint source)
IlvLevelRangeConstraint
by copying an
existing one.
source
- The origin of the copy.public IlvLevelRangeConstraint(IlvInputStream stream) throws IOException, IlvReadFileException
IlvLevelRangeConstraint
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 getSubject()
IlvNodeGroup
that describes a group
of nodes.public final int getMinLevel()
setLevelRange(int, int)
public final void setMinLevel(int minLevel)
minLevel
- The minimum level index suitable for the subject of this
constraint.setLevelRange(int, int)
public final int getMaxLevel()
setLevelRange(int, int)
public final void setMaxLevel(int maxLevel)
maxLevel
- The maximum level index suitable for the subject of this
constraint.setLevelRange(int, int)
public final void setLevelRange(int minLevel, int maxLevel)
constraint1.setLevelRange(5, 7); constraint2.setLevelRange(5, IlvHierarchicalLayout.UNSPECIFIED); constraint3.setLevelRange(IlvHierarchicalLayout.UNSPECIFIED, 7);The first statement forces the node or node group to be level 5, 6, or 7. The second statement forces the node or node group to be in a level with index greater or equal to 5. The third statement forces the node or node group to be in a level with index smaller or equal to 7.
minLevel
- The lower bound of the level range, or IlvHierarchicalLayout.UNSPECIFIED
if no lower bound is needed.maxLevel
- The upper bound of the level range, or IlvHierarchicalLayout.UNSPECIFIED
if no upper bound is needed.getMinLevel()
,
getMaxLevel()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.