Search this API

y.layout.hierarchic.incremental
Class SimplexNodePlacer

java.lang.Object
  extended by y.layout.hierarchic.incremental.SimplexNodePlacer
All Implemented Interfaces:
NodePlacer

public class SimplexNodePlacer
extends Object
implements NodePlacer

NodePlacer implementation based on rank-assignment. The drawer works with integer values and rounds double values to integers using sophisticated quantizing.


Field Summary
static int GROUP_COMPACTION_MAX
          Compaction strategy specifier for use with setGroupCompactionStrategy(int).
static int GROUP_COMPACTION_NONE
          Compaction strategy specifier for use with setGroupCompactionStrategy(int).
 
Constructor Summary
SimplexNodePlacer()
           
 
Method Summary
 void assignLayerCoordinates(LayoutGraph graph, LayoutDataProvider layoutDataProvider, Layers layers)
          Invoked by HierarchicLayouter before the ports get assigned.
 void assignSequenceCoordinates(LayoutGraph graph, LayoutDataProvider layoutDataProvider, Layers layers, DrawingDistanceCalculator drawingDistanceCalculator)
          Invoked by HierarchicLayouter to determine the resulting x coordinates.
 int getGroupCompactionStrategy()
          Gets the strategy that is used to control the horizontal compactness of group nodes.
protected  double getLayerAlignment(LayoutGraph graph, LayoutDataProvider ldp, Node node, int layerIndex, double minLayerHeight)
          Callback method used by assignLayerCoordinates(LayoutGraph,LayoutDataProvider,Layers) to determine the alignment of the node inside the layer
 long getMaximalDuration()
          Returns the time limit (in milliseconds) set for the algorithm.
protected  double getMinDistance(LayoutGraph graph, Layer layer, Node predNode, Node succ)
          Determines the minimum allowed distance between two nodes in a given layer
protected  double getMinimumLayerHeight(LayoutGraph graph, LayoutDataProvider ldp, Layer layer)
          Callback method used by assignLayerCoordinates(LayoutGraph,LayoutDataProvider,Layers) to determine the minimum height of a layer.
 double getSwimLaneCrossingWeight()
          Returns the relative weight of edges crossing a swim lane relative to edges that stay in their lane.
 boolean isBaryCenterModeEnabled()
          Returns whether or not to use the barycenter drawing mode.
 boolean isBendReductionEnabled()
          Returns whether or not an optimization step should be applied that tries to further reduce the number of bends.
 boolean isBreakLongSegmentsEnabled()
          Returns whether this instance may break long edge segments in favor of a more compact layout.
 boolean isEdgeStraighteningOptimizationEnabled()
          Returns whether a postprocessing step should be applied that tries to remove some bends.
 boolean isExactPlacementEnforced()
          Returns whether this instance should enforce the placement of nodes at their exact current position, even if this violates minimum distance constraints.
protected  boolean isFixedNode(LayoutGraph graph, LayoutDataProvider provider, Node node, boolean inLayer)
          Callback used by both assignLayerCoordinates(y.layout.LayoutGraph,LayoutDataProvider,Layers) and assignSequenceCoordinates(y.layout.LayoutGraph,LayoutDataProvider,Layers,DrawingDistanceCalculator) to determine whether the given node should be treated as a node with fixed (given) coordinates.
 boolean isFromSketchLayerAssignment()
          Returns whether this instance tries to use the coordinates given from the current sketch for the determination of the layer coordinates.
 boolean isHorizontalCompactionEnabled()
          Returns whether this instance tries to create a maximally compact horizontal layout at the cost of more bends.
 void setBaryCenterModeEnabled(boolean enabled)
          Specifies whether or not to use the barycenter drawing mode.
 void setBendReductionEnabled(boolean bendReductionEnabled)
          Specifies whether or not an optimization step should be applied that tries to further reduce the number of bends.
 void setBreakLongSegmentsEnabled(boolean breakLongSegmentsEnabled)
          Determines whether this instance may break long edge segments in favor of a more compact layout.
 void setEdgeStraighteningOptimizationEnabled(boolean edgeStraighteningOptimizationEnabled)
          Whether or not a postprocessing step should be applied that tries to remove some bends.
 void setExactPlacementEnforced(boolean exactPlacementEnforced)
          Determines whether this instance enforces the placement of nodes at their exact current position, even if this violates minimum distance constraints.
 void setFromSketchLayerAssignment(boolean fromSketchLayerAssignment)
          Sets whether this instance should try to use the coordinates given from the current sketch for the determination of the layer coordinates.
 void setGroupCompactionStrategy(int groupCompactionStrategy)
          Sets the strategy that is used to control the horizontal compactness of group nodes.
 void setHorizontalCompactionEnabled(boolean horizontalCompactionEnabled)
          Determines whether this instance tries to create a maximally compact horizontal layout at the cost of more bends.
 void setMaximalDuration(long maximalDuration)
          Sets a preferred time limit (in milliseconds) for the algorithm.
 void setSwimLaneCrossingWeight(double weight)
          Sets the relative weight of edges crossing a swim lane relative to edges that stay in their lane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_COMPACTION_NONE

public static final int GROUP_COMPACTION_NONE
Compaction strategy specifier for use with setGroupCompactionStrategy(int). This specifies no horizontal group compaction, i.e. group node contents will occupy nearly the same horizontal positions as when not grouped at all.

See Also:
Constant Field Values

GROUP_COMPACTION_MAX

public static final int GROUP_COMPACTION_MAX
Compaction strategy specifier for use with setGroupCompactionStrategy(int). This specifies maximal horizontal group compaction, i.e. the node placer will try to minimize the horizontally occupied space for a group node.

See Also:
Constant Field Values
Constructor Detail

SimplexNodePlacer

public SimplexNodePlacer()
Method Detail

isBendReductionEnabled

public boolean isBendReductionEnabled()
Returns whether or not an optimization step should be applied that tries to further reduce the number of bends.

Returns:
true if the bend optimization step is enabled.
See Also:
setBendReductionEnabled(boolean)

setBendReductionEnabled

public void setBendReductionEnabled(boolean bendReductionEnabled)
Specifies whether or not an optimization step should be applied that tries to further reduce the number of bends. By default this option is enabled. Note: using this option may increase runtime. If the runtime exceeds the maximal duration (see setMaximalDuration(long)) the number of bends is not reduced.

Parameters:
bendReductionEnabled - whether or not the bend optimization step should be applied.
See Also:
setMaximalDuration(long)

isHorizontalCompactionEnabled

public boolean isHorizontalCompactionEnabled()
Returns whether this instance tries to create a maximally compact horizontal layout at the cost of more bends.

Returns:
whether to create a maximally compact horizontal layout
See Also:
setHorizontalCompactionEnabled(boolean)

setHorizontalCompactionEnabled

public void setHorizontalCompactionEnabled(boolean horizontalCompactionEnabled)
Determines whether this instance tries to create a maximally compact horizontal layout at the cost of more bends.

For best results, setBreakLongSegmentsEnabled(boolean) should also be enabled.

Parameters:
horizontalCompactionEnabled - to create a maximally compact horizontal layout
See Also:
isHorizontalCompactionEnabled()

isEdgeStraighteningOptimizationEnabled

public boolean isEdgeStraighteningOptimizationEnabled()
Returns whether a postprocessing step should be applied that tries to remove some bends.

Returns:
true if the postprocessing step should be applied.

setEdgeStraighteningOptimizationEnabled

public void setEdgeStraighteningOptimizationEnabled(boolean edgeStraighteningOptimizationEnabled)
Whether or not a postprocessing step should be applied that tries to remove some bends. Note that enabling this option may violate some minimum distances specified by the user. Furthermore, the edge distribution is no longer uniform.

The default is false.

Parameters:
edgeStraighteningOptimizationEnabled - whether the postprocessing step should be applied.

getGroupCompactionStrategy

public int getGroupCompactionStrategy()
Gets the strategy that is used to control the horizontal compactness of group nodes.

Returns:
One of GROUP_COMPACTION_NONE or GROUP_COMPACTION_MAX.
See Also:
GROUP_COMPACTION_MAX, GROUP_COMPACTION_NONE, setGroupCompactionStrategy(int)

setGroupCompactionStrategy

public void setGroupCompactionStrategy(int groupCompactionStrategy)
Sets the strategy that is used to control the horizontal compactness of group nodes.

Parameters:
groupCompactionStrategy - One of GROUP_COMPACTION_NONE or GROUP_COMPACTION_MAX.
See Also:
GROUP_COMPACTION_MAX, GROUP_COMPACTION_NONE, getGroupCompactionStrategy()

isExactPlacementEnforced

public boolean isExactPlacementEnforced()
Returns whether this instance should enforce the placement of nodes at their exact current position, even if this violates minimum distance constraints.

The default is true.

See Also:
setExactPlacementEnforced(boolean)

setExactPlacementEnforced

public void setExactPlacementEnforced(boolean exactPlacementEnforced)
Determines whether this instance enforces the placement of nodes at their exact current position, even if this violates minimum distance constraints.

The default is true.

Parameters:
exactPlacementEnforced - whether to enforce exact coordinates

isFromSketchLayerAssignment

public boolean isFromSketchLayerAssignment()
Returns whether this instance tries to use the coordinates given from the current sketch for the determination of the layer coordinates.

Returns:
whether to use the current sketch

setFromSketchLayerAssignment

public void setFromSketchLayerAssignment(boolean fromSketchLayerAssignment)
Sets whether this instance should try to use the coordinates given from the current sketch for the determination of the layer coordinates.

Parameters:
fromSketchLayerAssignment - whether to use the current sketch

getMaximalDuration

public long getMaximalDuration()
Returns the time limit (in milliseconds) set for the algorithm.

Returns:
the time limit.
See Also:
setMaximalDuration(long)

setMaximalDuration

public void setMaximalDuration(long maximalDuration)
Sets a preferred time limit (in milliseconds) for the algorithm. Note that restricting the maximal duration may result in a worse layout quality. Furthermore, the real runtime may exceed the maximal duration since the algorithm still have to find a valid solution.

Parameters:
maximalDuration - the time limit.
See Also:
getMaximalDuration()

setSwimLaneCrossingWeight

public void setSwimLaneCrossingWeight(double weight)
Sets the relative weight of edges crossing a swim lane relative to edges that stay in their lane.

A value of 0.0d will effectively make the algorithm ignore edges crossing a swim lane border.

Defaults to 0.0d.

Parameters:
weight - the relative weight of an edge crossing a swim lane border [0.0d .. 1.0d]

getSwimLaneCrossingWeight

public double getSwimLaneCrossingWeight()
Returns the relative weight of edges crossing a swim lane relative to edges that stay in their lane.

A value of 0.0d will effectively make the algorithm ignore edges crossing a swim lane border.

Defaults to 0.0d.

Returns:
the relative weight of an edge crossing a swim lane border [0.0d .. 1.0d]

setBaryCenterModeEnabled

public void setBaryCenterModeEnabled(boolean enabled)
Specifies whether or not to use the barycenter drawing mode. If this mode is enabled the resulting drawing is likely to have more bends but may be more symmetric.

By default this mode is turned off.

Parameters:
enabled - whether to enable this mode.

isBaryCenterModeEnabled

public boolean isBaryCenterModeEnabled()
Returns whether or not to use the barycenter drawing mode. If this mode is enabled the resulting drawing is likely to have more bends but may be more symmetric.

By default this mode is turned off.

Returns:
whether the mode is enabled.

assignLayerCoordinates

