|
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.polyline.EdgeRouter
public class EdgeRouter
This class represents a polyline edge router which calculates an edge layout containing only straight segments. The router does not change the location or the size of the nodes in a diagram in any way.
setPolylineRoutingEnabled(boolean)
.
In both routing styles, edges can be grouped so they share common segments in the beginning or end of their routes.
PortConstraintKeys.SOURCE_GROUPID_KEY
(for source grouped edges) or PortConstraintKeys.TARGET_GROUPID_KEY
(for target grouped edges).
Many settings of the edge layout can be controlled individually for every edge using EdgeLayoutDescriptor
instances. So, if at the time of the invocation a DataProvider
instance is bound to the graph using the
EDGE_LAYOUT_DESCRIPTOR_DPKEY
key, the EdgeLayoutDescriptor
s provided for the individual edges
are used. Whenever no descriptor is provided for an edge, a default edge layout descriptor is used as fall-back
value. This edge layout descriptor can be obtained with getDefaultEdgeLayoutDescriptor()
.
EdgeRouter
coordinates all settings and steps that are needed to achieve a
polylinear or orthogonal edge routing. Partition
,
GraphPartition
, PartitionCell
).
Partition
(see: PathSearch
, Path
).
ChannelBasedPathRouting
).
for
Partition
or for PathSearch
, respectively. GraphPartitionExtension
s add obstacles which the PathSearch
will
consider. They also can add some information to PartitionCells
that, for example, specifies whether or
not the PartitionCell
belongs to a node. PathSearchExtension
s influence the
PathSearch
by adding costs for traversing specified PartitionCells
or narrowing their
intervals to allow a less expensive traversal of a PartitionCell
. For example, the
PathSearch
adds costs to a PartitionCell
that was marked as an obstacle that belongs to a
node, so the edge will avoid the node.
Field Summary | |
---|---|
static String |
EDGE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider key used to store the EdgeLayoutDescriptor for each edge. |
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. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
EdgeRouter()
Creates a new EdgeRouter instance. |
|
EdgeRouter(Layouter core)
Creates a new EdgeRouter instance with the given core Layouter. |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Returns true iff the given graph can be laid
out by this algorithm. |
protected void |
cleanupGraphPartition(GraphPartition partition)
Cleans up the given GraphPartition . |
protected void |
configureGraphPartition(GraphPartition partition)
Configures the given GraphPartition . |
protected void |
configurePathSearch(PathSearch pathSearch)
Configures the given PathSearch . |
protected PathSearchConfiguration |
createConfiguration(LayoutGraph graph,
Grouping grouping)
Creates the PathSearchConfiguration that is used during the path search. |
protected GraphPartition |
createGraphPartition(ObstaclePartition decomposition)
Creates a GraphPartition that divides the area of the graph into several rectangles. |
protected DynamicObstacleDecomposition |
createObstacleDecomposition()
Creates a DynamicObstacleDecomposition that is used by the GraphPartition to divide the graph
area in rectangles. |
protected ChannelBasedPathRouting |
createPathRouting()
Creates a ChannelBasedPathRouting that routes the edges using pre-calculated Path objects. |
protected PathSearch |
createPathSearch()
Creates a PathSearch that finds the edges' paths through the GraphPartition . |
protected PathSearchContext |
createPathSearchContext(PathSearch pathSearch,
PathSearchConfiguration configuration)
Creates a PathSearchContext that provides context information for the path search algorithm. |
void |
doLayout(LayoutGraph graph)
Main layout routine that assigns new layout information to the given graph. |
EdgeLayoutDescriptor |
getDefaultEdgeLayoutDescriptor()
Returns the EdgeLayoutDescriptor instance used for all those edges, that do not have a specific
layout descriptor assigned. |
protected EdgeLayoutDescriptor |
getEdgeLayoutDescriptor(Edge edge)
Returns the EdgeLayoutDescriptor provided by the DataProvider with the key
EDGE_LAYOUT_DESCRIPTOR_DPKEY for the given edge. |
Grid |
getGrid()
Returns the Grid the edge router tries to place the orthogonal segments on. |
long |
getMaximumDuration()
Returns the time limit (in milliseconds) set for the layout algorithm. |
double |
getMaximumPolylineSegmentRatio()
Returns the maximum segment length ratio at each end of an orthogonal segment that may get converted into a (non-orthogonal) polyline segment. |
double |
getMinimalNodeToEdgeDistance()
Determines the minimal distance between edges and node bounds. |
GraphPartition |
getPartition()
Returns the GraphPartition used during the layout. |
double |
getPreferredPolylineSegmentLength()
Returns the preferred length of (non-orthogonal) polyline segments. |
List |
getRegisteredPartitionExtensions()
Returns a list containing all registered GraphPartitionExtension s. |
List |
getRegisteredPathSearchExtensions()
Returns a list containing all registered PathSearchExtension s. |
Object |
getSelectedEdgesDpKey()
Returns the data provider key used to look up the selected state of the edges of the graph to be laid out. |
Object |
getSelectedNodesDpKey()
Returns the data provider key used to look up the selected state of the nodes of the graph to be laid out. |
byte |
getSphereOfAction()
Returns the currently set sphere of action specifier. |
boolean |
isConsiderEdgeLabelsEnabled()
Determines whether or not this edge router considers labels of edges that are not in the edge (sub-)set to be routed (see setSphereOfAction(byte) . |
boolean |
isConsiderNodeLabelsEnabled()
Determines whether or not this edge router considers node labels as obstacles for edge routes. |
boolean |
isPolylineRoutingEnabled()
Determines whether or not this edge router creates (non-orthogonal) polyline segments. |
boolean |
isReroutingEnabled()
Determines whether or not the edge router uses an additional step to reroute those edges that are considered to have the worst paths. |
void |
setConsiderEdgeLabelsEnabled(boolean considerEdgeLabelsEnabled)
Specifies whether or not this edge router considers labels of edges that are not in the edge (sub-)set to be routed (see setSphereOfAction(byte) . |
void |
setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
Specifies whether or not this edge router considers node labels as obstacles for edge routes. |
void |
setGrid(Grid grid)
Specifies the Grid on which orthogonal segments are placed. |
void |
setMaximumDuration(long maximumDuration)
Sets a preferred time limit (>= 0 and in milliseconds) for the layout algorithm. |
void |
setMaximumPolylineSegmentRatio(double maximumPolylineSegmentRatio)
Sets the maximum segment length ratio at each end of an orthogonal segment that may get converted into a (non-orthogonal) polyline segment. |
void |
setMinimalNodeToEdgeDistance(double minimalNodeToEdgeDistance)
Specifies the minimal distance between edges and node bounds. |
void |
setPolylineRoutingEnabled(boolean polylineRoutingEnabled)
Specifies whether or not this edge router creates (non-orthogonal) polyline segments. |
void |
setPreferredPolylineSegmentLength(double preferredPolylineSegmentLength)
Sets the preferred length of (non-orthogonal) polyline segments. |
void |
setReroutingEnabled(boolean reroutingEnabled)
Specifies whether or not the edge router uses an additional step to reroute those edges that are considered to have the worst paths. |
void |
setSelectedEdgesDpKey(Object selectedEdgesDpKey)
Specifies the data provider key used to look up the selected state of the edges of the graph to be laid out. |
void |
setSelectedNodesDpKey(Object key)
Specifies the data provider key used to look up the selected state of the nodes of the graph to be laid out. |
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 String EDGE_LAYOUT_DESCRIPTOR_DPKEY
DataProvider
key used to store the EdgeLayoutDescriptor
for each edge.
If there is no descriptor mapped for an edge, the default descriptor is used.
getDefaultEdgeLayoutDescriptor()
,
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 EdgeRouter(Layouter core)
public EdgeRouter()
Method Detail |
---|
public long getMaximumDuration()
setMaximumDuration(long)
public void setMaximumDuration(long maximumDuration)
Note that restricting the maximum duration may result in a worse layout quality. Furthermore, the actual runtime may exceed the maximum duration since the layout algorithm still has to find a valid solution.
maximumDuration
- the time limit.getMaximumDuration()
public EdgeLayoutDescriptor getDefaultEdgeLayoutDescriptor()
EdgeLayoutDescriptor
instance used for all those edges, that do not have a specific
layout descriptor assigned.
EDGE_LAYOUT_DESCRIPTOR_DPKEY
protected EdgeLayoutDescriptor getEdgeLayoutDescriptor(Edge edge)
EdgeLayoutDescriptor
provided by the DataProvider
with the key
EDGE_LAYOUT_DESCRIPTOR_DPKEY
for the given edge.
For all those edges, that do not have a specific layout descriptor assigned, the default descriptor is returned.
edge
- The edge to return the layout descriptor for.
EDGE_LAYOUT_DESCRIPTOR_DPKEY
,
getDefaultEdgeLayoutDescriptor()
public boolean isPolylineRoutingEnabled()
true
if this edge router creates (non-orthogonal) polyline segments, false
if
only orthogonal segments shall be used.getPreferredPolylineSegmentLength()
,
getMaximumPolylineSegmentRatio()
public void setPolylineRoutingEnabled(boolean polylineRoutingEnabled)
polylineRoutingEnabled
- true
if this edge router creates (non-orthogonal) polyline segments,
false
if only orthogonal segments shall be used.setPreferredPolylineSegmentLength(double)
,
setMaximumPolylineSegmentRatio(double)
public double getPreferredPolylineSegmentLength()
Note that this restriction isn't used for orthogonal segments.
isPolylineRoutingEnabled()
,
getMaximumPolylineSegmentRatio()
public void setPreferredPolylineSegmentLength(double preferredPolylineSegmentLength)
Note that this restriction isn't used for orthogonal segments.
preferredPolylineSegmentLength
- The preferred length of (non-orthogonal) polyline segments.setPolylineRoutingEnabled(boolean)
,
setMaximumPolylineSegmentRatio(double)
public double getMaximumPolylineSegmentRatio()
public void setMaximumPolylineSegmentRatio(double maximumPolylineSegmentRatio)
maximumPolylineSegmentRatio
- The maximum polyline segment ratio at each end of an orthogonal segment.
The ratio must be between 0 and 0.5.public boolean isReroutingEnabled()
Rerouting is only used, if the getMaximumDuration()
isn't exceeded, yet.
true
if a rerouting step will be done afterwards, false
otherwise.public void setReroutingEnabled(boolean reroutingEnabled)
Rerouting is only used, if the getMaximumDuration()
isn't exceeded, yet.
reroutingEnabled
- Whether or not a rerouting step shall be done afterwards.public void setSphereOfAction(byte sphere)
ROUTE_ALL_EDGES
.
IllegalArgumentException
- if the given argument is not one of the above constants.sphere
- One of
ROUTE_SELECTED_EDGES
, ROUTE_EDGES_AT_SELECTED_NODES
, and
ROUTE_ALL_EDGES
.getSelectedEdgesDpKey()
public byte getSphereOfAction()
setSphereOfAction(byte)
,
ROUTE_ALL_EDGES
,
ROUTE_SELECTED_EDGES
,
ROUTE_EDGES_AT_SELECTED_NODES
public Object getSelectedNodesDpKey()
Layouter.SELECTED_NODES
is used.
If the sphere of action is set to ROUTE_EDGES_AT_SELECTED_NODES
, only edges of selected nodes are routed while all
other edges are considered to have fixed routes.
setSphereOfAction(byte)
public void setSelectedNodesDpKey(Object key)
Layouter.SELECTED_NODES
is used.
If the sphere of action is set to ROUTE_EDGES_AT_SELECTED_NODES
, only edges of selected nodes are routed while all
other edges are considered to have fixed routes.
IllegalArgumentException
- if the specified key is null
.key
- The data provider key for the node selection.getSphereOfAction()
public Object getSelectedEdgesDpKey()
Layouter.SELECTED_EDGES
is used.
If the sphere of action is set to ROUTE_SELECTED_EDGES
, only the selected keys are routed while all
other edges are considered to have fixed routes.
getSphereOfAction()
public void setSelectedEdgesDpKey(Object selectedEdgesDpKey)
Layouter.SELECTED_EDGES
is used.
If the sphere of action is set to ROUTE_SELECTED_EDGES
, only the selected keys are routed while all
other edges are considered to have fixed routes.
IllegalArgumentException
- if the specified key is null
.selectedEdgesDpKey
- The data provider key for the edge selection.getSphereOfAction()
public boolean canLayout(LayoutGraph graph)
Layouter
true
iff the given graph can be laid
out by this algorithm. Calling doLayout
with
the given graph as its argument will only success if
this method returns true
.
public void setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
considerNodeLabelsEnabled
- true
, in case the edge router considers node labels as obstacles for
edge routes, false
otherwise.PenaltySettings.getNodeLabelCrossingPenalty()
public boolean isConsiderNodeLabelsEnabled()
true
if this edge router considers node labels as obstacles for edge routes,
false
otherwise.PenaltySettings.getNodeLabelCrossingPenalty()
public void setConsiderEdgeLabelsEnabled(boolean considerEdgeLabelsEnabled)
setSphereOfAction(byte)
.
considerEdgeLabelsEnabled
- true
, in case the edge router considers labels of edges that are not
routed; false
otherwisePenaltySettings.getNodeLabelCrossingPenalty()
,
setSphereOfAction(byte)
,
setSelectedEdgesDpKey(Object)
public boolean isConsiderEdgeLabelsEnabled()
setSphereOfAction(byte)
.
true
if this edge router considers labels of edges that are not routed; false
otherwisePenaltySettings.getNodeLabelCrossingPenalty()
,
setSphereOfAction(byte)
,
setSelectedEdgesDpKey(Object)
public Grid getGrid()
Grid
the edge router tries to place the orthogonal segments on.
public void setGrid(Grid grid)
Grid
on which orthogonal segments are placed.
grid
- The grid to place the segments on.public void setMinimalNodeToEdgeDistance(double minimalNodeToEdgeDistance)
minimalNodeToEdgeDistance
- The minimal distance between edges and node bounds.PenaltySettings.getMinimalNodeToEdgeDistancePenalty()
public double getMinimalNodeToEdgeDistance()
PenaltySettings.getMinimalNodeToEdgeDistancePenalty()
protected GraphPartition createGraphPartition(ObstaclePartition decomposition)
GraphPartition
that divides the area of the graph into several rectangles.
This implementation creates a GraphPartition
using the current ObstaclePartition
. It may be
overridden to customize the partition used in EdgeRouter
.
GraphPartition
configureGraphPartition(GraphPartition)
,
getRegisteredPartitionExtensions()
protected void configureGraphPartition(GraphPartition partition)
GraphPartition
.
This implementation gets all registered GraphPartitionExtension
s and adds them to the given
GraphPartition
. It may be overridden to adjust the configuration of the GraphPartition
.
partition
- the partition that shall be configuredconfigureGraphPartition(GraphPartition)
,
getRegisteredPartitionExtensions()
protected void cleanupGraphPartition(GraphPartition partition)
GraphPartition
.
This implementation gets all registered GraphPartitionExtension
s and removes them from the given
GraphPartition
. It may be overridden to adjust the configuration of the GraphPartition
.
partition
- the partition that shall be configuredconfigureGraphPartition(GraphPartition)
,
getRegisteredPartitionExtensions()
public List getRegisteredPartitionExtensions()
GraphPartitionExtension
s.
GraphPartitionExtensions
can be added and removed to change the composition of extensions used by the
GraphPartition
.
GraphPartitionExtensions
createGraphPartition(ObstaclePartition)
,
configureGraphPartition(GraphPartition)
protected PathSearch createPathSearch()
PathSearch
that finds the edges' paths through the GraphPartition
.
This implementation creates a new PathSearch
. May be overridden to customize the path
search.
PathSearch
configurePathSearch(PathSearch)
,
getRegisteredPathSearchExtensions()
protected void configurePathSearch(PathSearch pathSearch)
PathSearch
.
This implementation gets all registered PathSearchExtension
s and adds them to
the given PathSearch
. It may be overridden to adjust the configuration of the
PathSearch
.
pathSearch
- the path search that shall be configuredcreatePathSearch()
,
getRegisteredPathSearchExtensions()
public List getRegisteredPathSearchExtensions()
PathSearchExtension
s.
PathSearchExtension
can be added and removed to change the composition of extensions used by the
PathSearch
.
PathSearchExtension
screatePathSearch()
,
configurePathSearch(PathSearch)
protected ChannelBasedPathRouting createPathRouting()
ChannelBasedPathRouting
that routes the edges using pre-calculated Path
objects.
This implementation creates a new ChannelBasedPathRouting
. May be overridden to customize
the path routing.
ChannelBasedPathRouting
protected DynamicObstacleDecomposition createObstacleDecomposition()
DynamicObstacleDecomposition
that is used by the GraphPartition
to divide the graph
area in rectangles.
This implementation creates a new DynamicObstacleDecomposition
. May be overridden to
customize the area decomposition.
DynamicObstacleDecomposition
createGraphPartition(ObstaclePartition)
protected PathSearchContext createPathSearchContext(PathSearch pathSearch, PathSearchConfiguration configuration)
PathSearchContext
that provides context information for the path search algorithm.
This implementation creates a new PathSearchContext
. May be overridden to customize the context
information providing.
pathSearch
- The path search that uses the context to be created.configuration
- The configuration used for the path search.
PathSearchContext
protected PathSearchConfiguration createConfiguration(LayoutGraph graph, Grouping grouping)
PathSearchConfiguration
that is used during the path search.
This implementation creates a new PathSearchConfiguration
. May be overridden to use
a subclassed configuration.
PathSearchConfiguration
.public void doLayout(LayoutGraph graph)
Layouter
public GraphPartition getPartition()
GraphPartition
used during the layout.
GraphPartition
used during the layout or null
if no layout is running right now.
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |