public class SimplexNodePlacer extends Object implements INodePlacer
INodePlacer
implementation based on rank assignment
.
The drawer works with integer values and rounds double values to integers using sophisticated quantizing.
Constructor and Description |
---|
SimplexNodePlacer() |
Modifier and Type | Method and Description |
---|---|
void |
assignLayerCoordinates(LayoutGraph graph,
ILayoutDataProvider layoutDataProvider,
ILayers layers)
Assigns preliminary y-coordinates for each layer of a hierarchic layout.
|
protected void |
assignNodesToSublayer(NodeList layerNodes,
ILayoutDataProvider ldp,
LayoutGraph graph,
INodeMap lowerSublayer)
Assigns the nodes of a given layer to the corresponding upper/lower sublayer if
node compaction
is enabled. |
void |
assignSequenceCoordinates(LayoutGraph graph,
ILayoutDataProvider layoutDataProvider,
ILayers layers,
IDrawingDistanceCalculator drawingDistanceCalculator)
Determines the resulting x-coordinates of a hierarchic layout.
|
GroupCompactionPolicy |
getGroupCompactionStrategy()
Gets the strategy used for controlling the horizontal compactness of group nodes.
|
protected double |
getLayerAlignment(LayoutGraph graph,
ILayoutDataProvider ldp,
Node node,
int layerIndex,
double minLayerHeight)
Returns the alignment of the node with a specified layer.
|
long |
getMaximumDuration()
Gets the time limit (in milliseconds) set for the layout algorithm.
|
protected double |
getMinDistance(LayoutGraph graph,
ILayer layer,
Node predNode,
Node succ)
Specifies the minimum allowed distance between two nodes of the same given layer.
|
protected double |
getMinimumLayerHeight(LayoutGraph graph,
ILayoutDataProvider ldp,
ILayer layer)
Returns the minimum height of a given
layer . |
double |
getMinimumSublayerDistance()
Gets the minimum distance between the upper and lower sublayer.
|
double |
getSwimLaneCrossingWeight()
Gets the relative weight of edges crossing a swimlane relative to edges that stay in their lane.
|
boolean |
isBarycenterModeEnabled()
Gets whether or not a barycenter drawing mode should be used.
|
boolean |
isBendReduction()
Gets whether or not an optimization step should be applied that tries to further reduce the number of bends.
|
boolean |
isEdgeStraighteningEnabled()
Gets whether or not a postprocessing step should be applied to reduce the number of bends.
|
boolean |
isExactPlacement()
Gets whether or not the
SimplexNodePlacer enforces the placement of nodes at their exact current positions, even
if this violates minimum distance constraints. |
protected boolean |
isFixedNode(LayoutGraph graph,
ILayoutDataProvider provider,
Node node,
boolean inLayer)
Returns whether or not the given node should be treated as a node with fixed (given) coordinates.
|
boolean |
isFromSketchLayerAssignmentEnabled()
Gets whether or not the
SimplexNodePlacer should try to use the coordinates given from the current sketch for
the determination of the layer coordinates. |
boolean |
isHorizontalCompactionEnabled()
Gets whether or not the
SimplexNodePlacer tries to create a maximally compact horizontal layout at the cost of
more bends. |
boolean |
isLabelCompactionEnabled()
Gets whether or not the
SimplexNodePlacer places labels in a more compact style. |
boolean |
isLongSegmentBreakingEnabled()
Gets whether or not the
SimplexNodePlacer should break long edge segments in favor of a more compact layout. |
boolean |
isNodeCompaction()
Gets whether or not nodes should be placed in a more compact style with respect to layout width.
|
void |
setBarycenterModeEnabled(boolean value)
Sets whether or not a barycenter drawing mode should be used.
|
void |
setBendReduction(boolean value)
Sets whether or not an optimization step should be applied that tries to further reduce the number of bends.
|
void |
setEdgeStraighteningEnabled(boolean value)
Sets whether or not a postprocessing step should be applied to reduce the number of bends.
|
void |
setExactPlacement(boolean value)
Sets whether or not the
SimplexNodePlacer enforces the placement of nodes at their exact current positions, even
if this violates minimum distance constraints. |
void |
setFromSketchLayerAssignmentEnabled(boolean value)
Sets whether or not the
SimplexNodePlacer should try to use the coordinates given from the current sketch for
the determination of the layer coordinates. |
void |
setGroupCompactionStrategy(GroupCompactionPolicy value)
Sets the strategy used for controlling the horizontal compactness of group nodes.
|
void |
setHorizontalCompactionEnabled(boolean value)
Sets whether or not the
SimplexNodePlacer tries to create a maximally compact horizontal layout at the cost of
more bends. |
void |
setLabelCompactionEnabled(boolean value)
Sets whether or not the
SimplexNodePlacer places labels in a more compact style. |
void |
setLongSegmentBreakingEnabled(boolean value)
Sets whether or not the
SimplexNodePlacer should break long edge segments in favor of a more compact layout. |
void |
setMaximumDuration(long value)
Sets the time limit (in milliseconds) set for the layout algorithm.
|
void |
setMinimumSublayerDistance(double value)
Sets the minimum distance between the upper and lower sublayer.
|
void |
setNodeCompaction(boolean value)
Sets whether or not nodes should be placed in a more compact style with respect to layout width.
|
void |
setSwimLaneCrossingWeight(double value)
Sets the relative weight of edges crossing a swimlane relative to edges that stay in their lane.
|
public void assignLayerCoordinates(LayoutGraph graph, ILayoutDataProvider layoutDataProvider, ILayers layers)
INodePlacer
The distance between two layers will be adjusted later by the edge routing algorithm. This method is responsible for assigning the relative positions of the nodes within each layer.
assignLayerCoordinates
in interface INodePlacer
graph
- the input graphlayoutDataProvider
- the ILayoutDataProvider
containing information about the elementslayers
- the ILayers
instance that will be calculated by this methodprotected void assignNodesToSublayer(NodeList layerNodes, ILayoutDataProvider ldp, LayoutGraph graph, INodeMap lowerSublayer)
node compaction
is enabled.
Information about sublayers is given by a INodeMap
whose INodeMap.getBool(Object)
method has to return true
for each node that should be placed in the lower sublayer (values are set by this method).
layerNodes
- a list
of all @link y.layout.hierarchic.incremental.NodeData#TYPE_NORMAL normal nodes} of a layerldp
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instancesgraph
- the given graphlowerSublayer
- the INodeMap
holding sublayer informationsetNodeCompaction(boolean)
public void assignSequenceCoordinates(LayoutGraph graph, ILayoutDataProvider layoutDataProvider, ILayers layers, IDrawingDistanceCalculator drawingDistanceCalculator)
INodePlacer
The minimum distance between each pair of nodes of the graph is determined by a IDrawingDistanceCalculator
instance.
assignSequenceCoordinates
in interface INodePlacer
graph
- the input graphlayoutDataProvider
- the ILayoutDataProvider
containing information about the elementslayers
- the ILayers
instance that will be calculated by this methoddrawingDistanceCalculator
- the given IDrawingDistanceCalculator
instancepublic GroupCompactionPolicy getGroupCompactionStrategy()
GroupCompactionPolicy.NONE
. No group compaction is performed.setGroupCompactionStrategy(GroupCompactionPolicy)
protected double getLayerAlignment(LayoutGraph graph, ILayoutDataProvider ldp, Node node, int layerIndex, double minLayerHeight)
This callback method used by assignLayerCoordinates(LayoutGraph, ILayoutDataProvider, ILayers)
.
graph
- the input graphldp
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instancesnode
- the given nodelayerIndex
- the index of the layerminLayerHeight
- the minimum height of the layerpublic long getMaximumDuration()
Values have to be greater than or equal to 0
.
IllegalArgumentException
- if the maximum duration is negativeLong.MAX_VALUE
. The layout algorithm runs unrestricted.setMaximumDuration(long)
protected double getMinDistance(LayoutGraph graph, ILayer layer, Node predNode, Node succ)
This callback method is used by
assignSequenceCoordinates(LayoutGraph, ILayoutDataProvider, ILayers, IDrawingDistanceCalculator)
.
graph
- the graph that contains the nodeslayer
- the layer that contains the nodespredNode
- the node to the left of the other one, may be null
to indicate a border linesucc
- the node to the right of the other one, may be null
to indicate a border lineIDrawingDistanceCalculator
protected double getMinimumLayerHeight(LayoutGraph graph, ILayoutDataProvider ldp, ILayer layer)
layer
.
This callback method is used by assignLayerCoordinates(LayoutGraph, ILayoutDataProvider, ILayers)
.
graph
- the given graphldp
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instanceslayer
- the given ILayer
objectpublic double getMinimumSublayerDistance()
A too small distance value may prevent adjacent nodes from being placed in a stacked style (horizontally interleaving)
because the vertical distance between these nodes must be greater than or equal to the value specified by
MinimumDistance
.
Values should be greater than 0
.
IllegalArgumentException
- if minimum sublayer distance is negativeis enabled
.setNodeCompaction(boolean)
,
setMinimumSublayerDistance(double)
public double getSwimLaneCrossingWeight()
Higher values lead to more compact drawings but may cause additional bends.
Values should lie within [0,1]
interval.
IllegalArgumentException
- if the relative weight does not lie within [0,1][0,1]
setSwimLaneCrossingWeight(double)
public boolean isBarycenterModeEnabled()
If this mode is enabled the resulting drawing is likely to have more bends, but may be more symmetric.
false
. true
if a barycenter drawing mode is used, false
otherwisesetBarycenterModeEnabled(boolean)
public boolean isBendReduction()
MaximumDuration
) the number of bends is not reduced.true
. true
if the bend optimization step is applied, false
otherwisesetMaximumDuration(long)
,
setBendReduction(boolean)
public boolean isEdgeStraighteningEnabled()
Furthermore, enabling this option may violate some minimum distances specified by the user and the edge distribution is no longer uniform.
BarycenterModeEnabled
and NodeCompaction
are both disabled.false
. A postprocessing step to reduce the number of bends is not applied.true
if the number of bends is reduced, false
otherwisesetEdgeStraighteningEnabled(boolean)
public boolean isExactPlacement()
SimplexNodePlacer
enforces the placement of nodes at their exact current positions, even
if this violates minimum distance constraints.true
. true
if exact coordinates are enforced, false
otherwisesetExactPlacement(boolean)
protected boolean isFixedNode(LayoutGraph graph, ILayoutDataProvider provider, Node node, boolean inLayer)
This callback method is used by both assignLayerCoordinates(LayoutGraph, ILayoutDataProvider, ILayers)
and
assignSequenceCoordinates(LayoutGraph, ILayoutDataProvider, ILayers, IDrawingDistanceCalculator)
.
If inLayer
argument is true
, this method is called from within the assignLayerCoordinates(LayoutGraph, ILayoutDataProvider, ILayers)
method.
graph
- the given graphprovider
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instancesnode
- the given nodeinLayer
- true
if the layer coordinate of the node is queried, false
if the sequence coordinate is queriedtrue
if the node should be treated as fixed, false
otherwisepublic boolean isFromSketchLayerAssignmentEnabled()
SimplexNodePlacer
should try to use the coordinates given from the current sketch for
the determination of the layer coordinates.true
. true
if the current sketch is used, false
otherwisesetFromSketchLayerAssignmentEnabled(boolean)
public boolean isHorizontalCompactionEnabled()
SimplexNodePlacer
tries to create a maximally compact horizontal layout at the cost of
more bends.
For best results, LongSegmentBreakingEnabled
and LabelCompactionEnabled
should also be enabled.
false
. true
if a maximally compact horizontal layout is created, false
otherwisesetLabelCompactionEnabled(boolean)
,
setLongSegmentBreakingEnabled(boolean)
,
setHorizontalCompactionEnabled(boolean)
public boolean isLabelCompactionEnabled()
SimplexNodePlacer
places labels in a more compact style.
If this option is enabled the algorithm tries to place adjacent label elements in a stacked style, i.e., horizontally interleaving.
IDrawingDistanceCalculator
s, see
DrawingDistanceCalculator
.false
. true
if labels are placed compact, false
otherwisesetLabelCompactionEnabled(boolean)
public boolean isLongSegmentBreakingEnabled()
SimplexNodePlacer
should break long edge segments in favor of a more compact layout.false
. Long edges will not be broken.true
if long edges are broken, false
otherwisesetLongSegmentBreakingEnabled(boolean)
public boolean isNodeCompaction()
If enabled, the algorithm may place the nodes of a layer in a stacked style (horizontally interleaving), i.e., it splits the layer into an upper and lower sublayer and places adjacent nodes into different sublayers if this reduces the width of the layer.
IDrawingDistanceCalculator
s, see
DrawingDistanceCalculator
.false
. Nodes are not placed in a compact style.true
if nodes are placed in a compact style, false
otherwisesetMinimumSublayerDistance(double)
,
assignNodesToSublayer(NodeList, ILayoutDataProvider, LayoutGraph, INodeMap)
,
setNodeCompaction(boolean)
public void setBarycenterModeEnabled(boolean value)
If this mode is enabled the resulting drawing is likely to have more bends, but may be more symmetric.
false
. value
- true
if a barycenter drawing mode is used, false
otherwiseisBarycenterModeEnabled()
public void setBendReduction(boolean value)
MaximumDuration
) the number of bends is not reduced.true
. value
- true
if the bend optimization step is applied, false
otherwisesetMaximumDuration(long)
,
isBendReduction()
public void setEdgeStraighteningEnabled(boolean value)
Furthermore, enabling this option may violate some minimum distances specified by the user and the edge distribution is no longer uniform.
BarycenterModeEnabled
and NodeCompaction
are both disabled.false
. A postprocessing step to reduce the number of bends is not applied.value
- true
if the number of bends is reduced, false
otherwiseisEdgeStraighteningEnabled()
public void setExactPlacement(boolean value)
SimplexNodePlacer
enforces the placement of nodes at their exact current positions, even
if this violates minimum distance constraints.true
. value
- true
if exact coordinates are enforced, false
otherwiseisExactPlacement()
public void setFromSketchLayerAssignmentEnabled(boolean value)
SimplexNodePlacer
should try to use the coordinates given from the current sketch for
the determination of the layer coordinates.true
. value
- true
if the current sketch is used, false
otherwiseisFromSketchLayerAssignmentEnabled()
public void setGroupCompactionStrategy(GroupCompactionPolicy value)
GroupCompactionPolicy.NONE
. No group compaction is performed.value
- one of the predefined compaction strategiesgetGroupCompactionStrategy()
public void setHorizontalCompactionEnabled(boolean value)
SimplexNodePlacer
tries to create a maximally compact horizontal layout at the cost of
more bends.
For best results, LongSegmentBreakingEnabled
and LabelCompactionEnabled
should also be enabled.
false
. value
- true
if a maximally compact horizontal layout is created, false
otherwisesetLabelCompactionEnabled(boolean)
,
setLongSegmentBreakingEnabled(boolean)
,
isHorizontalCompactionEnabled()
public void setLabelCompactionEnabled(boolean value)
SimplexNodePlacer
places labels in a more compact style.
If this option is enabled the algorithm tries to place adjacent label elements in a stacked style, i.e., horizontally interleaving.
IDrawingDistanceCalculator
s, see
DrawingDistanceCalculator
.false
. value
- true
if labels are placed compact, false
otherwiseisLabelCompactionEnabled()
public void setLongSegmentBreakingEnabled(boolean value)
SimplexNodePlacer
should break long edge segments in favor of a more compact layout.false
. Long edges will not be broken.value
- true
if long edges are broken, false
otherwiseisLongSegmentBreakingEnabled()
public void setMaximumDuration(long value)
Values have to be greater than or equal to 0
.
IllegalArgumentException
- if the maximum duration is negativeLong.MAX_VALUE
. The layout algorithm runs unrestricted.value
- a non-negative value that specifies the time limitgetMaximumDuration()
public void setMinimumSublayerDistance(double value)
A too small distance value may prevent adjacent nodes from being placed in a stacked style (horizontally interleaving)
because the vertical distance between these nodes must be greater than or equal to the value specified by
MinimumDistance
.
Values should be greater than 0
.
IllegalArgumentException
- if minimum sublayer distance is negativeis enabled
.value
- the minimum distancesetNodeCompaction(boolean)
,
getMinimumSublayerDistance()
public void setNodeCompaction(boolean value)
If enabled, the algorithm may place the nodes of a layer in a stacked style (horizontally interleaving), i.e., it splits the layer into an upper and lower sublayer and places adjacent nodes into different sublayers if this reduces the width of the layer.
IDrawingDistanceCalculator
s, see
DrawingDistanceCalculator
.false
. Nodes are not placed in a compact style.value
- true
if nodes are placed in a compact style, false
otherwisesetMinimumSublayerDistance(double)
,
assignNodesToSublayer(NodeList, ILayoutDataProvider, LayoutGraph, INodeMap)
,
isNodeCompaction()
public void setSwimLaneCrossingWeight(double value)
Higher values lead to more compact drawings but may cause additional bends.
Values should lie within [0,1]
interval.
IllegalArgumentException
- if the relative weight does not lie within [0,1]value
- a double value from [0,1]
getSwimLaneCrossingWeight()