|
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 orthogonal bus-style edge routing algorithm which combines the large number of edges of complete subgraphs in a concise, tree-like structure that consists of vertical and horizontal line segments. A complete (sub)graph is a set of nodes, in which each node is connected to every other node. The positions of the nodes in a graph are not altered by this algorithm.
In a drawing of this algorithm, each edge path is orthogonal and 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. Besides these strict requirements, the algorithm aims to find routes where shared paths of edges with different end-nodes are drawn on top of each other and form long straight lines, so-called backbone segments. From these backbone segments, short connections of grouped edges branch off to each node (bus connections).
This routing algorithm uses a two-phase process. First, in backbone selection, a set of good initial backbone segments is determined. In routing and recombination, each initial backbone segment is connected to all others and also to each node by using orthogonal edge paths. Then, the set of resulting structures is reduced to the most optimal structure where backbone segments are long and connections to the nodes are short. Note that the calculated paths can join before reaching an initial backbone segment and, thus, establish additional backbone segments. Contrariwise, initial backbone segments of low overall profit are discarded and connections to them are rerouted to other backbone segments.
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 data provider holding bus descriptor objects is expected to be registered
with the graph using the EDGE_DESCRIPTOR_DPKEY
look-up key. In the absence of an individual bus ID for an
edge, a bus consisting only of the single edge is created. Additionally, a bus descriptors allows to mark its
associated edge as fixed or movable, which is required for incremental routing, and to specify an optional group ID
for an edge's source end and target end, respectively.
Incremental routing means extending or updating an already existing bus-style representation. This can be used to
rearrange existing edges or to include additional edges in an existing bus. The paths of edges not marked as fixed by
their associated BusDescriptor
are calculated anew. The structure induced by the
fixed edges must be orthogonal and cycle-free.
Field Summary | |
---|---|
static Object |
EDGE_DESCRIPTOR_DPKEY
DataProvider key used to store the BusDescriptor of every edge. |
static Object |
EDGE_SUBSET_DPKEY
DataProvider key used for specifying the edge subset to be laid out. |
static byte |
SCOPE_ALL
Scope constant - used for routing all edges in the graph. |
static byte |
SCOPE_SUBSET
Scope constant - used for routing only a subset of edges. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
BusRouter()
Creates a new instance of BusRouter . |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Returns true if the specified graph can be routed by this algorithm. |
protected OrthogonalEdgeRouter |
createOrthogonalEdgeRouter()
Factory method that creates an appropriate OrthogonalEdgeRouter implementation. |
void |
doLayout(LayoutGraph graph)
Calculates a new bus layout for the specified graph. |
double |
getCrossingCost()
Returns the cost for each edge crossing of a routed path. |
int |
getGridSpacing()
Returns the grid spacing that is used when grid routing is enabled. |
double |
getMinimumBackboneSegmentLength()
Returns the preferred minimum length of a backbone segment. |
int |
getMinimumBusConnectionsCount()
Returns the minimum number of bus connections each backbone segment must have. |
int |
getMinimumDistanceToEdge()
Returns the minimum distance between edge segments. |
int |
getMinimumDistanceToNode()
Returns the minimum distance between edge segments and nodes. |
int |
getPreferredBackboneSegmentCount()
Returns the preferred number of backbone segments with the same orientation. |
byte |
getScope()
Returns the scope set for this router. |
Object |
getSelectedEdgesDpKey()
Returns the DataProvider key to mark edges as selected. |
boolean |
isGridRoutingEnabled()
Returns whether or not to route edge segments on grid lines. |
boolean |
isRemovingCollinearBends()
Returns whether or not collinear bends are removed from the layout. |
boolean |
isReroutingEnabled()
Returns whether rerouting of edges with many crossings is enabled. |
void |
setCrossingCost(double cost)
Sets the cost for each edge crossing of a routed path. |
void |
setGridRoutingEnabled(boolean enabled)
Specifies whether or not to route edge segments on grid lines only. |
void |
setGridSpacing(int spacing)
Sets the grid spacing that is used when grid routing is enabled. |
void |
setMinimumBackboneSegmentLength(double minimumLength)
Sets the preferred minimum length of a backbone segment. |
void |
setMinimumBusConnectionsCount(int minimumCount)
Sets the minimum number of bus connections a backbone segment must have. |
void |
setMinimumDistanceToEdge(int dist)
Sets the minimum distance between edge segments. |
void |
setMinimumDistanceToNode(int dist)
Sets the minimum distance between edge segments and nodes. |
void |
setPreferredBackboneSegmentCount(int preferredCount)
Sets the maximal number of selected backbone segments with the same orientation. |
boolean |
setProperty(String key,
Object value)
Provides access to implementation specific properties of the algorithms used internally. |
void |
setRemovingCollinearBends(boolean removingCollinearBends)
Specifies whether or not collinear bends are removed from the layout. |
void |
setReroutingEnabled(boolean enabled)
Specifies whether or not to enable a further crossing minimization optimization based on rerouting edges that cross many edges. |
void |
setScope(byte scope)
Sets the scope for this router. |
void |
setSelectedEdgesDpKey(Object key)
Specifies the DataProvider key to mark 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
setScope(byte)
,
Constant Field Valuespublic static final byte SCOPE_SUBSET
DataProvider
.
EDGE_SUBSET_DPKEY
,
setScope(byte)
,
setSelectedEdgesDpKey(Object)
,
Constant Field Valuespublic static final Object EDGE_DESCRIPTOR_DPKEY
DataProvider
key used to store the BusDescriptor
of every edge. A bus descriptor provides the
edge's bus ID, its optional group IDs and whether or not the edge is fixed.
public static final Object EDGE_SUBSET_DPKEY
DataProvider
key used for specifying the edge subset to be laid out. This key is used if no custom key is
set. The algorithm expects for each edge in the graph to find a boolean
that
indicates whether the node belongs to the scope.
setScope(byte)
,
setSelectedEdgesDpKey(Object)
Constructor Detail |
---|
public BusRouter()
BusRouter
.
Method Detail |
---|
protected OrthogonalEdgeRouter createOrthogonalEdgeRouter()
public boolean canLayout(LayoutGraph graph)
true
if the specified graph can be routed by this algorithm. Calling doLayout(y.layout.LayoutGraph)
with
the specified graph as its argument will only succeed if this method returns true
.
If there is no fixed edge in the graph, routing is always possible. Otherwise, the route of each fixed edge must be
orthogonal.
public void doLayout(LayoutGraph graph)
graph
- the graph to lay outpublic void setGridSpacing(int spacing)
10
is set.
spacing
- determines the desired grid spacing. Positive values less than 2
are ignored, negative
values are mapped to their absolute.getGridSpacing()
,
setGridRoutingEnabled(boolean)
,
OrthogonalEdgeRouter.setGridSpacing(int)
public int getGridSpacing()
setGridSpacing(int)
,
OrthogonalEdgeRouter.getGridSpacing()
public void setGridRoutingEnabled(boolean enabled)
enabled
- specifies whether this feature is enabled or notisGridRoutingEnabled()
,
OrthogonalEdgeRouter.setGridRoutingEnabled(boolean)
public boolean isGridRoutingEnabled()
setGridRoutingEnabled(boolean)
,
OrthogonalEdgeRouter.isGridRoutingEnabled()
public void setMinimumDistanceToNode(int dist)
10
is set.
dist
- determines the desired distance. Positive values less than 2
are ignored, negative values
are mapped to their absolute.getMinimumDistanceToNode()
,
OrthogonalEdgeRouter.setMinimumDistanceToNode(int)
public int getMinimumDistanceToNode()
setMinimumDistanceToNode(int)
,
OrthogonalEdgeRouter.getMinimumDistanceToNode()
public void setMinimumDistanceToEdge(int dist)
5
is set.
dist
- determines the desired distance. Positive values less than 4
are ignored, negative values
are mapped to their absolute.getMinimumDistanceToEdge()
,
OrthogonalEdgeRouter.setMinimumDistance(int)
public int getMinimumDistanceToEdge()
setMinimumDistanceToEdge(int)
,
OrthogonalEdgeRouter.getMinimumDistance()
public void setCrossingCost(double cost)
n
means that a path rather changes
direction n
times than crossing the path of an edge. If the cost is set to 0.0
, 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.0
and 3.0
. By default, a cost of 1.0
is set.
This setting is taken into account only in the routing and recombination phase and does not affect the selection of
the initial backbone segments.
cost
- the cost for each edge crossinggetCrossingCost()
public double getCrossingCost()
setCrossingCost(double)
public void setReroutingEnabled(boolean enabled)
0.0
.
This setting is taken into account only in the routing and recombination phase and does not affect the selection of
the initial backbone segments.
enabled
- specifies whether this feature is enabled or notsetCrossingCost(double)
,
isReroutingEnabled()
,
OrthogonalEdgeRouter.setReroutingEnabled(boolean)
public boolean isReroutingEnabled()
true
if rerouting of specific edges is enabled.setCrossingCost(double)
,
setReroutingEnabled(boolean)
,
OrthogonalEdgeRouter.isReroutingEnabled()
public int getPreferredBackboneSegmentCount()
setPreferredBackboneSegmentCount(int)
public void setPreferredBackboneSegmentCount(int preferredCount)
2
is set.
This count 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.
preferredCount
- the maximal number of backbone candidates with the same orientationgetPreferredBackboneSegmentCount()
public double getMinimumBackboneSegmentLength()
setMinimumBackboneSegmentLength(double)
public void setMinimumBackboneSegmentLength(double minimumLength)
100.0
is set.
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.
minimumLength
- the preferred minimum length of a backbone segmentgetMinimumBackboneSegmentLength()
public int getMinimumBusConnectionsCount()
setMinimumBusConnectionsCount(int)
public void setMinimumBusConnectionsCount(int minimumCount)
3
is set.
This setting is taken into account only in the routing and recombination phase and does not affect the selection of
the initial backbone segments.
minimumCount
- the minimum number of bus connections each backbone segment must havegetMinimumBusConnectionsCount()
public boolean isRemovingCollinearBends()
setRemovingCollinearBends(boolean)
public void setRemovingCollinearBends(boolean removingCollinearBends)
removingCollinearBends
- whether this feature is activatedisRemovingCollinearBends()
public Object getSelectedEdgesDpKey()
DataProvider
key to mark edges as selected. By default, EDGE_SUBSET_DPKEY
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, EDGE_SUBSET_DPKEY
is used.
IllegalArgumentException
- if the specified key is null
.key
- the DataProvider
key.getSelectedEdgesDpKey()
public byte getScope()
SCOPE_ALL
or SCOPE_SUBSET
setScope(byte)
public void setScope(byte scope)
SCOPE_ALL
.
scope
- the new scope, should be one of SCOPE_ALL
or SCOPE_SUBSET
getScope()
public boolean setProperty(String key, Object value)
key
- the key to a propertyvalue
- the value to associate with the key
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |