Search this API

y.layout.router
Class StraightLineEdgeRouter

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.router.StraightLineEdgeRouter
All Implemented Interfaces:
Layouter, LayoutStage
Direct Known Subclasses:
PartialLayouter.StraightLineEdgeRouter

public class StraightLineEdgeRouter
extends AbstractLayoutStage

This edge routing algorithm routes edges as straight-lines considering the specified PortConstraints.

Layout Style

The edges connect to their ports with straight-lines. This may lead to edges crossing nodes.

Concept

StraightLineEdgeRouter will first invoke the AbstractLayoutStage.getCoreLayouter() if one exists. Then, it will remove all bends from the edges and will place the ports either on the center of the nodes or at a location specified by a PortConstraint.

 
Your browser does not support SVG content.

Field Summary
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
StraightLineEdgeRouter()
          Creates a new instance of StraightLineEdgeRouter with default settings.
StraightLineEdgeRouter(Layouter core)
          Creates a new instance of StraightLineEdgeRouter using the given core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that are accepted by the core layout algorithm.
 void doLayout(LayoutGraph graph)
          Routes the edges as straight-lines from their source to their target after invoking the core layout algorithm.
 java.lang.Object getSelectedEdgesDpKey()
          Returns the key to register a DataProvider that provides the selected state of the edges of the graph.
 java.lang.Object getSelectedNodesDpKey()
          Returns the key to register a DataProvider that provides the selected state of the nodes of the graph.
 byte getSphereOfAction()
          Returns the (sub-)set of edges to be routed.
 void setSelectedEdgesDpKey(java.lang.Object selectedEdgesDpKey)
          Specifies the key to register a DataProvider that provides the selected state of the edges of the graph.
 void setSelectedNodesDpKey(java.lang.Object key)
          Specifies the key to register a DataProvider that provides the selected state of the nodes of the graph.
 void setSphereOfAction(byte scope)
          Specifies the (sub-)set of edges to be routed.
 
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 routed.

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

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

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

StraightLineEdgeRouter

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

Parameters:
core - the core layout algorithm

StraightLineEdgeRouter

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

Method Detail

getSphereOfAction

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

StraightLineEdgeRouter will only route those edges and leave the remaining edges unchanged.

Returns:
one of the valid scope specifiers
See Also:
setSphereOfAction(byte), getSelectedEdgesDpKey(), getSelectedNodesDpKey()

setSphereOfAction

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

StraightLineEdgeRouter will only route those edges and leave the remaining edges unchanged.

Default Value:
The default value is ROUTE_ALL_EDGES
Parameters:
scope - one of the valid scope specifiers
Throws:
java.lang.IllegalArgumentException - if the given argument is an unknown specifier
See Also:
getSelectedEdgesDpKey(), getSelectedNodesDpKey()

getSelectedNodesDpKey

public java.lang.Object getSelectedNodesDpKey()
Returns the key to register a DataProvider that provides the selected state of the nodes of the graph.

If the scope only includes edges at selected nodes, only edges of the nodes marked in this DataProvider are routed while all other edges are considered to have fixed routes.

Returns:
the key to register a DataProvider for the node selection
See Also:
setSelectedNodesDpKey(Object), getSphereOfAction()

setSelectedNodesDpKey

public void setSelectedNodesDpKey(java.lang.Object key)
Specifies the key to register a DataProvider that provides the selected state of the nodes of the graph.

If the scope only includes edges at selected nodes, only edges of the nodes marked in this DataProvider are routed while all other edges are considered to have fixed routes.

Default Value:
The default value is Layouter.SELECTED_NODES
Parameters:
key - the key to register a DataProvider 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 key to register a DataProvider that provides the selected state of the edges of the graph.

If the scope only includes selected edges, only edges of the nodes marked in this DataProvider are routed while all other edges are considered to have fixed routes.

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

setSelectedEdgesDpKey

public void setSelectedEdgesDpKey(java.lang.Object selectedEdgesDpKey)
Specifies the key to register a DataProvider that provides the selected state of the edges of the graph.

If the scope only includes selected edges, only edges of the nodes marked in this DataProvider are routed while all other edges are considered to have fixed routes.

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

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that are accepted by the core layout algorithm.

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

doLayout

public void doLayout(LayoutGraph graph)
Routes the edges as straight-lines from their source to their target after invoking the core layout algorithm.

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

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