public class NodeLayoutDescriptor extends Object
HierarchicLayoutCore
during the various phases to provide the drawing details of the nodes
of the graph.
A NodeLayoutDescriptor
instance can be specified individually for single nodes using a IDataProvider
that returns a NodeLayoutDescriptor
instance for each node of the graph, or null
if no NodeLayoutDescriptor
is bound to an edge. The IDataProvider
is registered with the graph with key
HierarchicLayoutCore.NODE_LAYOUT_DESCRIPTOR_DPKEY
.
This class is designed as a class to allow future additions of new getter methods.
HierarchicLayoutCore.NODE_LAYOUT_DESCRIPTOR_DPKEY
,
EdgeLayoutDescriptor
Constructor and Description |
---|
NodeLayoutDescriptor()
Creates a new instance of a
NodeLayoutDescriptor with the default values. |
Modifier and Type | Method and Description |
---|---|
YPoint |
getGridReference()
Gets a reference point relative to the center of the node which will be placed on a grid coordinate.
|
double |
getLayerAlignment()
Gets the alignment of the
node of this NodeLayoutDescriptor instance
within its layer. |
double |
getMinimumDistance()
Gets the preferred minimum distance to obstacles.
|
double |
getMinimumLayerHeight()
Gets the minimum height of the layer to which this node is assigned.
|
NodeLabelMode |
getNodeLabelMode()
Gets the mode that determines how node labels are handled by the algorithm during the layout.
|
PortAssignmentMode |
getPortAssignment()
Gets the assignment strategy which distributes the ports along the node borders.
|
double |
getPortBorderGapRatio(int side)
Returns the port border gap ratio for the port distribution at a given side of the node.
|
void |
setGridReference(YPoint value)
Sets a reference point relative to the center of the node which will be placed on a grid coordinate.
|
void |
setLayerAlignment(double value)
Sets the alignment of the
node of this NodeLayoutDescriptor instance
within its layer. |
void |
setMinimumDistance(double value)
Sets the preferred minimum distance to obstacles.
|
void |
setMinimumLayerHeight(double value)
Sets the minimum height of the layer to which this node is assigned.
|
void |
setNodeLabelMode(NodeLabelMode value)
Sets the mode that determines how node labels are handled by the algorithm during the layout.
|
void |
setPortAssignment(PortAssignmentMode value)
Sets the assignment strategy which distributes the ports along the node borders.
|
void |
setPortBorderGapRatio(int side,
double ratio)
Specifies the port border gap ratio for the port distribution at a given side of the node.
|
void |
setPortBorderGapRatios(double value)
Sets the port border gap ratio for the port distribution on all sides of the node.
|
public NodeLayoutDescriptor()
NodeLayoutDescriptor
with the default values.public YPoint getGridReference()
grid
.YPoint.ORIGIN
. The reference point is YPoint.ORIGIN
and the center of the node is placed on the grid.setGridReference(YPoint)
public double getLayerAlignment()
node
of this NodeLayoutDescriptor
instance
within its layer.
0.0d
corresponds to top-alignment.0.5d
corresponds to center-alignment.1.0d
corresponds to bottom-alignment.
This value should be within [0,1]
interval.
IllegalArgumentException
- if the alignment is not within [0.0d .. 1.0d][0,1]
intervalsetLayerAlignment(double)
public double getMinimumDistance()
The minimum distance should be greater than 0
.
IllegalArgumentException
- if the minimum length is negativesetMinimumDistance(double)
public double getMinimumLayerHeight()
Values should be greater than 0
.
IllegalArgumentException
- if the minimum height is negativelayerAlignments
are present.setMinimumLayerHeight(double)
public NodeLabelMode getNodeLabelMode()
IllegalArgumentException
- if the constant is unknown.HierarchicLayout
is used for the layout, method NodeLabelConsiderationEnabled
should be set to true
. Otherwise, one has to assure that e.g., via an instance of
LabelLayoutTranslator
, the algorithm receives the appropriate information.NodeLabelMode.CONSIDER_FOR_DRAWING
. Node labels will be considered for node placement and routing, but not for
self-loops.HierarchicLayout.setNodeLabelConsiderationEnabled(boolean)
,
setNodeLabelMode(NodeLabelMode)
public PortAssignmentMode getPortAssignment()
PortAssignmentMode.DEFAULT
, PortAssignmentMode.ON_GRID
and PortAssignmentMode.ON_SUBGRID
are currently only supported in DefaultPortAllocator
. A custom
implementation of IPortAllocator
will have to handle these assignments
itself or will replace them with its own behavior.PortAssignmentMode.DEFAULT
. Ports are distributed evenly along the border of the node.setPortAssignment(PortAssignmentMode)
public double getPortBorderGapRatio(int side)
This ratio determines the gap between a corner of the node and the first assigned port.
The ratio should be greater than 0
.
A value of 0.0d
results in ports being placed directly on the corner of the node (if there is more than one
port).
A value of 0.5d
results in ports being distributed along the side of the node so that the distance between the
corner of the node and the first port is half as wide as the distance between two adjacent ports.
A value of Double.POSITIVE_INFINITY
results in all ports being centered at the side in one point.
side
- the zero-based clockwise side index for top-to-bottom layouts (i.e., top is 0)setPortBorderGapRatios(double)
,
setPortBorderGapRatio(int, double)
public void setGridReference(YPoint value)
grid
.YPoint.ORIGIN
. The reference point is YPoint.ORIGIN
and the center of the node is placed on the grid.value
- the reference point for grid placementgetGridReference()
public void setLayerAlignment(double value)
node
of this NodeLayoutDescriptor
instance
within its layer.
0.0d
corresponds to top-alignment.0.5d
corresponds to center-alignment.1.0d
corresponds to bottom-alignment.
This value should be within [0,1]
interval.
IllegalArgumentException
- if the alignment is not within [0.0d .. 1.0d]value
- a value from [0,1]
intervalgetLayerAlignment()
public void setMinimumDistance(double value)
The minimum distance should be greater than 0
.
IllegalArgumentException
- if the minimum length is negativevalue
- the minimum distance to obstaclesgetMinimumDistance()
public void setMinimumLayerHeight(double value)
Values should be greater than 0
.
IllegalArgumentException
- if the minimum height is negativelayerAlignments
are present.value
- a non-negative minimum heightgetMinimumLayerHeight()
public void setNodeLabelMode(NodeLabelMode value)
IllegalArgumentException
- if the constant is unknown.HierarchicLayout
is used for the layout, method NodeLabelConsiderationEnabled
should be set to true
. Otherwise, one has to assure that e.g., via an instance of
LabelLayoutTranslator
, the algorithm receives the appropriate information.NodeLabelMode.CONSIDER_FOR_DRAWING
. Node labels will be considered for node placement and routing, but not for
self-loops.value
- one of the predefined constantsHierarchicLayout.setNodeLabelConsiderationEnabled(boolean)
,
getNodeLabelMode()
public void setPortAssignment(PortAssignmentMode value)
PortAssignmentMode.DEFAULT
, PortAssignmentMode.ON_GRID
and PortAssignmentMode.ON_SUBGRID
are currently only supported in DefaultPortAllocator
. A custom
implementation of IPortAllocator
will have to handle these assignments
itself or will replace them with its own behavior.PortAssignmentMode.DEFAULT
. Ports are distributed evenly along the border of the node.value
- one of the predefined port assignment strategiesgetPortAssignment()
public void setPortBorderGapRatio(int side, double ratio)
This ratio determines the gap between a corner of the node and the first assigned port.
The ratio should be greater than 0
.
A value of 0.0d
results in ports being placed directly on the corner of the node (if there is more than one
port).
A value of 0.5d
results in ports being distributed along the side of the node so that the distance between the
corner of the node and the first port is half as wide as the distance between two adjacent ports.
A value of Double.POSITIVE_INFINITY
results in all ports being centered at the side in one point.
IllegalArgumentException
- if the given ratio is negativeside
- the zero-based clockwise side index for top-to-bottom layouts (i.e., top is 0)ratio
- the given ratiosetPortBorderGapRatios(double)
public void setPortBorderGapRatios(double value)
This ratio determines the gap between a corner of the node and the first assigned port.
The ratio should be greater than 0
.
A value of 0.0d
results in ports being placed directly on the corner of the node (if there is more than one
port).
A value of 0.5d
results in ports being distributed along the side of the node so that the distance between the
corner of the node and the first port is half as wide as the distance between two adjacent ports.
A value of Double.POSITIVE_INFINITY
results in all ports being centered at the side in one point.
IllegalArgumentException
- if the given ratio is negativevalue
- the given ratiosetPortBorderGapRatio(int, double)