|
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.BusRouter
public class BusRouter
An edge routing algorithm which routes edges of a graph in an orthogonal bus-style.
Carefully observe that the resulting bus representation, with many edge segments drawn on top of each other, leaves little room for a sensible interpretation of edge direction.
Note that class EdgeRouter
offers a newer, improved bus-style support
(also see BusDescriptor
) and it is recommended to use this instead.
Edge segments are bundled to buses. A bus is a segment shared by multiple edges to which shorter segments that connect to actual nodes are attached. Buses and all other segments are routed orthogonally.
A bus can, for example, be created in parts of a diagram where each node is connected to each other node. There are no cycles induced by any two edge paths of the same bus, that is, the combination of all edge routes looks like an orthogonal tree.
The algorithm tries to produce routes where the edges share as much of their paths as possible. It yields long line segments (so-called backbone segments) where ideally all but the first and last segments of all edge paths are drawn on top of each other (forming a bus), with short connections branching off to the nodes (bus connections). These short connections bundle the respective first or last segments of a node's incident edges.
This algorithm will not modify positions or sizes of nodes in any way, but will route the edges of the graph.
Bus-style edge routing with default settings
Edge routing sample including four different buses
The algorithm uses a two-phase process:
To determine which edges belong to a common bus, a mapping that assigns a bus ID to each edge must be specified
using BusDescriptor
s. A DataProvider
holding BusDescriptor
instances is expected to be
registered with the graph using the descriptor key
.
In the absence of an individual bus ID for an edge, a bus consisting only of the single edge is created.
This algorithm supports PortConstraint
s as well as PortCandidate
s to control
where edges should connect to nodes.
Note that if edges of the same bus connect to a common node but have inconsistent or contradicting port constraints/candidates, then any of these constraints/candidates can determine the actual location of the common port. The same applies for edges that, in addition, belong to the same edge group.
Also, the cardinality defined with a PortCandidateSet
object is interpreted in terms of
different bus IDs (group IDs) instead of number of edges.
This algorithm supports incremental edge routing, that is, extending or updating an already existing
bus-style representation. This is useful to rearrange existing edges or to include additional edges in
an existing bus.
Incremental routing is supported by denoting so-called fixed edges using the
corresponding BusDescriptor property
.
The paths of edges which are not marked as fixed are calculated by the algorithm.
The structure induced by the fixed edges must be orthogonal and cycle-free.
Field Summary | |
---|---|
static java.lang.Object |
EDGE_DESCRIPTOR_DPKEY
A DataProvider key for specifying a bus descriptor object for each edge
The BusDescriptor for an edge provides the edge's bus ID, its optional group IDs and whether
or not the edge is fixed. |
static java.lang.Object |
EDGE_SUBSET_DPKEY
A DataProvider key for specifying the edge subset to be routed
This key is used if no custom key for specifying the subset is defined using
setSelectedEdgesDpKey(Object) . |
static byte |
SCOPE_ALL
A scope specifier which defines that all edges of the input graph will be routed. |
static byte |
SCOPE_SUBSET
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 | |
---|---|
BusRouter()
Creates a new instance of BusRouter with default settings. |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm . |
protected OrthogonalEdgeRouter |
createOrthogonalEdgeRouter()
Creates a configured instance of OrthogonalEdgeRouter that is used for orthogonal routing of edges. |
void |
doLayout(LayoutGraph graph)
Calculates bus-like routes for the edges in the given input graph. |
double |
getCrossingCost()
Returns the cost for each edge crossing. |
int |
getGridSpacing()
Returns the equidistant spacing between the horizontal and vertical grid lines. |
double |
getMinimumBackboneSegmentLength()
Returns the preferred minimum length of a backbone segment. |
int |
getMinimumBusConnectionsCount()
Returns the minimum number of bus connections a backbone segment must have. |
int |
getMinimumDistanceToEdge()
Returns the minimum distance between any two edge segments. |
int |
getMinimumDistanceToNode()
Returns the minimum distance between edge segments and nodes. |
int |
getPreferredBackboneSegmentCount()
Returns the maximum number of selected backbone segments with the same orientation. |
byte |
getScope()
Returns the scope for this routing algorithm that determines which edges are routed. |
java.lang.Object |
getSelectedEdgesDpKey()
Returns the key to register a DataProvider for marking edges as selected. |
boolean |
isGridRoutingEnabled()
Specifies whether or not to route edge segments on grid lines only. |
boolean |
isRemovingCollinearBends()
Specifies whether or not collinear bends are removed from the layout. |
boolean |
isReroutingEnabled()
Specifies whether or not to perform an additional step to reroute the edges such that the number of edge crossings is reduced. |
void |
setCrossingCost(double cost)
Specifies the cost for each edge crossing. |
void |
setGridRoutingEnabled(boolean enabled)
Specifies whether or not to route edge segments on grid lines only. |
void |
setGridSpacing(int spacing)
Specifies the equidistant spacing between the horizontal and vertical grid lines. |
void |
setMinimumBackboneSegmentLength(double minimumLength)
Specifies the preferred minimum length of a backbone segment. |
void |
setMinimumBusConnectionsCount(int minimumCount)
Specifies the minimum number of bus connections a backbone segment must have. |
void |
setMinimumDistanceToEdge(int dist)
Sets the minimum distance between any two edge segments. |
void |
setMinimumDistanceToNode(int dist)
Sets the minimum distance between edge segments and nodes. |
void |
setPreferredBackboneSegmentCount(int preferredCount)
Specifies the maximum number of selected backbone segments with the same orientation. |
boolean |
setProperty(java.lang.String key,
java.lang.Object value)
Provides access to implementation-specific properties used for internal purposes only. |
void |
setRemovingCollinearBends(boolean removingCollinearBends)
Specifies whether or not collinear bends are removed from the layout. |
void |
setReroutingEnabled(boolean enabled)
Specifies whether or not to perform an additional step to reroute the edges such that the number of edge crossings is reduced. |
void |
setScope(byte scope)
Sets the scope for this routing algorithm that determines which edges are routed. |
void |
setSelectedEdgesDpKey(java.lang.Object key)
Specifies the key to register a DataProvider for marking edges as selected. |
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 SCOPE_ALL
public static final byte SCOPE_SUBSET
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.
public static final java.lang.Object EDGE_DESCRIPTOR_DPKEY
DataProvider
key for specifying a bus descriptor object for each edge
The BusDescriptor
for an edge provides the edge's bus ID, its optional group IDs and whether
or not the edge is fixed.
public static final java.lang.Object EDGE_SUBSET_DPKEY
DataProvider
key for specifying the edge subset to be routed
This key is used if no custom key for specifying the subset is defined using
setSelectedEdgesDpKey(Object)
.
SCOPE_SUBSET
.setScope(byte)
,
setSelectedEdgesDpKey(Object)
Constructor Detail |
---|
public BusRouter()
BusRouter
with default settings.
Method Detail |
---|
protected OrthogonalEdgeRouter createOrthogonalEdgeRouter()
OrthogonalEdgeRouter
that is used for orthogonal routing of edges.
This method is called when initializing the BusRouter
itself.
It may be overridden to create a custom implementation
or different settings for the internal routing algorithm.
OrthogonalEdgeRouter
, for example, setCrossingCost(double)
or setGridRoutingEnabled(boolean)
. Therefore, the defaults of properties of the BusRouter
will change when overriding this method and creating an OrthogonalEdgeRouter
with
different initial settings.OrthogonalEdgeRouter
instancepublic boolean canLayout(LayoutGraph graph)
core layout algorithm
.
If there is no core layout algorithm
, all graphs 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)
public void setGridSpacing(int spacing)
Positive values greater than 2
are allowed. Positive values less than 2
are ignored,
while negative values are mapped to their absolute value.
public int getGridSpacing()
Positive values greater than 2
are allowed. Positive values less than 2
are ignored,
while negative values are mapped to their absolute value.
grid routing
is enabled.setGridSpacing(int)
,
setGridRoutingEnabled(boolean)
public void setGridRoutingEnabled(boolean enabled)
setGridSpacing(int)
.enabled
- true
if edge segments should be routed on a grid, false
otherwisetrue - edge segments lie on the grid | false - edge segments are not aligned with the grid |
public boolean isGridRoutingEnabled()
setGridSpacing(int)
.true
if edge segments are routed on a grid, false
otherwisesetGridRoutingEnabled(boolean)
public void setMinimumDistanceToNode(int dist)
Positive values greater than 2
are allowed. Positive values less than 2
are ignored,
while negative values are mapped to their absolutes.
dist
- the minimum distance between edges and nodes10 - edges are placed in between the highlighted nodes, the minimum distance is not violated | 30 - edges do not fit in between the highlighted nodes, as this would violate the minimum distance |
public int getMinimumDistanceToNode()
Positive values greater than 2
are allowed. Positive values less than 2
are ignored,
while negative values are mapped to their absolutes.
setMinimumDistanceToNode(int)
public void setMinimumDistanceToEdge(int dist)
The edge routing algorithm adheres to this value if possible, but reduces the distance value selectively, i.e., only for a currently processed edge, when there is not enough space to find a path with the proper value.
Positive values greater than 4
are allowed. Positive values less than 4
are ignored,
while negative values are mapped to their absolute values.
public int getMinimumDistanceToEdge()
The edge routing algorithm to this value if possible, but reduces the distance value selectively, i.e., only for a currently processed edge, when there is not enough space to find a path with the proper value.
Positive values greater than 4
are allowed. Positive values less than 4
are ignored,
while negative values are mapped to their absolute values.
setMinimumDistanceToEdge(int)
public void setCrossingCost(double cost)
A cost value of n
means that it is more profitable for a path to change its
direction n
times rather than crossing the path of an edge. If the cost value is set to
0.0
, no global crossing optimization is performed.
The cost is defined to be a non-negative value.
1.0
and 3.0
.cost
- the non-negative cost value for each crossing
java.lang.IllegalArgumentException
- if the given cost value is negative3.0 - results in 1 crossing | 0.0 - results in 5 crossings |
public double getCrossingCost()
A cost value of n
means that it is more profitable for a path to change its
direction n
times rather than crossing the path of an edge. If the cost value is set to
0.0
, no global crossing optimization is performed.
The cost is defined to be a non-negative value.
1.0
and 3.0
.setCrossingCost(double)
public void setReroutingEnabled(boolean enabled)
This features does not guarantee that the number of crossings will be the minimal.
0.0
is assigned to the
crossing cost
.enabled
- true
if the rerouting feature should be enabled, false
otherwisesetCrossingCost(double)
public boolean isReroutingEnabled()
This features does not guarantee that the number of crossings will be the minimal.
0.0
is assigned to the
crossing cost
.true
if the rerouting feature is enabled, false
otherwisesetReroutingEnabled(boolean)
public int getPreferredBackboneSegmentCount()
This setting defines the number of backbone segments of the same orientation which are computed by the backbone selection phase. The final number of backbone segments may be different due to changes in the routing and recombination phase.
The number must be a value greater than or equal to 1
.
setPreferredBackboneSegmentCount(int)
public void setPreferredBackboneSegmentCount(int preferredCount)
This setting defines the number of backbone segments of the same orientation which are computed by the backbone selection phase. The final number of backbone segments may be different due to changes in the routing and recombination phase.
The number must be a value greater than or equal to 1
.
preferredCount
- the maximum number of backbone candidates with the same orientation
java.lang.IllegalArgumentException
- if the given preferred number is smaller than 1
1 - resulting backbones are highlighted | 2 - resulting backbones are highlighted |
public double getMinimumBackboneSegmentLength()
This number defines the minimum length of backbone segments which are computed by the backbone selection phase. Some of the final backbone segments may be shorter due to changes in the routing and recombination phase.
The minimum length is defined to be a value greater than or equal to 1.0
.
bounding box
.setMinimumBackboneSegmentLength(double)
public void setMinimumBackboneSegmentLength(double minimumLength)
This number defines the minimum length of backbone segments which are computed by the backbone selection phase. Some of the final backbone segments may be shorter due to changes in the routing and recombination phase.
The minimum length is defined to be a value greater than or equal to 1.0
.
bounding box
.minimumLength
- the preferred minimum length of a backbone segment
java.lang.IllegalArgumentException
- if the given minimum length is smaller than 1.0
100.0 | 300.0 |
public int getMinimumBusConnectionsCount()
If a backbone segment has less connections, it is removed and the affected nodes connect to another backbone segment.
The minimum connection count must be a value greater than or equal to 1
.
3
or 4
is a good choice for small graphs.
For larger graphs a much larger count can be reasonable.setMinimumBusConnectionsCount(int)
public void setMinimumBusConnectionsCount(int minimumCount)
If a backbone segment has less connections, it is removed and the affected nodes connect to another backbone segment.
The minimum connection count must be a value greater than or equal to 1
.
3
or 4
is a good choice for small graphs.
For larger graphs a much larger count can be reasonable.minimumCount
- the minimum number of bus connections each backbone segment must have
java.lang.IllegalArgumentException
- if the given minimum count is smaller than 1
2 - results in two backbones (in this example) | 6 - results in a single backbone all nodes are connected to (in this example) |
public boolean isRemovingCollinearBends()
A collinear bend is a bend that lies on a common line with its predecessor bend and successor bend.
If an edge has a collinear bend, there is another edge which has a real bend at this point, i.e., the bend location is an intersection of the bus. Therefore, it may be advantageous for some applications to keep such bends.
true
if collinear bends are removed, false
otherwisesetRemovingCollinearBends(boolean)
public void setRemovingCollinearBends(boolean removingCollinearBends)
A collinear bend is a bend that lies on a common line with its predecessor bend and successor bend.
If an edge has a collinear bend, there is another edge which has a real bend at this point, i.e., the bend location is an intersection of the bus. Therefore, it may be advantageous for some applications to keep such bends.
removingCollinearBends
- true
if collinear bends should be removed, false
otherwisepublic java.lang.Object getSelectedEdgesDpKey()
DataProvider
for marking edges as selected.
If the scope
is set to SCOPE_SUBSET
, only the edges for which the registered
DataProvider
returns true
will be routed.
All other edges will be considered to have fixed routes.
DataProvider
key for edge selectionsetSelectedEdgesDpKey(Object)
public void setSelectedEdgesDpKey(java.lang.Object key)
DataProvider
for marking edges as selected.
If the scope
is set to SCOPE_SUBSET
, only the edges for which the registered
DataProvider
returns true
will be routed.
All other edges will be considered to have fixed routes.
EDGE_SUBSET_DPKEY
key
- the DataProvider
key for edge selection
java.lang.IllegalArgumentException
- if the specified key is null
getSelectedEdgesDpKey()
public byte getScope()
setScope(byte)
public void setScope(byte scope)
SCOPE_ALL
scope
- one of the predefined scope values
java.lang.IllegalArgumentException
- if an unknown scope is givenpublic boolean setProperty(java.lang.String key, java.lang.Object value)
key
- the key to a propertyvalue
- the value to associate with the key
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |