|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.router.OrganicEdgeRouter
public class OrganicEdgeRouter
This edge routing algorithm applies organic routes to the edges of the graph.
Edges are routed organically, i.e. in smooth curves around the nodes observing a
minimum distance
to the nodes.
During the routing process, the positions of the nodes are considered to be fixed and the router will not modify their locations or their sizes in any way.
The edge routing algorithm can be applied whenever edge paths should avoid crossing any nodes in organic or cyclic layout styles.
The edge routing algorithm uses a force-directed approach to calculate the edge paths. Nodes are considered to be repulsive forces while edges will try to become as short as possible.
Each edge is routed separately and is influenced by the nodes in a certain area around it. The algorithm will add bends to the edge path that are placed by balancing the forces.
The quality of the result highly depends on how much space there is between the nodes. More precisely, the
distance between each pair of nodes should be at least twice the specified
minimum distance
. If it is not necessary that the nodes keep their locations, this
can be ensured using a combination of RemoveOverlapsLayoutStage
and
node enlargement stage
.
setMinimalDistance(double)
will make edges keep a custom distance to the nodes. However, if there is not
enough space between the nodes, this distance may be undershot (i.e. edges will be closer to nodes).
OrganicEdgeRouter
is able to reuse existing bends
. Edges will contain those
bends along with other bends added by the layout algorithm.
Another feature allows to consider bends such that they influence the route finding, however, their absolute
location is not kept (see setExistingBendsConsiderationEnabled(boolean)
).
This edge routing algorithm is realized as a LayoutStage
which can be applied to a graph directly or using
a core layout algorithm
.
Field Summary | |
---|---|
static java.lang.Object |
ROUTE_EDGE_DPKEY
A DataProvider key for selecting edges that should be routed
|
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
OrganicEdgeRouter()
Creates a new OrganicEdgeRouter instance with the default settings. |
|
OrganicEdgeRouter(double minNodeDistance)
Creates a new OrganicEdgeRouter instance with a custom minimum distance between edges and nodes. |
|
OrganicEdgeRouter(Layouter core)
Creates a new OrganicEdgeRouter with the given core layout algorithm . |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Accepts all graphs whose nodes have sizes greater than 0 and that the specified
core layout algorithm can handle. |
protected void |
checkGroupNodeSize(GraphLayout layout,
java.lang.Object node)
Checks whether or not the given group node's width or height is 0 . |
protected void |
checkNodeSize(GraphLayout layout,
java.lang.Object node)
Checks whether or not the given node's width or height is 0 . |
LayoutStage |
createNodeEnlargementStage()
Returns a LayoutStage which temporarily increases the sizes of the nodes to avoid overlaps. |
void |
doLayout(LayoutGraph graph)
Performs the organic routing of the edges of the input graph. |
Layouter |
getCoreLayouter()
Returns the core layout algorithm which arranges the graph before edge routing. |
double |
getMinimalDistance()
Returns the minimum distance the algorithm should guarantee between nodes and non-incident edges. |
boolean |
isEdgeNodeOverlapAllowed()
Returns whether or not edges are allowed to cross nodes. |
boolean |
isExistingBendsConsiderationEnabled()
Returns whether or not the initial bend coordinates influence the path routing such that the calculated routes tend to have a similar overall shape. |
boolean |
isRoutingAll()
Returns whether a rerouting step is performed on all edges or just on a subset where distances are violated. |
boolean |
isUsingBends()
Returns whether or not the initial bend coordinates are kept when determining the edge path. |
void |
setCoreLayouter(Layouter coreLayouter)
Specifies the core layout algorithm which arranges the graph before edge routing. |
void |
setEdgeNodeOverlapAllowed(boolean edgeNodeOverlapAllowed)
Specifies whether or not edges are allowed to cross nodes. |
void |
setExistingBendsConsiderationEnabled(boolean considerExistingBends)
Specifies whether or not the initial bend coordinates influence the path routing such that the calculated routes tend to have a similar overall shape. |
void |
setMinimalDistance(double minimumDistance)
Specifies the minimum distance the algorithm should guarantee between nodes and non-incident edges. |
void |
setRoutingAll(boolean routingAll)
Specifies whether a rerouting step is performed on all edges or just on a subset where distances are violated. |
void |
setUsingBends(boolean keepExistingBends)
Specifies whether or not the initial bend coordinates are kept when determining the edge path. |
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 ROUTE_EDGE_DPKEY
DataProvider
key for selecting edges that should be routed
Constructor Detail |
---|
public OrganicEdgeRouter()
OrganicEdgeRouter
instance with the default settings.
public OrganicEdgeRouter(double minNodeDistance)
OrganicEdgeRouter
instance with a custom minimum distance between edges and nodes.
minNodeDistance
- the minimum distance between edges and nodes
java.lang.IllegalArgumentException
- if the given minimum distance is negativepublic OrganicEdgeRouter(Layouter core)
OrganicEdgeRouter
with the given core layout algorithm
.
core
- the core layout algorithmMethod Detail |
---|
public boolean canLayout(LayoutGraph graph)
0
and that the specified
core layout algorithm
can handle. If there is no
core layout algorithm
specified, all general graphs without zero-sized nodes are
accepted.
canLayout
in interface Layouter
graph
- the input graph
true
if the core layout algorithm
can handle the given graph and
this graph doesn't contain nodes with size 0
, false
otherwiseLayouter.doLayout(LayoutGraph)
public boolean isEdgeNodeOverlapAllowed()
enlarged
, e.g., because the nodes should not move,
allowing overlaps between nodes and edges may lead to better results in case the distances between nodes
are small. The minimum distance
cannot always be maintained.true
if edge-node overlaps are allowed, false
otherwisesetEdgeNodeOverlapAllowed(boolean)
,
createNodeEnlargementStage()
,
setMinimalDistance(double)
public void setEdgeNodeOverlapAllowed(boolean edgeNodeOverlapAllowed)
enlarged
, e.g., because the nodes should not move,
allowing overlaps between nodes and edges may lead to better results in case the distances between nodes
are small. The minimum distance
cannot always be maintained.edgeNodeOverlapAllowed
- true
if edge-node overlaps should be allowed,
false
otherwisecreateNodeEnlargementStage()
,
setMinimalDistance(double)
false | true |
public void doLayout(LayoutGraph graph)
doLayout
in interface Layouter
graph
- the input graphLayouter.canLayout(LayoutGraph)
protected void checkNodeSize(GraphLayout layout, java.lang.Object node) throws java.lang.IllegalArgumentException
0
.
This method is called in doLayout(LayoutGraph)
before the core layout algorithm
is invoked. It can be overridden to remove/change this check.
layout
- a graph layout objectnode
- the node
java.lang.IllegalArgumentException
- if width or height of the node object is zerocheckGroupNodeSize(GraphLayout, Object)
protected void checkGroupNodeSize(GraphLayout layout, java.lang.Object node) throws java.lang.IllegalArgumentException
0
.
This method is called in doLayout(LayoutGraph)
before the core layout algorithm
is invoked. It can be overridden to remove/change this check.
layout
- a graph layout objectnode
- the group node
java.lang.IllegalArgumentException
- if width or height of the group node object is zerocheckNodeSize(GraphLayout, Object)
public Layouter getCoreLayouter()
getCoreLayouter
in interface LayoutStage
setCoreLayouter(Layouter)
public void setCoreLayouter(Layouter coreLayouter)
setCoreLayouter
in interface LayoutStage
coreLayouter
- the layout algorithm that arranges the graphpublic double getMinimalDistance()
The distance also influences how many bends are added to the path (a higher distance leads to less bends).
The minimum distance is defined to be a non-negative value.
10
.setMinimalDistance(double)
public void setMinimalDistance(double minimumDistance)
The distance also influences how many bends are added to the path (a higher distance leads to less bends).
The minimum distance is defined to be a non-negative value.
10
.minimumDistance
- the non-negative minimum distance between edges and nodes
java.lang.IllegalArgumentException
- if the given minimum distance is negative10 | 50 |
public boolean isUsingBends()
setExistingBendsConsiderationEnabled(boolean)
instead and disable this one.true
if the initial bend coordinates are kept, false
otherwisesetUsingBends(boolean)
public void setUsingBends(boolean keepExistingBends)
setExistingBendsConsiderationEnabled(boolean)
instead and disable this one.keepExistingBends
- true
if the initial bend coordinates should be kept,
false
otherwiseInitial graph | false | true |
public boolean isExistingBendsConsiderationEnabled()
The existing bend coordinates are considered but not kept.
If they shall be kept, enable property setUsingBends(boolean)
.
setUsingBends(boolean)
is enabled.ture
if the existing bends are considered, false
otherwisesetExistingBendsConsiderationEnabled(boolean)
public void setExistingBendsConsiderationEnabled(boolean considerExistingBends)
The existing bend coordinates are considered but not kept.
If they shall be kept, enable property setUsingBends(boolean)
.
setUsingBends(boolean)
is enabled.considerExistingBends
- ture
if the existing bends should be considered,
false
otherwisepublic boolean isRoutingAll()
If only a subset of edges is rerouted, only those edges which cross nodes or come too close to a node are included. During rerouting, more bends are added to the edges that will be influenced by the repulsive forces.
minimum distances
more closely.
Disabling this feature, i.e., keeping the first calculated path will take less runtime.true
if all edges are rerouted, false
if only a subset is reroutedsetRoutingAll(boolean)
public void setRoutingAll(boolean routingAll)
If only a subset of edges is rerouted, only those edges which cross nodes or come too close to a node are included. During rerouting, more bends are added to the edges that will be influenced by the repulsive forces.
minimum distances
more closely.
Disabling this feature, i.e., keeping the first calculated path will take less runtime.routingAll
- true
if all edges are rerouted, false
if only a subset is reroutedfalse | true |
public LayoutStage createNodeEnlargementStage()
LayoutStage
which temporarily increases the sizes of the nodes to avoid overlaps.
The edges will keep a greater distance to the nodes. Therefore, they won't cross them.
RemoveOverlapsLayoutStage
,
see the provided example.
The following example demonstrates how to use this stage:
OrganicEdgeRouter router = new OrganicEdgeRouter(); CompositeLayoutStage cls = new CompositeLayoutStage(); cls.appendStage(router.createNodeEnlargementStage()); cls.appendStage(new RemoveOverlapsLayoutStage(0)); router.setCoreLayouter(cls); router.doLayout(graph);
LayoutStage
that resizes the nodes
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |