Search this API

y.layout.router.polyline
Class PolylineLayoutStage

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.router.polyline.PolylineLayoutStage
All Implemented Interfaces:
Layouter, LayoutStage

public class PolylineLayoutStage
extends AbstractLayoutStage

Adds polyline segment to the orthogonal edge paths of a graph. The current implementation only adds octilinear segments to all orthogonal edges (non-orthogonal edges are completely ignored). Between two succeeding vertical and horizontal segments, an octilinear segment is added whose length can be influenced by the maximum non orthogonal segment ratio and the preferred polyline segment length. The new octilinear segments keep a minimum distance between the edges and all nodes in the graph if possible.


Field Summary
static byte ROUTE_ALL_EDGES
          Sphere of action specifier.
static byte ROUTE_EDGES_AT_SELECTED_NODES
          Sphere of action specifier.
static byte ROUTE_SELECTED_EDGES
          Sphere of action specifier.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
PolylineLayoutStage()
           
PolylineLayoutStage(Layouter coreLayouter)
          Initializes this layout stage with the given core layouter.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns true iff the given graph can be laid out by this algorithm.
 void doLayout(LayoutGraph graph)
          Main layout routine that assigns new layout information to the given graph.
 double getMaximumNonOrthogonalSegmentRatio()
          Returns the maximum segment length ratio at each end of an orthogonal segment that may get converted into a (non-orthogonal) polyline segment.
 double getMinimalNodeToEdgeDistance()
          Specifies the minimal distance between edges and node bounds.
 double getPreferredPolylineSegmentLength()
          Returns the preferred segment length for (non-orthogonal) polyline segments.
 Object getSelectedEdgesDpKey()
          Returns the data provider key used to look up the selected state of the edges of the graph to be laid out.
 Object getSelectedNodesDpKey()
          Returns the data provider key used to look up the selected state of the nodes of the graph to be laid out.
 byte getSphereOfAction()
          Determines the (sub-)set of edges to be routed polylinear.
 void setMaximumNonOrthogonalSegmentRatio(double ratio)
          Sets the maximum segment length ratio at each end of an orthogonal segment that may get converted into a (non-orthogonal) polyline segment.
 void setMinimalNodeToEdgeDistance(double distance)
          Specifies the minimal distance between edges and node bounds.
 void setPreferredPolylineSegmentLength(double length)
          Sets the preferred segment length for (non-orthogonal) polyline segments.
 void setSelectedEdgesDpKey(Object selectedEdgesDpKey)
          Specifies the data provider key used to look up the selected state of the edges of the graph to be laid out.
 void setSelectedNodesDpKey(Object key)
          Specifies the data provider key used to look up the selected state of the nodes of the graph to be laid out.
 void setSphereOfAction(byte sphere)
          Specifies the (sub-)set of edges to be routed polylinear.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROUTE_ALL_EDGES

public static final byte ROUTE_ALL_EDGES
Sphere of action specifier. Route all edges of the input graph.

See Also:
setSphereOfAction(byte), Constant Field Values

ROUTE_SELECTED_EDGES

public static final byte ROUTE_SELECTED_EDGES
Sphere of action specifier. Route only selected edges of the input graph. The selection state of an edge is determined by a boolean value returned by the data provider associated with the data provider key getSelectedEdgesDpKey().

See Also:
Graph.addDataProvider(Object, y.base.DataProvider), setSphereOfAction(byte), Constant Field Values

ROUTE_EDGES_AT_SELECTED_NODES

public static final byte ROUTE_EDGES_AT_SELECTED_NODES
Sphere of action specifier. Route only edges connected to selected nodes. The selection state of a node is determined by a boolean value returned by the data provider associated with the data provider key getSelectedNodesDpKey().

See Also:
Graph.addDataProvider(Object, y.base.DataProvider), setSphereOfAction(byte), Constant Field Values
Constructor Detail

PolylineLayoutStage

public PolylineLayoutStage(Layouter coreLayouter)
Initializes this layout stage with the given core layouter.

Parameters:
coreLayouter - The core layouter to wrap with this layout stage.

PolylineLayoutStage

public PolylineLayoutStage()
Method Detail

getSelectedNodesDpKey

public Object getSelectedNodesDpKey()
Returns the data provider key used to look up the selected state of the nodes of the graph to be laid out. By default, Layouter.SELECTED_NODES is used.

If the sphere of action is set to ROUTE_EDGES_AT_SELECTED_NODES, only edges of selected nodes are routed while all other edges are considered to have fixed routes.

Returns:
The data provider key for the node selection.
See Also:
setSphereOfAction(byte), setSelectedNodesDpKey(Object)

setSelectedNodesDpKey

public void setSelectedNodesDpKey(Object key)
Specifies the data provider key used to look up the selected state of the nodes of the graph to be laid out. By default, Layouter.SELECTED_NODES is used.

If the sphere of action is set to ROUTE_EDGES_AT_SELECTED_NODES, only edges of selected nodes are routed while all other edges are considered to have fixed routes.

Throws:
IllegalArgumentException - if the specified key is null.
Parameters:
key - The data provider key for the node selection.
See Also:
getSphereOfAction(), getSelectedNodesDpKey()

getSelectedEdgesDpKey

public Object getSelectedEdgesDpKey()
Returns the data provider key used to look up the selected state of the edges of the graph to be laid out. By default, Layouter.SELECTED_EDGES is used.

If the sphere of action is set to ROUTE_SELECTED_EDGES, only the selected keys are routed while all other edges are considered to have fixed routes.

Returns:
The data provider key for the edge selection.
See Also:
getSphereOfAction(), setSelectedEdgesDpKey(Object)

setSelectedEdgesDpKey

public void setSelectedEdgesDpKey(Object selectedEdgesDpKey)
Specifies the data provider key used to look up the selected state of the edges of the graph to be laid out. By default, Layouter.SELECTED_EDGES is used.

If the sphere of action is set to ROUTE_SELECTED_EDGES, only the selected keys are routed while all other edges are considered to have fixed routes.

Throws:
IllegalArgumentException - if the specified key is null.
Parameters:
selectedEdgesDpKey - The data provider key for the edge selection.
See Also:
getSphereOfAction(), getSelectedEdgesDpKey()

setSphereOfAction

public void setSphereOfAction(byte sphere)
Specifies the (sub-)set of edges to be routed polylinear. Default setting is ROUTE_ALL_EDGES.

Throws:
IllegalArgumentException - if the given argument is not one of the above constants.
Parameters:
sphere - One of ROUTE_SELECTED_EDGES, ROUTE_EDGES_AT_SELECTED_NODES, and ROUTE_ALL_EDGES.
See Also:
getSphereOfAction(), getSelectedEdgesDpKey(), getSelectedNodesDpKey()

getSphereOfAction

public byte getSphereOfAction()
Determines the (sub-)set of edges to be routed polylinear. Default setting is ROUTE_ALL_EDGES.

Returns:
One of ROUTE_SELECTED_EDGES, ROUTE_EDGES_AT_SELECTED_NODES, and ROUTE_ALL_EDGES.
See Also:
setSphereOfAction(byte), getSelectedEdgesDpKey(), getSelectedNodesDpKey()

getMinimalNodeToEdgeDistance

public double getMinimalNodeToEdgeDistance()
Specifies the minimal distance between edges and node bounds. Default is 10.

Returns:
The minimal distance between edges and node bounds.

setMinimalNodeToEdgeDistance

public void setMinimalNodeToEdgeDistance(double distance)
Specifies the minimal distance between edges and node bounds. Default is 10.

Throws:
IllegalArgumentException - If distance is less than 0.
Parameters:
distance - The minimal distance between edges and node bounds.

getMaximumNonOrthogonalSegmentRatio

public double getMaximumNonOrthogonalSegmentRatio()
Returns the maximum segment length ratio at each end of an orthogonal segment that may get converted into a (non-orthogonal) polyline segment. Default is 0.5.

Returns:
The maximum polyline segment ratio at each end of an orthogonal segment.

setMaximumNonOrthogonalSegmentRatio

public void setMaximumNonOrthogonalSegmentRatio(double ratio)
Sets the maximum segment length ratio at each end of an orthogonal segment that may get converted into a (non-orthogonal) polyline segment. Default is 0.5.

Throws:
IllegalArgumentException - If the ratio is out of bounds.
Parameters:
ratio - The maximum polyline segment ratio at each end of an orthogonal segment. The ratio must be between 0 and 0.5.

getPreferredPolylineSegmentLength

public double getPreferredPolylineSegmentLength()
Returns the preferred segment length for (non-orthogonal) polyline segments. Default is 50.

Returns:
The preferred segment length for (non-orthogonal) polyline segments.

setPreferredPolylineSegmentLength

public void setPreferredPolylineSegmentLength(double length)
Sets the preferred segment length for (non-orthogonal) polyline segments. Default is 50.

Throws:
IllegalArgumentException - If length is less than 0.
Parameters:
length - The preferred segment length for (non-orthogonal) polyline segments.

canLayout

public boolean canLayout(LayoutGraph graph)
Description copied from interface: Layouter
Returns true iff the given graph can be laid out by this algorithm. Calling doLayout with the given graph as its argument will only success if this method returns true.


doLayout

public void doLayout(LayoutGraph graph)
Description copied from interface: Layouter
Main layout routine that assigns new layout information to the given graph.


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