Search this API

y.layout.hierarchic.incremental
Class DefaultDrawingDistanceCalculator

java.lang.Object
  extended by y.layout.hierarchic.incremental.DefaultDrawingDistanceCalculator
All Implemented Interfaces:
DrawingDistanceCalculator

public class DefaultDrawingDistanceCalculator
extends Object
implements DrawingDistanceCalculator

A default DrawingDistanceCalculator implementation that is used by HierarchicLayouter to configure the NodePlacer.


Constructor Summary
DefaultDrawingDistanceCalculator()
          Creates a new instance of DefaultDrawingDistanceCalculator with default settings.
 
Method Summary
 void dispose(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
          Called to dispose internal data structures.
 double getEdge2EdgeDistance()
          Returns the minimum distance between two edges.
 double getMinDistance(LayoutGraph graph, Layer layer, LayoutDataProvider ldp, Node left, Node right)
          Main interface method.
 double getNode2EdgeDistance()
          Returns the minimum distance between a node and an (non-adjacent) edge.
 double getNode2NodeDistance()
          Returns the minimum distance between two nodes.
 void initialize(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
          Called to initialize internal data structures.
 boolean isAdaptiveMinEdgeDistanceEnabled()
          Returns whether or not an adaptive minimum edge distance should be used.
 boolean isSwimLaneDistanceOptimizationEnabled()
          Returns whether the optimized minimum distance calculation for swim lane layouts is enabled.
 void setAdaptiveMinEdgeDistanceEnabled(boolean adaptiveMinEdgeDistanceEnabled)
          Specifies whether or not an adaptive minimum edge distance should be used.
 void setEdge2EdgeDistance(double edge2EdgeDistance)
          Sets the minimum distance between two edges.
 void setNode2EdgeDistance(double node2EdgeDistance)
          Sets the minimum distance between a node and an (non-adjacent) edge.
 void setNode2NodeDistance(double node2NodeDistance)
          Sets the minimum distance between two nodes.
 void setSwimLaneDistanceOptimizationEnabled(boolean enabled)
          Specifies whether or not to use an optimized minimum distance calculation for swim lane layouts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDrawingDistanceCalculator

public DefaultDrawingDistanceCalculator()
Creates a new instance of DefaultDrawingDistanceCalculator with default settings.

Method Detail

initialize

public void initialize(LayoutGraph graph,
                       Layers layers,
                       LayoutDataProvider ldp)
Description copied from interface: DrawingDistanceCalculator
Called to initialize internal data structures. Implementations may cache lengthy calculations in the initialization phase. It is guaranteed that the graph will not be changed during subsequent calls to DrawingDistanceCalculator.getMinDistance(LayoutGraph, Layer, LayoutDataProvider, Node, Node).

Specified by:
initialize in interface DrawingDistanceCalculator
Parameters:
graph - the graph that contains all elements that are used during the node placement
layers - the Layers object that will be used during subsequent calls
ldp - the LayoutDataProvider that can be used to query information
See Also:
DrawingDistanceCalculator.dispose(LayoutGraph, Layers, LayoutDataProvider)

dispose

public void dispose(LayoutGraph graph,
                    Layers layers,
                    LayoutDataProvider ldp)
Description copied from interface: DrawingDistanceCalculator
Called to dispose internal data structures. Implementations should release internally held data structures here.

Specified by:
dispose in interface DrawingDistanceCalculator
Parameters:
graph - the graph that contains all elements that are used during the node placement
layers - the Layers object that was used
ldp - the LayoutDataProvider that was used to query information
See Also:
DrawingDistanceCalculator.initialize(LayoutGraph, Layers, LayoutDataProvider)

isAdaptiveMinEdgeDistanceEnabled

public boolean isAdaptiveMinEdgeDistanceEnabled()
Returns whether or not an adaptive minimum edge distance should be used. If this option is enabled the minimum distance between two adjacent edges is the minimum of the set minimum edge distance and the distance of the edges' source/target points.

See Also:
setAdaptiveMinEdgeDistanceEnabled(boolean)

setAdaptiveMinEdgeDistanceEnabled

public void setAdaptiveMinEdgeDistanceEnabled(boolean adaptiveMinEdgeDistanceEnabled)
Specifies whether or not an adaptive minimum edge distance should be used. If this option is enabled the minimum distance between two adjacent edges is the minimum of the set minimum edge distance and the distance of the edges' source/target points. By default this option is enabled.

Parameters:
adaptiveMinEdgeDistanceEnabled - whether or not an adaptive minimum edge distance should be used.

getMinDistance

public double getMinDistance(LayoutGraph graph,
                             Layer layer,
                             LayoutDataProvider ldp,
                             Node left,
                             Node right)
Description copied from interface: DrawingDistanceCalculator
Main interface method. Queried by NodePlacer instances to determine the minimum distances between elements in one layer. Note that either of the Node arguments may be null. In that case only the border of the non-null node should be considered.

Specified by:
getMinDistance in interface DrawingDistanceCalculator
Parameters:
graph - the graph that contains the nodes
layer - the layer object that contains the nodes
ldp - the LayoutDataProvider that can be used to query information
left - the left one of the two nodes whose minimum distance is to be determined or null if only the left border of the right node is of interest.
right - the right one of the two nodes whose minimum distance is to be determined or null if only the right border of the left node is of interest.

getNode2NodeDistance

public double getNode2NodeDistance()
Returns the minimum distance between two nodes. Default is 30.0d.

Returns:
the minimum distance

setNode2NodeDistance

public void setNode2NodeDistance(double node2NodeDistance)
Sets the minimum distance between two nodes.

Parameters:
node2NodeDistance - the new minimum distance.

getNode2EdgeDistance

public double getNode2EdgeDistance()
Returns the minimum distance between a node and an (non-adjacent) edge. Default is 15.0d.

Returns:
the minimum distance

setNode2EdgeDistance

public void setNode2EdgeDistance(double node2EdgeDistance)
Sets the minimum distance between a node and an (non-adjacent) edge.

Parameters:
node2EdgeDistance - the new minimum distance

getEdge2EdgeDistance

public double getEdge2EdgeDistance()
Returns the minimum distance between two edges. Default is 20.0d.

Returns:
the minimum distance

setEdge2EdgeDistance

public void setEdge2EdgeDistance(double edge2EdgeDistance)
Sets the minimum distance between two edges.

Parameters:
edge2EdgeDistance - the new minimum distance

setSwimLaneDistanceOptimizationEnabled

public void setSwimLaneDistanceOptimizationEnabled(boolean enabled)
Specifies whether or not to use an optimized minimum distance calculation for swim lane layouts. If set to true this instance will report 0.0d as the minimum distance between two nodes if they belong to different swim lanes. This avoids unwanted feedback between different swim lanes during node placement.

Parameters:
enabled - whether to enable the modified distance calculation for swim lane layouts.

isSwimLaneDistanceOptimizationEnabled

public boolean isSwimLaneDistanceOptimizationEnabled()
Returns whether the optimized minimum distance calculation for swim lane layouts is enabled. If set to true this instance will report 0.0d as the minimum distance between two nodes if they belong to different swim lanes. This avoids unwanted feedback between different swim lanes during node placement.

Returns:
whether the modified distance calculation for swim lane layouts is being used

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