y.layout.router
Class OrthogonalEdgeRouter

java.lang.Object
  |
  +--y.layout.AbstractLayoutStage
        |
        +--y.layout.router.OrthogonalEdgeRouter
All Implemented Interfaces:
Layouter, LayoutStage

public class OrthogonalEdgeRouter
extends AbstractLayoutStage

This class represents an orthogonal edge router. An orthogonal edge router is a layout algorithm that changes the coordinates of the edge paths in a way that the resulting layout of the edges is made up of vertical and horizontal segments only. The router does not change the location or the size of the nodes in a diagram in any way.

This edge router can obey strong and weak port constraints. It expects the port constraints to be bound to the input graph by the data provider keys PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY and PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY

Precondition: In the current version, the input graph may not contain any self-loops.

The router often finds ideal routes in difficult situations like the one depicted below.


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.
static byte STYLE_ADHOC
          Routing style specifier.
static byte STYLE_PREFERMIDDLE
          Routing style specifier.
static byte STYLE_SHORTPATH
          Routing style specifier.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
OrthogonalEdgeRouter()
          Creates a new instance of the Orthogonal Edge Router.
OrthogonalEdgeRouter(Layouter core)
          Convenience constructor to simultaneously set a core layout algorithm which will run before the orthogonal edge router.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns false if the graph contains any self-loops, else true.
 void doLayout(LayoutGraph graph)
          Main entrance to orthogonal edge routing.
 boolean getBadOrthogonal()
          Returns whether bad edges should be drawn in an orthogonal fashion.
 double getCenterToSpaceRatio()
          Returns the currently set ratio between the two complementary weighting strategies center driven and space driven.
 boolean getCoupledDistances()
          Returns whether the minimum distances are coupled.
 int getCustomBorderCapacity()
          Returns the currently set custom value for the capacity of the routing border around the graph's bounding box.
 boolean getCustomBorderCapacityEnabled()
          Returns the a custom value for the capacity of the routing border should be applied.
 YPoint getGridOrigin()
          Returns a grid point coordinate used when grid routing is enabled.
 int getGridSpacing()
          Returns the grid spacing to be assumed when grid routing is enabled.
 int getMinimumDistance()
          Returns the minimum distance between edge segments.
 int getMinimumDistanceToNode()
          Returns the minimum distance between edge segments and nodes.
 byte getRoutingStyle()
          Returns the currently set routing style.
 byte getSphereOfAction()
          Returns the currently set sphere of action specifier.
 String getStatistics()
          Returns statistical information about the Orthogonal Edge Router.
 boolean isGridRoutingEnabled()
          Returns whether or not to route edge segments on grid lines.
 boolean isInnerPortsEnabled()
          Returns whether edge ports should lay inside the node's bounding box or on its border.
 boolean isLocalCrossingMinimizationEnabled()
          Returns whether the local crossing minimization strategy is enabled.
 void setBadOrthogonal(boolean value)
          Determines the way that edges which cannot be routed should be drawn.
 void setCenterToSpaceRatio(double csr)
          Determines the ratio between two complementary weighting strategies, namely center driven and space driven weighting, when looking for an edge path.
 void setCoupledDistances(boolean coupled)
          Whether or not the minimum distances should be coupled, i.e., whether half the value set for the minimum distance between edge segments should automatically be used as the minimum distance between edge segments and nodes, or a custom value should be used instead.
 void setCustomBorderCapacity(int value)
          Determines the custom value for the capacity of the routing border around the graph's bounding box.
 void setCustomBorderCapacityEnabled(boolean value)
          Whether or not a custom value for the capacity of the routing border around the graph's bounding box should be applied.
 void setGridOrigin(int x, int y)
          Sets a grid point coordinate used when grid routing is enabled.
 void setGridRoutingEnabled(boolean enabled)
          Whether or not to route edge segments on grid lines.
 void setGridSpacing(int spacing)
          Sets the grid spacing to be assumed when grid routing is enabled.
 void setInnerPortsEnabled(boolean value)
          Whether edge ports should lay inside the node's bounding box or on its border.
 void setLocalCrossingMinimizationEnabled(boolean enabled)
          Whether or not a local crossing minimization strategy should be applied.
 void setMinimumDistance(int dist)
          Sets the minimum distance between edge segments.
 void setMinimumDistanceToNode(int dist)
          Sets the minimum distance between edge segments and nodes.
 boolean setProperty(String key, Object value)
           
 void setRoutingStyle(byte style)
          Sets the preferred routing style for the edges to be routed.
 void setSphereOfAction(byte sphere)
          Sets the edge (sub-)set 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
Sphere of action specifier. Route all edges of the input graph.

See Also:
OrthogonalEdgeRouter.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 Layouter.SELECTED_EDGES.

See Also:
Graph.addDataProvider(Object, DataProvider), OrthogonalEdgeRouter.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 Layouter.SELECTED_NODES.

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

STYLE_ADHOC

public static final byte STYLE_ADHOC
Routing style specifier. Edge segments are drawn ad hoc, i.e., rather crude.

See Also:
OrthogonalEdgeRouter.setRoutingStyle(byte), Constant Field Values

STYLE_SHORTPATH

public static final byte STYLE_SHORTPATH
Routing style specifier. Edge segments are drawn the short way, i.e., with the global way of the edge in mind.

See Also:
OrthogonalEdgeRouter.setRoutingStyle(byte), Constant Field Values

STYLE_PREFERMIDDLE

public static final byte STYLE_PREFERMIDDLE
Routing style specifier. Edge segments are drawn with the most distance to already known obstacles such as nodes or other edge segments.

See Also:
OrthogonalEdgeRouter.setRoutingStyle(byte), Constant Field Values
Constructor Detail

OrthogonalEdgeRouter

public OrthogonalEdgeRouter()
Creates a new instance of the Orthogonal Edge Router. The initial settings (the default values) make up an instance that:

See Also:
OrthogonalEdgeRouter.setSphereOfAction(byte), OrthogonalEdgeRouter.setGridRoutingEnabled(boolean), OrthogonalEdgeRouter.setRoutingStyle(byte), OrthogonalEdgeRouter.setBadOrthogonal(boolean)

OrthogonalEdgeRouter

public OrthogonalEdgeRouter(Layouter core)
Convenience constructor to simultaneously set a core layout algorithm which will run before the orthogonal edge router.

See Also:
OrthogonalEdgeRouter.OrthogonalEdgeRouter()
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Returns false if the graph contains any self-loops, else true.


doLayout

public void doLayout(LayoutGraph graph)
Main entrance to orthogonal edge routing. Routes the edges of the given graph according to the settings made through OrthogonalEdgeRouter.setSphereOfAction(byte), OrthogonalEdgeRouter.setGridRoutingEnabled(boolean), and OrthogonalEdgeRouter.setMinimumDistance(int)/ OrthogonalEdgeRouter.setGridSpacing(int), respectively. These are the three basic main options. Further aspects can be set by the methods OrthogonalEdgeRouter.setRoutingStyle(byte), and OrthogonalEdgeRouter.setBadOrthogonal(boolean). Precondition: Note, that the given graph should not contain any self-loops.


setProperty

public boolean setProperty(String key,
                           Object value)

getStatistics

public String getStatistics()
Returns statistical information about the Orthogonal Edge Router.


setSphereOfAction

public void setSphereOfAction(byte sphere)
Sets the edge (sub-)set to be routed.

Parameters:
sphere - One of OrthogonalEdgeRouter.ROUTE_SELECTED_EDGES, OrthogonalEdgeRouter.ROUTE_EDGES_AT_SELECTED_NODES and OrthogonalEdgeRouter.ROUTE_ALL_EDGES.
See Also:
Layouter.SELECTED_EDGES, Layouter.SELECTED_NODES

getSphereOfAction

public byte getSphereOfAction()
Returns the currently set sphere of action specifier.

See Also:
OrthogonalEdgeRouter.setSphereOfAction(byte)

setGridRoutingEnabled

public void setGridRoutingEnabled(boolean enabled)
Whether or not to route edge segments on grid lines. By default this feature is disabled, i.e., "free" routing is enabled.

See Also:
OrthogonalEdgeRouter.setGridOrigin(int, int), OrthogonalEdgeRouter.setGridSpacing(int)

isGridRoutingEnabled

public boolean isGridRoutingEnabled()
Returns whether or not to route edge segments on grid lines.


setGridOrigin

public void setGridOrigin(int x,
                          int y)
Sets a grid point coordinate used when grid routing is enabled. By default (0, 0) is set.

See Also:
OrthogonalEdgeRouter.setGridRoutingEnabled(boolean)

getGridOrigin

public YPoint getGridOrigin()
Returns a grid point coordinate used when grid routing is enabled.


setGridSpacing

public void setGridSpacing(int spacing)
Sets the grid spacing to be assumed when grid routing is enabled. By default a spacing of 2 is set. This is also the minimum allowed spacing.

Parameters:
spacing - Integral value that determines the desired grid spacing. Positive values less than 2 are ignored. Negative values are mapped to their absolute.
See Also:
OrthogonalEdgeRouter.setGridRoutingEnabled(boolean)

getGridSpacing

public int getGridSpacing()
Returns the grid spacing to be assumed when grid routing is enabled.


setMinimumDistance

public void setMinimumDistance(int dist)
Sets the minimum distance between edge segments. By default a distance of 2 is set. This is also the minimum allowed distance.

Parameters:
dist - Integral value that determines the desired distance. Positive values less than 4 are ignored. Negative values are mapped to their absolute.

Note: If the minimum distances are coupled (as is the default), half the value as set here is automatically used as the minimum distance between edge segments and nodes.

See Also:
OrthogonalEdgeRouter.setCoupledDistances(boolean), OrthogonalEdgeRouter.setMinimumDistanceToNode(int)

getMinimumDistance

public int getMinimumDistance()
Returns the minimum distance between edge segments.


setCoupledDistances

public void setCoupledDistances(boolean coupled)
Whether or not the minimum distances should be coupled, i.e., whether half the value set for the minimum distance between edge segments should automatically be used as the minimum distance between edge segments and nodes, or a custom value should be used instead. By default the minimum distances are coupled.

See Also:
OrthogonalEdgeRouter.setMinimumDistanceToNode(int), OrthogonalEdgeRouter.setMinimumDistance(int)

getCoupledDistances

public boolean getCoupledDistances()
Returns whether the minimum distances are coupled.


setMinimumDistanceToNode

public void setMinimumDistanceToNode(int dist)
Sets the minimum distance between edge segments and nodes.

Parameters:
dist - Integral value that determines the desired distance. Positive values less than 2 are ignored. Negative values are mapped to their absolute.

Note: If the minimum distances are coupled (as is the default), half the value as set for the minimum distance between edge segments is automatically used here.

See Also:
OrthogonalEdgeRouter.setCoupledDistances(boolean), OrthogonalEdgeRouter.setMinimumDistance(int)

getMinimumDistanceToNode

public int getMinimumDistanceToNode()
Returns the minimum distance between edge segments and nodes.


setLocalCrossingMinimizationEnabled

public void setLocalCrossingMinimizationEnabled(boolean enabled)
Whether or not a local crossing minimization strategy should be applied. By default this feature is enabled.


isLocalCrossingMinimizationEnabled

public boolean isLocalCrossingMinimizationEnabled()
Returns whether the local crossing minimization strategy is enabled.

See Also:
OrthogonalEdgeRouter.setLocalCrossingMinimizationEnabled(boolean)

setCenterToSpaceRatio

public void setCenterToSpaceRatio(double csr)
Determines the ratio between two complementary weighting strategies, namely center driven and space driven weighting, when looking for an edge path.

Parameters:
csr - Ranges from 0.0 to 1.0; higher values give more emphasis to edge paths closer to an edge's center. The default is an equal weighting of center driven and space driven strategy, i.e., csr equals 0.5.

getCenterToSpaceRatio

public double getCenterToSpaceRatio()
Returns the currently set ratio between the two complementary weighting strategies center driven and space driven.

See Also:
OrthogonalEdgeRouter.setCenterToSpaceRatio(double)

setRoutingStyle

public void setRoutingStyle(byte style)
Sets the preferred routing style for the edges to be routed. The default is OrthogonalEdgeRouter.STYLE_PREFERMIDDLE.

Parameters:
style - One of OrthogonalEdgeRouter.STYLE_ADHOC, OrthogonalEdgeRouter.STYLE_SHORTPATH and OrthogonalEdgeRouter.STYLE_PREFERMIDDLE.

getRoutingStyle

public byte getRoutingStyle()
Returns the currently set routing style.

See Also:
OrthogonalEdgeRouter.setRoutingStyle(byte)

setBadOrthogonal

public void setBadOrthogonal(boolean value)
Determines the way that edges which cannot be routed should be drawn. If set, edge paths are drawn in an orthogonal fashion with at most one bend. Otherwise the edge path is drawn as a straight line.


getBadOrthogonal

public boolean getBadOrthogonal()
Returns whether bad edges should be drawn in an orthogonal fashion.

See Also:
OrthogonalEdgeRouter.setBadOrthogonal(boolean)

setCustomBorderCapacityEnabled

public void setCustomBorderCapacityEnabled(boolean value)
Whether or not a custom value for the capacity of the routing border around the graph's bounding box should be applied.

See Also:
OrthogonalEdgeRouter.setCustomBorderCapacity(int)

getCustomBorderCapacityEnabled

public boolean getCustomBorderCapacityEnabled()
Returns the a custom value for the capacity of the routing border should be applied.

See Also:
OrthogonalEdgeRouter.setCustomBorderCapacity(int)

setCustomBorderCapacity

public void setCustomBorderCapacity(int value)
Determines the custom value for the capacity of the routing border around the graph's bounding box. The routing border means the space left of the leftmost node, right of the rightmost node, above the topmost node, and below the bottommost node. By default this value is set to 5, i.e., the routing border accommodates up to 5 parallel edge paths left of the leftmost node, right of the rightmost node, etc. ...


getCustomBorderCapacity

public int getCustomBorderCapacity()
Returns the currently set custom value for the capacity of the routing border around the graph's bounding box.

See Also:
OrthogonalEdgeRouter.setCustomBorderCapacity(int)

setInnerPortsEnabled

public void setInnerPortsEnabled(boolean value)
Whether edge ports should lay inside the node's bounding box or on its border. More specifically, "inside" means on the node's meridian for edges connecting to the left and right, and on the node's equator for edges connecting to the upper and lower side.


isInnerPortsEnabled

public boolean isInnerPortsEnabled()
Returns whether edge ports should lay inside the node's bounding box or on its border.

See Also:
OrthogonalEdgeRouter.setInnerPortsEnabled(boolean)

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

2003