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

PolylineLayoutStage extends the orthogonal edge paths with polyline segments. The current implementation only adds octilinear segments to all orthogonal edges. Non-orthogonal edges are completely ignored.

An octilinear segment is added between two consecutive vertical and horizontal segments. The length of an octilinear segment can be influenced by the maximum non-orthogonal segment ratio and the preferred polyline segment length. The new octilinear segments maintain a minimum distance between the edges and all nodes in the graph if possible.

 

Field Summary
static byte ROUTE_ALL_EDGES
          A scope specifier which defines that all edges of the input graph will be adjusted.
static byte ROUTE_EDGES_AT_SELECTED_NODES
          A scope specifier which defines that only edges incident to selected nodes will be adjusted.
static byte ROUTE_SELECTED_EDGES
          A scope specifier which defines that only the selected edges of the input graph will be adjusted.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
PolylineLayoutStage()
          Creates a new instance of PolylineLayoutStage with default settings.
PolylineLayoutStage(Layouter coreLayouter)
          Creates a new instance of PolylineLayoutStage using the given core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that can be handled by the core layout algorithm.
 void doLayout(LayoutGraph graph)
          Adds polyline segments to the edge routes produced by the core layout algorithm.
 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()
          Returns the minimum distance between edges and node bounds.
 double getPreferredPolylineSegmentLength()
          Returns the preferred segment length for (non-orthogonal) polyline segments.
 java.lang.Object getSelectedEdgesDpKey()
          Returns the DataProvider key used for looking up the selected state of the edges of the graph to be laid out.
 java.lang.Object getSelectedNodesDpKey()
          Returns the DataProvider key used for looking up the selected state of the nodes of the graph to be laid out.
 byte getSphereOfAction()
          Returns the (sub-)set of edges to be routed in a polyline fashion.
 void setMaximumNonOrthogonalSegmentRatio(double ratio)
          Specifies 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 minimum distance between edges and node bounds.
 void setPreferredPolylineSegmentLength(double length)
          Specifies the preferred segment length for (non-orthogonal) polyline segments.
 void setSelectedEdgesDpKey(java.lang.Object selectedEdgesDpKey)
          Specifies the DataProvider key used for looking up the selected state of the edges of the graph to be laid out.
 void setSelectedNodesDpKey(java.lang.Object key)
          Specifies the DataProvider key used for looking up the selected state of the nodes of the graph to be laid out.
 void setSphereOfAction(byte scope)
          Specifies the (sub-)set of edges to be routed in a polyline fashion.
 
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
A scope specifier which defines that all edges of the input graph will be adjusted.

See Also:
setSphereOfAction(byte), Constant Field Values

ROUTE_SELECTED_EDGES

public static final byte ROUTE_SELECTED_EDGES
A scope specifier which defines that only the selected edges of the input graph will be adjusted.

The selection state of an edge is determined by a boolean value returned by a DataProvider registered with key getSelectedEdgesDpKey().

All other non-selected edges will be considered to have fixed routes.

See Also:
setSphereOfAction(byte), setSelectedEdgesDpKey(Object), Constant Field Values

ROUTE_EDGES_AT_SELECTED_NODES

public static final byte ROUTE_EDGES_AT_SELECTED_NODES
A scope specifier which defines that only edges incident to selected nodes will be adjusted.

The selection state of a node is determined by a boolean value returned by a DataProvider registered with key getSelectedNodesDpKey().

All other edges that are incident to non-selected nodes will be considered to have fixed routes.

See Also:
setSphereOfAction(byte), setSelectedNodesDpKey(Object), Constant Field Values
Constructor Detail

PolylineLayoutStage

public PolylineLayoutStage(Layouter coreLayouter)
Creates a new instance of PolylineLayoutStage using the given core layout algorithm.

Parameters:
coreLayouter - the core layout routine

PolylineLayoutStage

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

Method Detail

getSelectedNodesDpKey

public java.lang.Object getSelectedNodesDpKey()
Returns the DataProvider key used for looking up the selected state of the nodes of the graph to be laid out.

If the scope 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 DataProvider key for the node selection
See Also:
setSelectedNodesDpKey(Object), getSphereOfAction()

setSelectedNodesDpKey

public void setSelectedNodesDpKey(java.lang.Object key)
Specifies the DataProvider key used for looking up the selected state of the nodes of the graph to be laid out.

If the scope 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.

Default Value:
The default value is Layouter.SELECTED_NODES
Parameters:
key - the DataProvider key for the node selection
Throws:
java.lang.IllegalArgumentException - if the specified key is null
See Also:
getSelectedNodesDpKey(), getSphereOfAction()

getSelectedEdgesDpKey

public java.lang.Object getSelectedEdgesDpKey()
Returns the DataProvider key used for looking up the selected state of the edges of the graph to be laid out.

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

Returns:
the DataProvider key for the edge selection
See Also:
setSelectedEdgesDpKey(Object), getSphereOfAction()

setSelectedEdgesDpKey

public void setSelectedEdgesDpKey(java.lang.Object selectedEdgesDpKey)
Specifies the DataProvider key used for looking up the selected state of the edges of the graph to be laid out.

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

Default Value:
The default value is Layouter.SELECTED_EDGES
Parameters:
selectedEdgesDpKey - the DataProvider key for the edge selection
Throws:
java.lang.IllegalArgumentException - if the specified key is null
See Also:
getSelectedEdgesDpKey(), getSphereOfAction()

setSphereOfAction

public void setSphereOfAction(byte scope)
Specifies the (sub-)set of edges to be routed in a polyline fashion.

Default Value:
The default value is ROUTE_ALL_EDGES. All edges are routed.
Parameters:
scope - one of the default scope values
Throws:
java.lang.IllegalArgumentException - if the given argument is none of the predefined scope values
See Also:
getSelectedEdgesDpKey(), getSelectedNodesDpKey()

getSphereOfAction

public byte getSphereOfAction()
Returns the (sub-)set of edges to be routed in a polyline fashion.

Returns:
one of the default scope values
See Also:
getSelectedEdgesDpKey(), getSelectedNodesDpKey(), setSphereOfAction(byte)

getMinimalNodeToEdgeDistance

public double getMinimalNodeToEdgeDistance()
Returns the minimum distance between edges and node bounds.

Values should be greater than or equal to 0.

Returns:
the minimum distance between edges and node bounds
See Also:
setMinimalNodeToEdgeDistance(double)

setMinimalNodeToEdgeDistance

public void setMinimalNodeToEdgeDistance(double distance)
Specifies the minimum distance between edges and node bounds.

Values should be greater than or equal to 0.

Default Value:
The default value is 10.
Parameters:
distance - the minimum distance between edges and node bounds
Throws:
java.lang.IllegalArgumentException - if the distance is negative

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.

The ratio must be between 0 and 0.5.

Returns:
a value from the interval [0,0.5]
See Also:
setMaximumNonOrthogonalSegmentRatio(double)

setMaximumNonOrthogonalSegmentRatio

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

The ratio must be between 0 and 0.5.

Default Value:
The default value is 0.5.
Parameters:
ratio - a value from the interval [0,0.5]
Throws:
java.lang.IllegalArgumentException - if the ratio does not lie within [0,0.5] interval

getPreferredPolylineSegmentLength

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

Values should be greater than or equal to 0.

Returns:
the preferred segment length for (non-orthogonal) polyline segments
See Also:
setPreferredPolylineSegmentLength(double)

setPreferredPolylineSegmentLength

public void setPreferredPolylineSegmentLength(double length)
Specifies the preferred segment length for (non-orthogonal) polyline segments.

Values should be greater than or equal to 0.

Default Value:
The default value is 50.
Parameters:
length - the preferred segment length for (non-orthogonal) polyline segments
Throws:
java.lang.IllegalArgumentException - if the length is negative

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm.

If there is no core layout algorithm, all graphs are accepted.

Parameters:
graph - the input graph
Returns:
true if there is no core layout algorithm or the core layout algorithm accepts the graph, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Adds polyline segments to the edge routes produced by the core layout algorithm.

Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

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