|
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.OrthogonalPatternEdgeRouter
public class OrthogonalPatternEdgeRouter
OrthogonalPatternEdgeRouter
routes edges orthogonally such that the resulting layout of the edges consists only
of vertical and horizontal segments.
Note that the location and size of the nodes in a diagram remains unchanged.
The edge router will not try to find a perfect route from source to edge (unlike to what
EdgeRouter
does) but chooses the best path out of a set of fixed paths. The best
path out of these possible paths is determined by its cost. The costs may be influenced by setting several cost
factors. The distance that an edge will have from its source and target node is determined by
setMinimumDistance(double)
.
The edges whose paths have to be routed can be defined registering a DataProvider
with key
AFFECTED_EDGES
.
Field Summary | |
---|---|
static java.lang.Object |
AFFECTED_EDGES
A DataProvider key for determining which edges are routed.
|
static byte |
MONOTONIC_BOTH
A monotonic path restriction specifier that describes restrictions for the horizontal and vertical direction. |
static byte |
MONOTONIC_HORIZONTAL
A monotonic path restriction specifier that describes restrictions for the horizontal direction. |
static byte |
MONOTONIC_NONE
A monotonic path restriction specifier that describes no restrictions for edges. |
static byte |
MONOTONIC_VERTICAL
A monotonic path restriction specifier that describes restrictions for the vertical direction. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
OrthogonalPatternEdgeRouter()
Creates a new instance of OrthogonalPatternEdgeRouter with default settings. |
Method Summary | |
---|---|
protected double |
calculateBendCost(Edge edge,
YList path,
PortCandidate spc,
PortCandidate tpc)
Calculates the costs for all bends of the given path. |
protected double |
calculateCost(Edge edge,
YList path,
PortCandidate spc,
PortCandidate tpc)
Calculates the edge cost of a possible edge path, in order to determine which path is the best, i.e., the cheapest. |
protected double |
calculateCrossingCosts(Edge edge,
YList path,
PortCandidate spc,
PortCandidate tpc)
Calculates the overall crossing costs of the given path, including edge crossings, edge overlaps and node crossings. |
protected double |
calculateEdgeLength(Edge edge,
YList path,
PortCandidate spc,
PortCandidate tpc)
Calculates the costs for the length of the given path. |
protected double |
calculatePortCandidateCost(Edge edge,
YList path,
PortCandidate spc,
PortCandidate tpc)
Calculates the costs for the chosen PortCandidate s. |
protected double |
calculateSelfLoopSelfSidePenaltyCost(Edge edge,
YList path,
PortCandidate spc,
PortCandidate tpc)
Calculates the extra penalty that is added to the path's cost if the edge is a self-loop and source and target ports have the same direction. |
boolean |
canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm . |
protected void |
checkGroupNodeSize(GraphLayout layout,
java.lang.Object node)
Checks the given group node for zero or negative width/height. |
protected void |
checkNodeSize(GraphLayout layout,
java.lang.Object node)
Checks the given node for zero or negative width/height. |
void |
doLayout(LayoutGraph graph)
Routes the edges of the given graph orthogonally. |
java.lang.Object |
getAffectedEdgesDPKey()
Returns the key to register a DataProvider which determines the edges that shall be routed by this
algorithm. |
double |
getBendCost()
Returns the costs for creating a bend on the edge's path. |
double |
getEdgeCrossingCost()
Returns the costs for a crossing between two edges. |
double |
getEdgeOverlapCost()
Returns the costs for overlapping edge paths. |
YPoint |
getGridOrigin()
Returns the origin of the grid. |
double |
getGridWidth()
Returns the spacing of the grid on which edges are routed. |
double |
getMinimumDistance()
Returns the minimum distance that an edge will maintain from its source and target node. |
byte |
getMonotonicPathRestriction()
Returns the monotonic path restriction that should be applied. |
double |
getNodeCrossingCost()
Returns the costs for edges that cross nodes. |
boolean |
isGridRoutingEnabled()
Returns whether or not to route the edges on a grid. |
void |
setAffectedEdgesDPKey(java.lang.Object key)
Specifies the key to register a DataProvider which determines the edges that shall be routed by this
algorithm. |
void |
setBendCost(double bendCost)
Specifies the costs for creating a bend on the edge's path. |
void |
setEdgeCrossingCost(double edgeCrossingCost)
Specifies the costs for a crossing between two edges. |
void |
setEdgeOverlapCost(double edgeOverlapCost)
Specifies the costs for overlapping edge paths. |
void |
setGridOrigin(YPoint gridOrigin)
Specifies the origin of the grid. |
void |
setGridRoutingEnabled(boolean gridRoutingEnabled)
Specifies whether or not to route the edges on a grid. |
void |
setGridWidth(double gridSpacing)
Specifies the spacing of the grid on which edges are routed. |
void |
setMinimumDistance(double minDist)
Specifies the minimum distance that an edge will maintain from its source and target node. |
void |
setMonotonicPathRestriction(byte monotonicPathRestriction)
Specifies the monotonic path restriction that should be applied. |
void |
setNodeCrossingCost(double nodeCrossingCost)
Specifies the costs for edges that cross nodes. |
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 java.lang.Object AFFECTED_EDGES
DataProvider
key for determining which edges are routed.
public static final byte MONOTONIC_NONE
setMonotonicPathRestriction(byte)
,
Constant Field Valuespublic static final byte MONOTONIC_VERTICAL
Each vertical edge segment should be directed from the source to the target. Furthermore, each edge path starts and ends with a vertical segment.
setMonotonicPathRestriction(byte)
,
Constant Field Valuespublic static final byte MONOTONIC_HORIZONTAL
Each horizontal edge segment should be directed from the source to the target. Furthermore, each edge path starts and ends with a horizontal segment.
setMonotonicPathRestriction(byte)
,
Constant Field Valuespublic static final byte MONOTONIC_BOTH
Each horizontal as well as each vertical edge segment is directed from the source to the target.
setMonotonicPathRestriction(byte)
,
Constant Field ValuesConstructor Detail |
---|
public OrthogonalPatternEdgeRouter()
OrthogonalPatternEdgeRouter
with default settings.
Method Detail |
---|
public byte getMonotonicPathRestriction()
setMonotonicPathRestriction(byte)
public void setMonotonicPathRestriction(byte monotonicPathRestriction)
MONOTONIC_NONE
monotonicPathRestriction
- one of the valid monotonic path restrictions
java.lang.IllegalArgumentException
- if the specified path restriction is unknownpublic boolean canLayout(LayoutGraph graph)
core layout algorithm
.
If there is no core layout algorithm
, all graphs whose nodes have width and height
greater than 0
are accepted.
graph
- the input graph
true
if there is no core layout algorithm or the core layout algorithm accepts the graph,
false
otherwiseLayouter.doLayout(LayoutGraph)
public void doLayout(LayoutGraph graph)
graph
- the input graphLayouter.canLayout(LayoutGraph)
protected void checkNodeSize(GraphLayout layout, java.lang.Object node) throws java.lang.IllegalArgumentException
This method is called before the invocation of the core layouter for each normal node of the input graph. It may be overridden in order to obtain a custom implementation of node-size check or to remove it entirely.
layout
- the GraphLayout
instancenode
- the node object
java.lang.IllegalArgumentException
- if the width/height of the node object is zero or negativecheckGroupNodeSize(GraphLayout,Object)
,
canLayout(LayoutGraph)
,
doLayout(LayoutGraph)
protected void checkGroupNodeSize(GraphLayout layout, java.lang.Object node) throws java.lang.IllegalArgumentException
This method is called by doLayout(LayoutGraph)
for each group node of the input graph.
It may be overridden in order to obtain a custom implementation of group-node-size check or to remove it entirely.
layout
- the GraphLayout
instancenode
- the group node object
java.lang.IllegalArgumentException
- if the width/height of the group node object is zero or negativecheckNodeSize(GraphLayout,Object)
protected double calculateCost(Edge edge, YList path, PortCandidate spc, PortCandidate tpc)
This method is called by doLayout(LayoutGraph)
in order to decide which path is the best. The default
implementation considers the edge length, the number of bends, edge crossings, PortCandidate
s and
monotonic path restrictions. It may be overridden to apply a different set of costs or a different weighting.
edge
- the edge whose costs to calculatepath
- the edge's pathspc
- the source PortCandidate
for this edgetpc
- the target PortCandidate
for this edge
protected double calculatePortCandidateCost(Edge edge, YList path, PortCandidate spc, PortCandidate tpc)
PortCandidate
s.
This method is called by calculateCost(Edge, YList, PortCandidate, PortCandidate)
. The default
implementation will return the candidates' costs
. It may be
overridden to change the calculation of these costs.
edge
- the edge for which the costs are calculatedpath
- the path of the given edgespc
- the source PortCandidate
for this edgetpc
- the target PortCandidate
for this edge
PortCandidate
sprotected double calculateBendCost(Edge edge, YList path, PortCandidate spc, PortCandidate tpc)
This method is called by calculateCost(Edge, YList, PortCandidate, PortCandidate)
. The default
implementation multiplies the number of bends with the according costs
. It may be
overridden to change the calculation of these costs.
edge
- the edge for which the costs are calculatedpath
- the path of the given edgespc
- the source PortCandidate
for this edgetpc
- the target PortCandidate
for this edge
protected double calculateSelfLoopSelfSidePenaltyCost(Edge edge, YList path, PortCandidate spc, PortCandidate tpc)
This method is called by calculateCost(Edge, YList, PortCandidate, PortCandidate)
. The default
implementation adds costs for another bend if source and target ports share the same node side. In this manner, paths
with different source and target directions are cheaper and thus preferred. The method may be overridden to
change the calculation of this penalty.
edge
- the edge for which the costs are calculatedpath
- the path of the given edgespc
- the source PortCandidate
for this edgetpc
- the target PortCandidate
for this edge
protected double calculateEdgeLength(Edge edge, YList path, PortCandidate spc, PortCandidate tpc)
This method is called by calculateCost(Edge, YList, PortCandidate, PortCandidate)
. The default
implementation returns costs between 0
for short paths and 1
for long paths. Hence, it
has relatively little impact on the overall costs. The method may be overridden to introduce a different
weighting of the edge length.
edge
- the edge for which the costs are calculatedpath
- the path of the given edgespc
- the source PortCandidate
for this edgetpc
- the target PortCandidate
for this edge
protected double calculateCrossingCosts(Edge edge, YList path, PortCandidate spc, PortCandidate tpc)
This method is called by calculateCost(Edge, YList, PortCandidate, PortCandidate)
. The default
implementation will determine overlaps and crossings between edge segments and nodes and sum up the costs. It may
be overridden to use a different combination of costs.
edge
- the edge for which the costs are calculatedpath
- the path of the given edgespc
- the source PortCandidate
for this edgetpc
- the target PortCandidate
for this edge
public void setAffectedEdgesDPKey(java.lang.Object key)
DataProvider
which determines the edges that shall be routed by this
algorithm.
AFFECTED_EDGES
key
- the key to register a DataProvider
which determines the edges to be routed
java.lang.IllegalArgumentException
- if the specified DataProvider
key is null
public java.lang.Object getAffectedEdgesDPKey()
DataProvider
which determines the edges that shall be routed by this
algorithm.
DataProvider
which determines the edges to be routedsetAffectedEdgesDPKey(Object)
public void setMinimumDistance(double minDist)
The distance needs to be non-negative.
minDist
- the minimum distance between the edge and its source and target node
java.lang.IllegalArgumentException
- if the specified distance is negativepublic double getMinimumDistance()
The distance needs to be non-negative.
setMinimumDistance(double)
public void setGridWidth(double gridSpacing)
The spacing between two grid lines must be at least 2
.
grid routing is enabled
.gridSpacing
- the spacing between two grid lines
java.lang.IllegalArgumentException
- if the specified grid spacing is less than 2
setGridRoutingEnabled(boolean)
public double getGridWidth()
The spacing between two grid lines must be at least 2
.
grid routing is enabled
.setGridWidth(double)
,
setGridRoutingEnabled(boolean)
public void setGridOrigin(YPoint gridOrigin)
minimum distance
. Thus, it is
possible that edges are not routed on the grid if there is not enough space between two borders.grid routing is enabled
.YPoint.ORIGIN
gridOrigin
- the origin of the grid
java.lang.IllegalArgumentException
- if the specified point is null
setGridRoutingEnabled(boolean)
public YPoint getGridOrigin()
minimum distance
. Thus, it is
possible that edges are not routed on the grid if there is not enough space between two borders.grid routing is enabled
.setGridOrigin(YPoint)
,
setGridRoutingEnabled(boolean)
public void setGridRoutingEnabled(boolean gridRoutingEnabled)
The grid can be defined using methods setGridOrigin(YPoint)
and setGridWidth(double)
.
PortConstraint
s or assign
coordinates that already lie on the grid for these ports if grid routing is desired.gridRoutingEnabled
- true
if edges should be routed on grid, false
otherwisepublic boolean isGridRoutingEnabled()
The grid can be defined using methods setGridOrigin(YPoint)
and setGridWidth(double)
.
PortConstraint
s or assign
coordinates that already lie on the grid for these ports if grid routing is desired.true
if edges are routed on grid, false
otherwisesetGridRoutingEnabled(boolean)
,
setGridOrigin(YPoint)
,
setGridWidth(double)
public void setEdgeCrossingCost(double edgeCrossingCost)
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
edgeCrossingCost
- the costs for an edge crossing
java.lang.IllegalArgumentException
- if the specified costs are negativepublic double getEdgeCrossingCost()
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
setEdgeCrossingCost(double)
public double getNodeCrossingCost()
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
setNodeCrossingCost(double)
public void setNodeCrossingCost(double nodeCrossingCost)
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
nodeCrossingCost
- the costs for edges crossing nodes
java.lang.IllegalArgumentException
- if the specified costs are negativepublic void setBendCost(double bendCost)
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
bendCost
- the costs for edges crossing nodes
java.lang.IllegalArgumentException
- if the specified costs are negativepublic double getBendCost()
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
setBendCost(double)
public double getEdgeOverlapCost()
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
OrthogonalPatternEdgeRouter
is used stand-alone, one can determine a higher cost to
prevent edge overlaps.OrthogonalPatternEdgeRouter
is used in conjunction with a
OrthogonalSegmentDistributionStage
. Hence, edge overlaps are desired and thus should not cause any
costs.setEdgeOverlapCost(double)
public void setEdgeOverlapCost(double edgeOverlapCost)
These costs are used for finding the best path out of the predefined paths from which the router can choose.
The costs need to be non-negative.
OrthogonalPatternEdgeRouter
is used stand-alone, one can determine a higher cost to
prevent edge overlaps.OrthogonalPatternEdgeRouter
is used in conjunction with a
OrthogonalSegmentDistributionStage
. Hence, edge overlaps are desired and thus should not cause any
costs.edgeOverlapCost
- the costs for overlapping edge segments
java.lang.IllegalArgumentException
- if the specified costs are negative
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |