public class OrganicEdgeRouter extends Object implements ILayoutStage
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.
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 RemoveOverlapsStage
and node enlargement stage
.
MinimumDistance
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.
This edge routing algorithm is realized as a ILayoutStage
which can be applied to a graph directly or using a
core layout algorithm
.
Modifier and Type | Field and Description |
---|---|
static EdgeDpKey<Boolean> |
AFFECTED_EDGES_DPKEY
A
DataProvider key for selecting edges that should be routed
|
Constructor and Description |
---|
OrganicEdgeRouter()
Creates a new
OrganicEdgeRouter instance with the default settings. |
OrganicEdgeRouter(ILayoutAlgorithm core)
Creates a new
OrganicEdgeRouter with the given core layout algorithm . |
Modifier and Type | Method and Description |
---|---|
void |
applyLayout(LayoutGraph graph)
Performs the organic routing of the edges of the input graph.
|
protected void |
checkNodeSize(LayoutGraph g)
Checks the sizes of the nodes to be non-zero.
|
ILayoutStage |
createNodeEnlargementStage()
Returns a
ILayoutStage which temporarily increases the sizes of the nodes to avoid overlaps. |
ILayoutAlgorithm |
getCoreLayout()
Gets the core layout algorithm which arranges the graph before edge routing.
|
double |
getMinimumDistance()
Gets the minimum distance the algorithm should guarantee between nodes and non-incident edges.
|
boolean |
isEdgeNodeOverlapAllowed()
Gets whether or not edges are allowed to cross nodes.
|
boolean |
isKeepingExistingBendsEnabled()
Gets whether or not the initial bend coordinates are kept when determining the edge path.
|
boolean |
isRoutingAllEdgesEnabled()
Gets whether a rerouting step is performed on all edges or just on a subset where distances are violated.
|
void |
setCoreLayout(ILayoutAlgorithm value)
Sets the core layout algorithm which arranges the graph before edge routing.
|
void |
setEdgeNodeOverlapAllowed(boolean value)
Sets whether or not edges are allowed to cross nodes.
|
void |
setKeepingExistingBendsEnabled(boolean value)
Sets whether or not the initial bend coordinates are kept when determining the edge path.
|
void |
setMinimumDistance(double value)
Sets the minimum distance the algorithm should guarantee between nodes and non-incident edges.
|
void |
setRoutingAllEdgesEnabled(boolean value)
Sets whether a rerouting step is performed on all edges or just on a subset where distances are violated.
|
public OrganicEdgeRouter()
OrganicEdgeRouter
instance with the default settings.public OrganicEdgeRouter(ILayoutAlgorithm core)
OrganicEdgeRouter
with the given core layout algorithm
.core
- the core layout algorithmpublic void applyLayout(LayoutGraph graph)
applyLayout
in interface ILayoutAlgorithm
graph
- the input graphprotected void checkNodeSize(LayoutGraph g)
g
- The graph to check.public ILayoutStage createNodeEnlargementStage()
ILayoutStage
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.
RemoveOverlapsStage
, 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.CoreLayouter = cls; graph.ApplyLayout(router);
ILayoutStage
that resizes the nodespublic ILayoutAlgorithm getCoreLayout()
getCoreLayout
in interface ILayoutStage
null
. setCoreLayout(ILayoutAlgorithm)
public double getMinimumDistance()
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.
IllegalArgumentException
- if the given minimum distance is negative10
.setMinimumDistance(double)
public boolean isEdgeNodeOverlapAllowed()
Allowing edges to overlap with nodes will produce smoother edges, because the edge paths can be closer to the nodes.
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
. Edges are allowed to cross nodes.true
if edge-node overlaps are allowed, false
otherwisecreateNodeEnlargementStage()
,
setMinimumDistance(double)
,
setEdgeNodeOverlapAllowed(boolean)
public boolean isKeepingExistingBendsEnabled()
The bends are considered as fixed nodes and stay part of the path.
false
. Bends in the input graph are not considered for edge routing.true
if the initial bend coordinates are kept, false
otherwisesetKeepingExistingBendsEnabled(boolean)
public boolean isRoutingAllEdgesEnabled()
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.false
. Only edges being too close to nodes are rerouted.true
if all edges are rerouted, false
if only a subset is reroutedsetRoutingAllEdgesEnabled(boolean)
public void setCoreLayout(ILayoutAlgorithm value)
setCoreLayout
in interface ILayoutStage
null
. value
- the layout algorithm that arranges the graphgetCoreLayout()
public void setEdgeNodeOverlapAllowed(boolean value)
Allowing edges to overlap with nodes will produce smoother edges, because the edge paths can be closer to the nodes.
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
. Edges are allowed to cross nodes.value
- true
if edge-node overlaps are allowed, false
otherwisecreateNodeEnlargementStage()
,
setMinimumDistance(double)
,
isEdgeNodeOverlapAllowed()
public void setKeepingExistingBendsEnabled(boolean value)
The bends are considered as fixed nodes and stay part of the path.
false
. Bends in the input graph are not considered for edge routing.value
- true
if the initial bend coordinates are kept, false
otherwiseisKeepingExistingBendsEnabled()
public void setMinimumDistance(double value)
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.
IllegalArgumentException
- if the given minimum distance is negative10
.value
- the non-negative minimum distance between edges and nodesgetMinimumDistance()
public void setRoutingAllEdgesEnabled(boolean value)
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.false
. Only edges being too close to nodes are rerouted.value
- true
if all edges are rerouted, false
if only a subset is reroutedisRoutingAllEdgesEnabled()