public void assignLayerCoordinates(LayoutGraph graph,
                                   LayoutDataProvider layoutDataProvider,
                                   Layers layers)
Description copied from interface: NodePlacer
Invoked by HierarchicLayouter before the ports get assigned. This method is used to assign preliminary y coordinates for each layer. 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.

Specified by:
assignLayerCoordinates in interface NodePlacer
Parameters:
graph - the graph that contains the elements
layoutDataProvider - the LayoutDataProvider that contains information about the elements
layers - the Layers that shall be calculated by this method

isFixedNode

protected boolean isFixedNode(LayoutGraph graph,
                              LayoutDataProvider provider,
                              Node node,
                              boolean inLayer)
Callback used by both assignLayerCoordinates(y.layout.LayoutGraph,LayoutDataProvider,Layers) and assignSequenceCoordinates(y.layout.LayoutGraph,LayoutDataProvider,Layers,DrawingDistanceCalculator) to determine whether the given node should be treated as a node with fixed (given) coordinates.

Parameters:
graph - the graph that contains the node
provider - the current LayoutDataProvider
node - the node
inLayer - whether the nodes' layer coordinate is queried or the sequence coordinate. Iff inLayer is true this method is called from within the assignLayerCoordinates(y.layout.LayoutGraph,LayoutDataProvider,Layers) method
Returns:
whether the node should be treated as fixed

getMinimumLayerHeight

protected double getMinimumLayerHeight(LayoutGraph graph,
                                       LayoutDataProvider ldp,
                                       Layer layer)
Callback method used by assignLayerCoordinates(LayoutGraph,LayoutDataProvider,Layers) to determine the minimum height of a layer.


getLayerAlignment

protected double getLayerAlignment(LayoutGraph graph,
                                   LayoutDataProvider ldp,
                                   Node node,
                                   int layerIndex,
                                   double minLayerHeight)
Callback method used by assignLayerCoordinates(LayoutGraph,LayoutDataProvider,Layers) to determine the alignment of the node inside the layer


assignSequenceCoordinates

public void assignSequenceCoordinates(LayoutGraph graph,
                                      LayoutDataProvider layoutDataProvider,
                                      Layers layers,
                                      DrawingDistanceCalculator drawingDistanceCalculator)
Description copied from interface: NodePlacer
Invoked by HierarchicLayouter to determine the resulting x coordinates. This method is invoked after all ports have been assigned their final relative coordinates and nodes have been given relative coordinates within each layer.

Specified by:
assignSequenceCoordinates in interface NodePlacer
Parameters:
graph - the graph that contains the elements
layoutDataProvider - the LayoutDataProvider that contains information about the elements
layers - the Layers that shall be calculated by this method
drawingDistanceCalculator - an instance that can be queried to determine the minimum distance between each pair of nodes in the graph

getMinDistance

protected double getMinDistance(LayoutGraph graph,
                                Layer layer,
                                Node predNode,
                                Node succ)
Determines the minimum allowed distance between two nodes in a given layer

Parameters:
graph - the graph that contains the nodes
layer - the layer that contains the nodes
predNode - the node to the left of the other one, may be null to indicate a border line
succ - the node to the right of the other one, may be null to indicate a border line
Returns:
the minimum distance allowed between those two nodes ( >=0 )
See Also:
DrawingDistanceCalculator

isBreakLongSegmentsEnabled

public boolean isBreakLongSegmentsEnabled()
Returns whether this instance may break long edge segments in favor of a more compact layout.

Returns:
whether to break long segments
See Also:
setBreakLongSegmentsEnabled(boolean)

setBreakLongSegmentsEnabled

public void setBreakLongSegmentsEnabled(boolean breakLongSegmentsEnabled)
Determines whether this instance may break long edge segments in favor of a more compact layout.

Parameters:
breakLongSegmentsEnabled - whether to break long segments
See Also:
isBreakLongSegmentsEnabled()

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.