|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.organic.ShuffleLayouter
public class ShuffleLayouter
This layout algorithm removes overlaps between nodes in a graph.
Note: The usage of RemoveOverlapsLayoutStage
instead of this class is recommended for most use
cases involving the mere removal of overlaps. That stage offers a more powerful strategy to do the task.
The style of results often resembles the look of tiles which have been dropped onto each other, where tiles correspond to nodes of the graph. The reason is that overlapping nodes are moved in order to resolve the overlap. During this process, several nodes moving in the same direction may be stacked next to or above each other.
This algorithm does not route the edges of the input graph - edges might although be stretched due to the node movement.
Nodes overlapping with other nodes will be moved in horizontal or vertical direction in order to remove overlaps. The concept behind this removal step is based on a famous Russian arcade game.
This layout stage can also be executed
on its own, without specifying a
core layout algorithm
.
A minimum distance between nodes can be specified such that not only overlaps will be removed but
nodes will keep this specified distance to other nodes. This distance can be defined separately
for each node using a DataProvider
registered with key MINIMAL_DISTANCE_DPKEY
.
The minimum distance can also be specified globally via setMinimalNodeDistance(double)
.
To specify that specific nodes should not be moved, they can be marked as fixed using a
DataProvider
registered with key FIXED_NODE_DPKEY
.
Field Summary | |
---|---|
static java.lang.Object |
FIXED_NODE_DPKEY
A DataProvider key for marking nodes as fixed
A node marked as fixed will not be moved by this algorithm but stay at its current position. |
static byte |
HOC_INTERSECTION_BOX
Horizontal overlap criterion defining an overlap as horizontal if the overlapping area is greater in height than in width. |
static byte |
HOC_LESS_MOVEMENT
Horizontal overlap criterion categorizing an overlap as horizontal if the required movement for solving the overlap is shorter in horizontal direction than in vertical direction. |
static byte |
HOC_NODE_CENTER
Horizontal overlap criterion categorizing an overlap as horizontal if the center-to-center difference between the overlapping nodes is greater in horizontal direction (x-coordinates) than in vertical direction (y-coordinates). |
static java.lang.Object |
MINIMAL_DISTANCE_DPKEY
A DataProvider key for specifying a minimum distance for each node
The default minimum distance specified by setMinimalNodeDistance(double) will be ignored
for a node if the DataProvider registered with this key contains a valid minimum distance for that node. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
ShuffleLayouter()
Creates a new instance of ShuffleLayouter with default settings. |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Accepts all graphs that the specified core layout algorithm accepts. |
void |
doLayout(LayoutGraph graph)
Performs the overlap removal (shuffle) algorithm on the given graph, after the core layout algorithm was applied to it. |
Layouter |
getCoreLayouter()
Returns the core layout algorithm. |
byte |
getHorizontalOverlapCriterium()
Returns the criterion for marking an overlap as horizontal. |
double |
getMinimalNodeDistance()
Returns the default minimum distance that has to be obeyed between any two nodes. |
boolean |
isBarycenterModeActive()
Returns whether or not the barycenter mode is used for node shuffling when removing overlaps. |
boolean |
isSimpleModeActive()
Returns whether or not the simple, fast layout mode of this algorithm is active. |
void |
setBarycenterModeActive(boolean barycenterModeActive)
Specifies whether or not the barycenter mode is used for node shuffling when removing overlaps. |
void |
setCoreLayouter(Layouter layouter)
Specifies the core layout algorithm. |
void |
setHorizontalOverlapCriterium(byte hoc)
Specifies the criterion for marking an overlap as horizontal. |
void |
setMinimalNodeDistance(double distance)
Specifies the default minimum distance that has to be obeyed between any two nodes. |
void |
setSimpleModeActive(boolean s)
Specifies whether or not the simple, fast layout mode of this algorithm is active. |
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 MINIMAL_DISTANCE_DPKEY
DataProvider
key for specifying a minimum distance for each node
The default minimum distance specified by setMinimalNodeDistance(double)
will be ignored
for a node if the DataProvider
registered with this key contains a valid minimum distance for that node.
Minimum distance values need to be greater than 0
.
DataProvider
with this key is registered, the minimum
distance for all nodes is specified by setMinimalNodeDistance(double)
.public static final java.lang.Object FIXED_NODE_DPKEY
DataProvider
key for marking nodes as fixed
A node marked as fixed will not be moved by this algorithm but stay at its current position.
public static final byte HOC_INTERSECTION_BOX
Otherwise, if the overlap area's width is greater than or equal to its height, an overlap will be categorized as vertical.
The area of an overlap is defined as the rectangle where two nodes intersect with each other.
public static final byte HOC_NODE_CENTER
Otherwise, if the center-to-center difference between two overlapping nodes is greater in vertical direction (y-coordinates), the corresponding overlap is categorized as vertical. The same applies if the differences in vertical and horizontal direction are equal.
public static final byte HOC_LESS_MOVEMENT
Otherwise, an overlap will be categorized as vertical.
This criterion tries to avoid moving nodes too much because the direction for resolving overlaps will be chosen such that the shorter movement is preferred.
Constructor Detail |
---|
public ShuffleLayouter()
ShuffleLayouter
with default settings.
Method Detail |
---|
public void doLayout(LayoutGraph graph)
core layout algorithm
was applied to it.
doLayout
in interface Layouter
graph
- the input graphLayouter.canLayout(LayoutGraph)
public boolean canLayout(LayoutGraph graph)
core layout algorithm
accepts. If there is no
core layout algorithm specified, all types of graphs are accepted.
canLayout
in interface Layouter
graph
- the input graph
true
if the core layout algorithm
can handle the given graph or
the graph is not null
in case that no core layout algorithm is specified,
false
otherwiseLayouter.doLayout(LayoutGraph)
public void setCoreLayouter(Layouter layouter)
LayoutStage
Layouter.doLayout(LayoutGraph)
. The LayoutStage
may add pre- and post-processing steps before and after calling the core layout algorithm.
setCoreLayouter
in interface LayoutStage
layouter
- the core layout algorithmpublic Layouter getCoreLayouter()
LayoutStage
Layouter.doLayout(LayoutGraph)
. The LayoutStage
may add pre- and post-processing steps before and after calling the core layout algorithm.
getCoreLayouter
in interface LayoutStage
public void setHorizontalOverlapCriterium(byte hoc)
This criterion influences how overlaps will be resolved. If an overlap is considered horizontal, it will preferably be solved by moving nodes horizontally, else vertically.
simple mode
is disabled.HOC_LESS_MOVEMENT
hoc
- one of the predefined overlap criteria
java.lang.IllegalArgumentException
- if the given criterion is unknownpublic byte getHorizontalOverlapCriterium()
This criterion influences how overlaps will be resolved. If an overlap is considered horizontal, it will preferably be solved by moving nodes horizontally, else vertically.
simple mode
is disabled.public void setMinimalNodeDistance(double distance)
This default distance will be considered for a node if the DataProvider
registered with the graph with
key MINIMAL_DISTANCE_DPKEY
does not contain a valid, positive distance for that node.
If there is no DataProvider
registered with the mentioned key, then this default distance will
be applied to all nodes.
The minimum distance needs to be a non-negative value.
public double getMinimalNodeDistance()
This default distance will be considered for a node if the DataProvider
registered with the graph with
key MINIMAL_DISTANCE_DPKEY
does not contain a valid, positive distance for that node.
If there is no DataProvider
registered with the mentioned key, then this default distance will
be applied to all nodes.
The minimum distance needs to be a non-negative value.
setMinimalNodeDistance(double)
,
MINIMAL_DISTANCE_DPKEY
public void setSimpleModeActive(boolean s)
Enabling this mode, the overlap removal step will be executed using a simpler and less sophisticated approach. All overlaps will only be solved by moving nodes vertically. The algorithm will not try to figure out which direction might be better for overlap removal.
The runtime will improve, but results may be of lower quality when using this mode.
horizontal
overlap criterion
will not have any effect.s
- true
if the simple and fast layout mode should be enabled,
false
otherwise.false - input on left hand side, result on right hand side | true - input on left hand side, result on right hand side |
public boolean isSimpleModeActive()
Enabling this mode, the overlap removal step will be executed using a simpler and less sophisticated approach. All overlaps will only be solved by moving nodes vertically. The algorithm will not try to figure out which direction might be better for overlap removal.
The runtime will improve, but results may be of lower quality when using this mode.
horizontal
overlap criterion
will not have any effect.true
if the simple and fast layout mode is enabled,
false
otherwise.setSimpleModeActive(boolean)
public boolean isBarycenterModeActive()
If this mode is active, the overlap removal step will be executed two times for each direction, once with the normal node ordering and once with the reversed ordering. Finally, the barycenter between both results will be used for assigning the node coordinates.
Activating the barycenter mode allows more symmetric results for some graphs. However, the runtime might increase.
true
if the barycenter placement mode is active
false
otherwisesetBarycenterModeActive(boolean)
public void setBarycenterModeActive(boolean barycenterModeActive)
If this mode is active, the overlap removal step will be executed two times for each direction, once with the normal node ordering and once with the reversed ordering. Finally, the barycenter between both results will be used for assigning the node coordinates.
Activating the barycenter mode allows more symmetric results for some graphs. However, the runtime might increase.
barycenterModeActive
- true
if the barycenter placement mode should be active
false
otherwise
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |