|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.AbstractLayoutStage y.layout.router.OrthogonalEdgeRouter
public class OrthogonalEdgeRouter
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.
Several LayoutStages can be used to enhance performance and/or functionality of this class, e.g. EdgeGroupRouterStage
, GroupNodeRouterStage
, ReducedSphereOfActionStage
or PatchRouterStage
.
This edge router will 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
. Furthermore, this class supports the more advanced port constraint
concept of PortCandidate
s. It expects collections of port candidates to be bound to the input graph by the
data provider keys PortCandidate.SOURCE_PCLIST_DPKEY
and PortCandidate.TARGET_PCLIST_DPKEY
.
The router often finds ideal routes in difficult situations like the one depicted below.
Field Summary | |
---|---|
static byte |
MONOTONIC_BOTH
Constant that specifies monotonic path restrictions for edges. |
static byte |
MONOTONIC_HORIZONTAL
Constant that specifies monotonic path restrictions for edges. |
static byte |
MONOTONIC_NONE
Constant that specifies monotonic path restrictions for edges. |
static byte |
MONOTONIC_VERTICAL
Constant that specifies monotonic path restrictions for edges. |
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_BALANCED
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 true if the specified core layouter does, and also when there is no core layouter. |
protected void |
checkGroupNodeSize(GraphLayout layout,
Object node)
This method throws an IllegalArgumentException if the width/height of the given group node object is zero. |
protected void |
checkNodeSize(GraphLayout layout,
Object node)
This method throws an IllegalArgumentException if the width/height of the given node object is zero. |
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. |
double |
getCrossingCost()
Returns the cost for each edge crossing of a routed path. |
int |
getCustomBorderCapacity()
Returns the currently set custom value for the capacity of the routing border around the graph's bounding box. |
boolean |
getCustomBorderCapacityEnabled()
Returns whether a custom value for the capacity of the routing border is used. |
YPoint |
getGridOrigin()
Returns a grid point coordinate used when grid routing is enabled. |
int |
getGridSpacing()
Returns the grid spacing that is used 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 |
getMonotonicPathRestriction()
Returns the specified kind of monotonic path restrictions. |
byte |
getRoutingStyle()
Returns the currently set routing style. |
Object |
getSelectedEdgesDpKey()
Returns the DataProvider key to mark edges as
selected. |
Object |
getSelectedNodesDpKey()
Returns the DataProvider key to mark nodes as
selected. |
byte |
getSphereOfAction()
Returns the currently set sphere of action specifier. |
boolean |
isConsiderNodeLabelsEnabled()
Returns whether or not node labels are taken into account when calculating edge paths (thereby preventing possible edge/node label overlaps). |
boolean |
isEnforceMonotonicPathRestrictions()
Returns whether monotonic path restrictions (set with setMonotonicPathRestriction(byte) ) should be enforced. |
boolean |
isGridRoutingEnabled()
Returns whether or not to route edge segments on grid lines. |
boolean |
isInnerPortsEnabled()
Returns whether edge ports (that do not have a strong port constraint set) should lie inside the node's bounding box or on the node's border. |
boolean |
isLocalCrossingMinimizationEnabled()
Returns whether the local crossing minimization strategy is enabled. |
boolean |
isReroutingEnabled()
Returns whether rerouting bad edges 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 |
setConsiderNodeLabelsEnabled(boolean enabled)
Specifies whether or not to consider node labels when calculating edge paths (thereby preventing possible edge/node label overlaps). |
void |
setCoupledDistances(boolean coupled)
Specifies whether or not the minimum distances should be coupled. |
void |
setCrossingCost(double cost)
Sets the cost for each edge crossing of a routed path. |
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)
Specifies whether or not a custom value for the capacity of the routing border around the graph's bounding box should be applied. |
void |
setEnforceMonotonicPathRestrictions(boolean enforceMonotonicPathRestrictions)
Whether or not monotonic path restrictions (set with setMonotonicPathRestriction(byte) ) should be enforced. |
void |
setGridOrigin(int x,
int y)
Sets a grid point coordinate used when grid routing is enabled. |
void |
setGridRoutingEnabled(boolean enabled)
Specifies whether or not to route edge segments on grid lines. |
void |
setGridSpacing(int spacing)
Sets the grid spacing that is used when grid routing is enabled. |
void |
setInnerPortsEnabled(boolean value)
Specifies whether edge ports (that do not have a strong port constraint set) should lie inside the node's bounding box or on the node's border. |
void |
setLocalCrossingMinimizationEnabled(boolean enabled)
Specifies 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. |
void |
setMonotonicPathRestriction(byte monotonicPathRestriction)
Specifies which kind of monotonic path restrictions should be applied. |
void |
setReroutingEnabled(boolean enabled)
Specifies whether or not to enable a further crossing minimization optimization based on rerouting edges that cross many edges. |
void |
setRoutingStyle(byte style)
Sets the preferred routing style for the edges to be routed. |
void |
setSelectedEdgesDpKey(Object key)
Specifies the DataProvider key to mark edges as
selected. |
void |
setSelectedNodesDpKey(Object key)
Specifies the DataProvider key to mark nodes as
selected. |
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 |
---|
public static final byte MONOTONIC_NONE
setMonotonicPathRestriction(byte)
,
Constant Field Valuespublic static final byte MONOTONIC_VERTICAL
setMonotonicPathRestriction(byte)
,
Constant Field Valuespublic static final byte MONOTONIC_HORIZONTAL
setMonotonicPathRestriction(byte)
,
Constant Field Valuespublic static final byte MONOTONIC_BOTH
setMonotonicPathRestriction(byte)
,
Constant Field Valuespublic static final byte STYLE_ADHOC
setRoutingStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_SHORTPATH
setRoutingStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_PREFERMIDDLE
setRoutingStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_BALANCED
STYLE_PREFERMIDDLE
for the two end segments and segments between bends
of different directions. Segments between bends of the same direction (u-shaped turns) are drawn the short way.
This style achieves a well-balanced routing and is used by default.
setRoutingStyle(byte)
,
Constant Field Valuespublic static final byte ROUTE_ALL_EDGES
setSphereOfAction(byte)
,
Constant Field Valuespublic static final byte ROUTE_SELECTED_EDGES
getSelectedEdgesDpKey()
.
Graph.addDataProvider(Object,DataProvider)
,
setSphereOfAction(byte)
,
Constant Field Valuespublic static final byte ROUTE_EDGES_AT_SELECTED_NODES
getSelectedNodesDpKey()
.
Graph.addDataProvider(Object,DataProvider)
,
setSphereOfAction(byte)
,
Constant Field ValuesConstructor Detail |
---|
public OrthogonalEdgeRouter()
setSphereOfAction(byte)
,
setGridRoutingEnabled(boolean)
,
setRoutingStyle(byte)
,
setBadOrthogonal(boolean)
public OrthogonalEdgeRouter(Layouter core)
OrthogonalEdgeRouter()
Method Detail |
---|
public Object getSelectedNodesDpKey()
DataProvider
key to mark nodes as
selected.
By default, Layouter.SELECTED_NODES
is used.
DataProvider
key to mark nodes as selected.setSelectedNodesDpKey(Object)
public void setSelectedNodesDpKey(Object key)
DataProvider
key to mark nodes as
selected.
By default, Layouter.SELECTED_NODES
is used.
IllegalArgumentException
- if the specified key is null
.key
- the DataProvider
key.getSelectedNodesDpKey()
public Object getSelectedEdgesDpKey()
DataProvider
key to mark edges as
selected.
By default, Layouter.SELECTED_EDGES
is used.
DataProvider
key to mark edges as selected.setSelectedEdgesDpKey(Object)
public void setSelectedEdgesDpKey(Object key)
DataProvider
key to mark edges as
selected.
By default, Layouter.SELECTED_EDGES
is used.
IllegalArgumentException
- if the specified key is null
.key
- the DataProvider
key.getSelectedEdgesDpKey()
public void setConsiderNodeLabelsEnabled(boolean enabled)
false
.
enabled
- whether to enable this featurepublic boolean isConsiderNodeLabelsEnabled()
false
.
public byte getMonotonicPathRestriction()
setMonotonicPathRestriction(byte)
public void setMonotonicPathRestriction(byte monotonicPathRestriction)
MONOTONIC_NONE
, MONOTONIC_VERTICAL
, MONOTONIC_HORIZONTAL
and MONOTONIC_BOTH
.
monotonicPathRestriction
- the monotonic path restriction.public boolean isEnforceMonotonicPathRestrictions()
setMonotonicPathRestriction(byte)
) should be enforced.
setEnforceMonotonicPathRestrictions(boolean)
public void setEnforceMonotonicPathRestrictions(boolean enforceMonotonicPathRestrictions)
setMonotonicPathRestriction(byte)
) should be enforced.
Enabling this option guarantees monotonic edge paths even if this results in additional overlaps between edges and nodes.
public boolean canLayout(LayoutGraph graph)
true
if the specified core layouter does, and also when there is no core layouter.
public void doLayout(LayoutGraph graph)
protected void checkNodeSize(GraphLayout layout, Object node) throws IllegalArgumentException
IllegalArgumentException
if the width/height of the given node object is zero.
It is called by the doLayout(LayoutGraph)
method for each node object in the input graph.
IllegalArgumentException
- thrown if the width/height of the node object is zero.layout
- a graph layout object.node
- the node object to test.checkGroupNodeSize(GraphLayout,Object)
protected void checkGroupNodeSize(GraphLayout layout, Object node) throws IllegalArgumentException
IllegalArgumentException
if the width/height of the given group node object is zero.
It is called by the doLayout(LayoutGraph)
method for each group node object in the input graph.
IllegalArgumentException
- thrown if the width/height of the group node object is zero.layout
- a graph layout object.node
- the group node object to test.checkNodeSize(GraphLayout,Object)
public void setCrossingCost(double cost)
n
means that a path rather changes
direction n
times than crossing the path of an edge. By default the cost is set to 0
and
therefore no global crossing optimization is performed. Setting a higher value will activate global crossing
minimization. A good trade-off between the number of direction changes and few crossings of a path is achieved by
values between 1
and 3
.
public double getCrossingCost()
setCrossingCost(double)
public void setReroutingEnabled(boolean enabled)
0
.
setCrossingCost(double)
public boolean isReroutingEnabled()
setReroutingEnabled(boolean)
public void setSphereOfAction(byte sphere)
ROUTE_ALL_EDGES
.
sphere
- One of
ROUTE_SELECTED_EDGES
,
ROUTE_EDGES_AT_SELECTED_NODES
, and
ROUTE_ALL_EDGES
.getSelectedEdgesDpKey()
,
getSelectedNodesDpKey()
public byte getSphereOfAction()
setSphereOfAction(byte)
public void setGridRoutingEnabled(boolean enabled)
setGridOrigin(int,int)
,
setGridSpacing(int)
public boolean isGridRoutingEnabled()
setGridRoutingEnabled(boolean)
public void setGridOrigin(int x, int y)
(0, 0)
is set.
setGridRoutingEnabled(boolean)
public YPoint getGridOrigin()
setGridOrigin(int,int)
public void setGridSpacing(int spacing)
2
is set,
which is also the minimum allowed spacing.
spacing
- Integral value that determines the desired grid spacing. Positive values less than 2 are ignored,
negative values are mapped to their absolute.setGridRoutingEnabled(boolean)
public int getGridSpacing()
setGridSpacing(int)
public void setMinimumDistance(int dist)
4
is set, which is also the
minimum allowed distance.
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.
setCoupledDistances(boolean)
,
setMinimumDistanceToNode(int)
public int getMinimumDistance()
setMinimumDistance(int)
public void setCoupledDistances(boolean coupled)
By default the minimum distances are coupled.
setMinimumDistance(int)
,
setMinimumDistanceToNode(int)
public boolean getCoupledDistances()
setCoupledDistances(boolean)
public void setMinimumDistanceToNode(int dist)
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.
setCoupledDistances(boolean)
,
setMinimumDistance(int)
public int getMinimumDistanceToNode()
setMinimumDistanceToNode(int)
public void setLocalCrossingMinimizationEnabled(boolean enabled)
public boolean isLocalCrossingMinimizationEnabled()
setLocalCrossingMinimizationEnabled(boolean)
public void setCenterToSpaceRatio(double csr)
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
.public double getCenterToSpaceRatio()
setCenterToSpaceRatio(double)
public void setRoutingStyle(byte style)
STYLE_BALANCED
.
style
- One of STYLE_BALANCED
, STYLE_ADHOC
, STYLE_SHORTPATH
, and
STYLE_PREFERMIDDLE
.public byte getRoutingStyle()
setRoutingStyle(byte)
public void setBadOrthogonal(boolean value)
Default setting is true
.
public boolean getBadOrthogonal()
setBadOrthogonal(boolean)
public void setCustomBorderCapacityEnabled(boolean value)
Default setting is false
.
setCustomBorderCapacity(int)
public boolean getCustomBorderCapacityEnabled()
setCustomBorderCapacityEnabled(boolean)
,
setCustomBorderCapacity(int)
public void setCustomBorderCapacity(int value)
public int getCustomBorderCapacity()
setCustomBorderCapacity(int)
public void setInnerPortsEnabled(boolean value)
Default setting is false
.
public boolean isInnerPortsEnabled()
setInnerPortsEnabled(boolean)
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |