Search this API

y.layout.router
Class CurveRoutingStage

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

public class CurveRoutingStage
extends AbstractLayoutStage

CurveRoutingStage replaces polyline edge paths with curved segments using cubic bezier splines.

This layout stage provides a generic way to add curved edge paths for a layout with polyline routes. It first calls the core layout algorithm and converts the edge routes as a post-processing step. Note that IncrementalHierarchicLayouter and EdgeRouter offer an integrated curve routing, making the usage of this layout stage unnecessary (see routing styles RoutingStyle.EDGE_STYLE_CURVED and EdgeLayoutDescriptor.EDGE_STYLE_CURVED).


A layout where this stage converted orthogonal edge paths to curved ones (the input is shown below).


The orthogonal input produced by the core layout on which the above curved example is based.

Using the scope, it is possible to select for which edges the path is converted to a curved one. This allows to only change a subset of edges. Furthermore, the CurveEdgeLayoutDescriptor class allows to individually configure settings for edges.

This stage is able to consider node and edge labels, see the respective properties setNodeLabelConsiderationEnabled(boolean) and setEdgeLabelConsiderationEnabled(boolean). If edge labels are considered, the PreferredPlacementDescriptor is respected too, such that the preferred placement remains correct if it is already correct after the core layout execution.

This stage also supports edge grouping such that edges that are correctly grouped by the core layout algorithm remain grouped in the curved layout result. However, it will not create new groupings. The same applies for other features like, e.g., PortConstraints or PortCandidates. They are only respected if they are already respected by the core layout algorithm.

 
Curved segments can only be added to polyline edge routes. If the core layout algorithm creates straight-line edges, they will stay this way. Thus, this stage requires that the edges have proper polyline/orthogonal routes after the core layout was executed. It does not find new routes on its own.
 
Your browser does not support SVG content.

Field Summary
static java.lang.Object CURVE_EDGE_LAYOUT_DESCRIPTOR_DPKEY
          A DataProvider key for specifying individual edge layout information If the DataProvider registered with this key does not contain a CurveEdgeLayoutDescriptor for an edge, then the default descriptor is used.
static byte ROUTE_ALL_EDGES
          A scope specifier which defines that all edges of the input graph will be routed.
static byte ROUTE_EDGES_AT_SELECTED_NODES
          A scope specifier which defines that only edges incident to selected nodes will be routed.
static byte ROUTE_SELECTED_EDGES
          A scope specifier which defines that only the selected edges of the input graph will be routed.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
CurveRoutingStage(Layouter core)
          Creates a new CurveRoutingStage instance using the given core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all general graphs.
 void doLayout(LayoutGraph graph)
          Adds curved segments to the edge routes produced by the core layout algorithm.
 java.lang.Object getAffectedEdgesDpKey()
          Returns the DataProvider key to look up which edges are routed.
 java.lang.Object getAffectedNodesDpKey()
          Returns the DataProvider key to look up the nodes whose incident edges are routed.
 CurveEdgeLayoutDescriptor getDefaultEdgeLayoutDescriptor()
          Returns the default CurveEdgeLayoutDescriptor which provides layout information that is considered when adding curves to the edge path.
 byte getScope()
          Returns the (sub-)set of edges whose routes shall be converted to curved ones.
 boolean isEdgeLabelConsiderationEnabled()
          Returns whether or not edge labels are considered while determining curved edge routes.
 boolean isNodeLabelConsiderationEnabled()
          Returns whether or not node labels are considered while determining spline routes.
 void setAffectedEdgesDpKey(java.lang.Object affectedEdgesDpKey)
          Specifies the DataProvider key to look up which edges are routed.
 void setAffectedNodesDpKey(java.lang.Object affectedNodesDpKey)
          Specifies the DataProvider key to look up the nodes whose incident edges are routed.
 void setDefaultEdgeLayoutDescriptor(CurveEdgeLayoutDescriptor descriptor)
          Specifies the default CurveEdgeLayoutDescriptor which provides layout information that is considered when adding curves to the edge path.
 void setEdgeLabelConsiderationEnabled(boolean enabled)
          Specifies whether or not edge labels are considered while determining curved edge routes.
 void setNodeLabelConsiderationEnabled(boolean enabled)
          Specifies whether or not node labels are considered while determining spline routes.
 void setScope(byte scope)
          Specifies the (sub-)set of edges whose routes shall be converted to curved ones.
 
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

CURVE_EDGE_LAYOUT_DESCRIPTOR_DPKEY

public static final java.lang.Object CURVE_EDGE_LAYOUT_DESCRIPTOR_DPKEY
A DataProvider key for specifying individual edge layout information

If the DataProvider registered with this key does not contain a CurveEdgeLayoutDescriptor for an edge, then the default descriptor is used.

See Also:
CurveEdgeLayoutDescriptor, getDefaultEdgeLayoutDescriptor()

ROUTE_ALL_EDGES

public static final byte ROUTE_ALL_EDGES
A scope specifier which defines that all edges of the input graph will be routed.

See Also:
setScope(byte), Constant Field Values
Sample Graphs:

Input graph with orthogonal routes

All edges routed by the edge routing algorithm

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 routed.

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

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

See Also:
setScope(byte), setAffectedEdgesDpKey(Object), Constant Field Values
Sample Graphs:

Input graph with orthogonal routes

Only affected (marked) edges routed by the edge routing algorithm

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 routed.

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

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

See Also:
setScope(byte), setAffectedNodesDpKey(Object), Constant Field Values
Sample Graphs:

Input graph with orthogonal routes

Only edges connected to the affected (marked) node routed by the edge routing algorithm
Constructor Detail

CurveRoutingStage

public CurveRoutingStage(Layouter core)
Creates a new CurveRoutingStage instance using the given core layout algorithm.

Parameters:
core - the core layout algorithm
Method Detail

getScope

public byte getScope()
Returns the (sub-)set of edges whose routes shall be converted to curved ones.

Returns:
one of the default scope values
See Also:
setScope(byte), getAffectedEdgesDpKey(), getAffectedNodesDpKey()

setScope

public void setScope(byte scope)
Specifies the (sub-)set of edges whose routes shall be converted to curved ones.

Default Value:
The default value is ROUTE_ALL_EDGES
Parameters:
scope - one of the default scope values
Throws:
java.lang.IllegalArgumentException - if the given scope is unknown
See Also:
getAffectedEdgesDpKey(), getAffectedNodesDpKey()

getAffectedEdgesDpKey

public java.lang.Object getAffectedEdgesDpKey()
Returns the DataProvider key to look up which edges are routed.

If the setScope(byte) scope} is set to ROUTE_SELECTED_EDGES, only the selected edges will be routed, while all other edges will be considered to have fixed routes.

Returns:
the DataProvider key for the edge selection
See Also:
setScope(byte), setAffectedEdgesDpKey(Object)

setAffectedEdgesDpKey

public void setAffectedEdgesDpKey(java.lang.Object affectedEdgesDpKey)
Specifies the DataProvider key to look up which edges are routed.

If the setScope(byte) scope} is set to ROUTE_SELECTED_EDGES, only the selected edges will be routed, while all other edges will be considered to have fixed routes.

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

getAffectedNodesDpKey

public java.lang.Object getAffectedNodesDpKey()
Returns the DataProvider key to look up the nodes whose incident edges are routed.

If the setScope(byte) scope} is set to ROUTE_EDGES_AT_SELECTED_NODES, only the edges that are incident to selected nodes will be routed, while all other edges will be considered to have fixed routes.

Returns:
the DataProvider key for the node selection
See Also:
setScope(byte), setAffectedNodesDpKey(Object)

setAffectedNodesDpKey

public void setAffectedNodesDpKey(java.lang.Object affectedNodesDpKey)
Specifies the DataProvider key to look up the nodes whose incident edges are routed.

If the setScope(byte) scope} is set to ROUTE_EDGES_AT_SELECTED_NODES, only the edges that are incident to selected nodes will be routed, while all other edges will be considered to have fixed routes.

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

getDefaultEdgeLayoutDescriptor

public CurveEdgeLayoutDescriptor getDefaultEdgeLayoutDescriptor()
Returns the default CurveEdgeLayoutDescriptor which provides layout information that is considered when adding curves to the edge path.

This CurveEdgeLayoutDescriptor is used for all edges that have no individual layout information assigned.

Returns:
the CurveEdgeLayoutDescriptor
See Also:
CURVE_EDGE_LAYOUT_DESCRIPTOR_DPKEY, setDefaultEdgeLayoutDescriptor(CurveEdgeLayoutDescriptor)

setDefaultEdgeLayoutDescriptor

public void setDefaultEdgeLayoutDescriptor(CurveEdgeLayoutDescriptor descriptor)
Specifies the default CurveEdgeLayoutDescriptor which provides layout information that is considered when adding curves to the edge path.

This CurveEdgeLayoutDescriptor is used for all edges that have no individual layout information assigned.

Default Value:
The default value is CurveEdgeLayoutDescriptor
Parameters:
descriptor - the CurveEdgeLayoutDescriptor
Throws:
java.lang.IllegalArgumentException - if the specified CurveEdgeLayoutDescriptor is null
See Also:
CURVE_EDGE_LAYOUT_DESCRIPTOR_DPKEY

isEdgeLabelConsiderationEnabled

public boolean isEdgeLabelConsiderationEnabled()
Returns whether or not edge labels are considered while determining curved edge routes.

The edge labels are taken into account when checking for intersections and the routes are prepared to get an associated segment that fits the preferred placement of the label.

 
In case the labels are not placed yet, there can be unexpected results. Hence, make sure to have the core layout algorithm place the labels.
Returns:
true if edge labels are considered, false otherwise
See Also:
PreferredPlacementDescriptor, setEdgeLabelConsiderationEnabled(boolean)

setEdgeLabelConsiderationEnabled

public void setEdgeLabelConsiderationEnabled(boolean enabled)
Specifies whether or not edge labels are considered while determining curved edge routes.

The edge labels are taken into account when checking for intersections and the routes are prepared to get an associated segment that fits the preferred placement of the label.

 
In case the labels are not placed yet, there can be unexpected results. Hence, make sure to have the core layout algorithm place the labels.
Default Value:
The default value is true. Edge labels are considered
Parameters:
enabled - true if edge labels should be considered, false otherwise
See Also:
PreferredPlacementDescriptor

isNodeLabelConsiderationEnabled

public boolean isNodeLabelConsiderationEnabled()
Returns whether or not node labels are considered while determining spline routes.

The node labels will be taken into account when checking for intersections and the routes will be prepared to get an associated segment that fits the the preferred placement of the label.

 
In case the labels are not placed yet, there can be unexpected results. Hence, make sure to have the core layout algorithm place the labels.
Returns:
true if node labels are considered, false otherwise
See Also:
setNodeLabelConsiderationEnabled(boolean)

setNodeLabelConsiderationEnabled

public void setNodeLabelConsiderationEnabled(boolean enabled)
Specifies whether or not node labels are considered while determining spline routes.

The node labels will be taken into account when checking for intersections and the routes will be prepared to get an associated segment that fits the the preferred placement of the label.

 
In case the labels are not placed yet, there can be unexpected results. Hence, make sure to have the core layout algorithm place the labels.
Default Value:
The default value is true. Node labels are considered
Parameters:
enabled - true if node labels should be considered, false otherwise

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all general graphs.

Parameters:
graph - the input graph
Returns:
true for all graphs
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Adds curved 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.