public class IlvExtremityConstraint extends IlvHierarchicalConstraint
IlvExtremityConstraint
is a constraint that
forces the node to be placed at an extremal level, or at one of the
extremal sides of a level.
Nodes are organized in horizontal or vertical levels numbered from 0 to "n". The first level is the north pole level, and the last level is the south pole level. 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. North is at the top and south is at the bottom of the drawing in this case. 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. North is at the left side and south is at the right side of the drawing in this case.
A north extremity constraint causes a node to be placed at level 0 (that is, at the top if the flow direction is top to bottom, or at the left if the flow direction is left to right), and all other nodes to be placed at a level with higher index. A south extremity constraint causes a node to be placed at the level with highest index (that is, at the bottom if the flow direction is top to bottom, or at the right if the flow direction is left to right), and all other nodes to be placed at a level with lower index. If for instance a south extremity constraint is specified for several nodes, these nodes are all placed at the same level with highest index.
Within each level, the nodes are placed sequentially from west to east at relative positions numbered from 0 to "m". 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. West is at the left side and east is at the right side of the drawing in this case. If the link flow direction is from left to right, the node with position index 0 is placed bottommost within its level, and the nodes with higher position indexes are placed above. West is at the bottom side and east is at the top side of the drawing in this case.
A west extremity constraint causes a node to be placed at position index 0, and an east extremity constraint causes a node to be placed at the highest position index of its level. Note that the east and west extremity constraint are local to each level: an node with east extremity constraint is not placed at the eastmost corner of the entire drawing, but only eastmost relative to its own level.
Of course, you should not specify level indexes for nodes additional to north or south extremity constraints, and you should not specify position indexes for nodes additional to east or west extremity constraints.
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.
In recursive layout mode (see IlvHierarchicalLayout.setRecursiveLayoutMode(boolean)
), the constraint must be
installed at the layout instance that is attached to the subgraph the
constrained node belongs to.
IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
,
IlvHierarchicalLayout.setIncrementalMode(boolean)
,
IlvHierarchicalLayout.markForIncremental(Object)
,
IlvHierarchicalLayout.setSpecNodeLevelIndex(Object, int)
,
IlvHierarchicalLayout.setSpecNodePositionIndex(Object, int)
,
IlvHierarchicalLayout.NORTH
,
IlvHierarchicalLayout.SOUTH
,
IlvHierarchicalLayout.WEST
,
IlvHierarchicalLayout.EAST
,
Serialized FormConstructor and Description |
---|
IlvExtremityConstraint(IlvExtremityConstraint source)
Creates a new
IlvExtremityConstraint by copying an
existing one. |
IlvExtremityConstraint(IlvInputStream stream)
Creates a new
IlvExtremityConstraint from an
IlvInputStream . |
IlvExtremityConstraint(Object nodeArg,
int sideArg)
Creates a new
IlvExtremityConstraint . |
Modifier and Type | Method and Description |
---|---|
IlvHierarchicalConstraint |
copy()
Copies the constraint.
|
Object |
getNode()
Returns the node of this constraint.
|
int |
getSide()
Returns the side at which extremity the node should be placed.
|
void |
setSide(int side)
Sets the side at which extremity the node should be placed.
|
void |
write(IlvOutputStream stream)
Writes the constraint to the output stream.
|
getPriority, setPriority
public IlvExtremityConstraint(Object nodeArg, int sideArg)
IlvExtremityConstraint
.
The following examples show how to use the constraint:
layout.addConstraint( new IlvExtremityConstraint(node1, IlvHierarchicalLayout.NORTH)); layout.addConstraint( new IlvExtremityConstraint(node2, IlvHierarchicalLayout.SOUTH)); layout.addConstraint( new IlvExtremityConstraint(node3, IlvHierarchicalLayout.WEST)); layout.addConstraint( new IlvExtremityConstraint(node4, IlvHierarchicalLayout.EAST));This forces node1 to be placed in the level with lowest index, and node2 to be placed in the level with highest index. This means the node1 is placed in level 0, and the node2 is placed in a level with higher index than all other nodes. This furthermore forces node3 to be placed first within its level and node4 to be placed last within its level.
For instance, if the link flow direction is from top to bottom, this means that the node1 is placed topmost, the node2 is placed bottommost, furthermore the node3 is placed leftmost within its level, and the node4 is placed rightmost within its level.
nodeArg
- A node that should be placed at the extremity.sideArg
- The compass side that specifies the extremity:
IlvHierarchicalLayout.NORTH
for the first level, IlvHierarchicalLayout.SOUTH
for the last level, IlvHierarchicalLayout.WEST
for the first position within a level, IlvHierarchicalLayout.EAST
for the last position within a level. setSide(int)
,
IlvHierarchicalLayout.addConstraint(IlvHierarchicalConstraint)
public IlvExtremityConstraint(IlvExtremityConstraint source)
IlvExtremityConstraint
by copying an
existing one.
source
- The origin of the copy.public IlvExtremityConstraint(IlvInputStream stream) throws IOException, IlvReadFileException
IlvExtremityConstraint
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 getNode()
public final int getSide()
setSide(int)
public final void setSide(int side)
Examples:
constraint1.setSide(IlvHierarchicalLayout.NORTH); constraint2.setSide(IlvHierarchicalLayout.SOUTH); constraint3.setSide(IlvHierarchicalLayout.WEST); constraint4.setSide(IlvHierarchicalLayout.EAST);The first statement forces the node of constraint1 to be placed in the level with lowest index. The second statement forces the node of constraint2 to be placed in the level with highest index. The third statement forces the node of constraint3 to be placed first within its level. The fourth statement forces the node of constraint4 to be places last within its level.
For instance, if the link flow direction is from top to bottom, this means that the node of constraint1 is placed topmost, the node of constraint2 is placed bottommost, furthermore the node of constraint3 is placed leftmost within its level, and the node of constraint4 is placed rightmost within its level.
side
- The compass side that specifies the extremity:
IlvHierarchicalLayout.NORTH
for the first level, IlvHierarchicalLayout.SOUTH
for the last level, IlvHierarchicalLayout.WEST
for the first position within
a level, IlvHierarchicalLayout.EAST
for the last position within a
level. getSide()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.