|
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.SelfLoopLayouter
public class SelfLoopLayouter
A SelfLoopLayouter
routes the self-loops (reflexive edges) of a graph.
The nodes and normal edges are arranged by the core layout algorithm
. This layout
algorithm only handles the paths of self-loops.
Self-loops are routed either orthogonal
or with rounded
corners.
The layout algorithm places the self-loops in the least crowded quadrant around a node.
Self-loops are handled in four steps:
SelfLoopLayouter
can either be used as a LayoutStage
wrapping a layout algorithm
which cannot handle self-loops. Then it will hide the self-loops from this
core layout algorithm
and take over the routing of them.
If no core layout algorithm
is specified, SelfLoopLayouter
can work alone. It
will route only the self-loops and keep the remaining graph unchanged.
When all self-loops already have a suitable layout, this layout algorithm can
keep the self-loop paths
. It will just hide the self-loops
before invoking the core layout algorithm, such that they are not altered by it.
To only exclude some self-loops from routing, a DataProvider
registered with
KEEP_SELF_LOOP_LAYOUT_DPKEY
can be used for marking those self-loops.
CanonicMultiStageLayouter
Field Summary | |
---|---|
static java.lang.Object |
KEEP_SELF_LOOP_LAYOUT_DPKEY
A DataProvider key for determining which self-loops should keep their current path
If no DataProvider is registered with this key, all self-loops will be routed. |
static byte |
STYLE_ORTHOGONAL
Self-loop style specifier which defines that the routes of self-loops are orthogonal. |
static byte |
STYLE_ROUNDED
Self-loop style specifier which defines that the routes of self-loops are rounded. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
SelfLoopLayouter()
Creates a new SelfLoopLayouter instance with default settings. |
|
SelfLoopLayouter(Layouter coreLayouter)
Creates a new SelfLoopLayouter using the given core layout algorithm . |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm after removing all
self-loops. |
void |
doLayout(LayoutGraph graph)
Delegates the arrangement of nodes and edges to the core layout algorithm and routes
the self-loops. |
int |
getCornerApproximationPointsCount()
Returns the number of points that are used for rounding the corners of the self-loops. |
byte |
getLayoutStyle()
Returns the layout style of the self-loops. |
double |
getLineDistance()
Returns the distance between two self-loops incident to the same node. |
boolean |
isKeepAllSelfloopLayoutsEnabled()
Returns whether or not this algorithm should keep all self-loop routes. |
boolean |
isSmartSelfloopPlacementEnabled()
Returns whether or not the algorithm chooses the side of the self-loop depending on the incident edges. |
protected void |
layoutSelfLoops(LayoutGraph graph)
Calculates the routes of the self-loops in the given graph. |
void |
setCornerApproximationPointsCount(int cornerApproximationPointsCount)
Specifies the number of points that are used for rounding the corners of the self-loops. |
void |
setKeepAllSelfloopLayoutsEnabled(boolean keepAllSelfloopLayouts)
Specifies whether or not this algorithm should keep all self-loop routes. |
void |
setLayoutStyle(byte layoutStyle)
Specifies the layout style of the self-loops. |
void |
setLineDistance(double distance)
Specifies the distance between two self-loops incident to the same node. |
void |
setSmartSelfloopPlacementEnabled(boolean smartSelfloopPlacementEnabled)
Specifies whether or not the algorithm chooses the side of the self-loop depending on the incident edges. |
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 java.lang.Object KEEP_SELF_LOOP_LAYOUT_DPKEY
DataProvider
key for determining which self-loops should keep their current path
If no DataProvider
is registered with this key, all self-loops will be routed.
setKeepAllSelfloopLayoutsEnabled(boolean)
public static final byte STYLE_ORTHOGONAL
The routes consist of an alternating sequence of horizontal and vertical line segments.
public static final byte STYLE_ROUNDED
The distance between incident self-loops
and
rounding of the corners
can be customized for rounded self-loops.
Constructor Detail |
---|
public SelfLoopLayouter()
SelfLoopLayouter
instance with default settings.
public SelfLoopLayouter(Layouter coreLayouter)
SelfLoopLayouter
using the given core layout algorithm
.
coreLayouter
- the core layout algorithmMethod Detail |
---|
public int getCornerApproximationPointsCount()
For rounded corners, the number of points should be at least 2
. All smaller values will produce one
bend and, therefore, an orthogonal path.
The number of points for a corner must be at least 1
.
STYLE_ROUNDED
is used.setCornerApproximationPointsCount(int)
,
setLayoutStyle(byte)
,
STYLE_ROUNDED
public void setCornerApproximationPointsCount(int cornerApproximationPointsCount)
For rounded corners, the number of points should be at least 2
. All smaller values will produce one
bend and, therefore, an orthogonal path.
The number of points for a corner must be at least 1
.
STYLE_ROUNDED
is used.cornerApproximationPointsCount
- the number of bends that are inserted to round the corners of self-loops
java.lang.IllegalArgumentException
- if the specified point count is less than 1
setLayoutStyle(byte)
,
STYLE_ROUNDED
2 | 5 |
public void setLineDistance(double distance)
The distance needs to be a non-negative value.
public double getLineDistance()
The distance needs to be a non-negative value.
STYLE_ROUNDED
.setLineDistance(double)
,
STYLE_ROUNDED
public boolean isSmartSelfloopPlacementEnabled()
true
if self-loops are placed smartly, false
otherwisesetSmartSelfloopPlacementEnabled(boolean)
public void setSmartSelfloopPlacementEnabled(boolean smartSelfloopPlacementEnabled)
public byte getLayoutStyle()
setLayoutStyle(byte)
public void setLayoutStyle(byte layoutStyle)
STYLE_ROUNDED
layoutStyle
- the layout style for self-loops
java.lang.IllegalArgumentException
- if the specified style is unknownpublic void doLayout(LayoutGraph graph)
core layout algorithm
and routes
the self-loops.
graph
- the input graphLayouter.canLayout(LayoutGraph)
public boolean canLayout(LayoutGraph graph)
core layout algorithm
after removing all
self-loops.
If there is no core layout algorithm
, all graphs are accepted.
graph
- the input graph
true
if there is no core layout algorithm or the core layout algorithm accepts the graph,
false
otherwiseLayouter.doLayout(LayoutGraph)
protected void layoutSelfLoops(LayoutGraph graph)
This method will only change the routes of self-loops that are not marked to be
kept
.
This method is called by doLayout(LayoutGraph)
after the core layout algorithm
has arranged the graph and all self-loops have been reinserted into the graph. It may be overridden to
introduce custom self-loop styles.
graph
- the input graphpublic boolean isKeepAllSelfloopLayoutsEnabled()
When enabled, no self-loop will be routed, instead the existing self-loop layout will be moved with its node.
DataProvider
registered with
KEEP_SELF_LOOP_LAYOUT_DPKEY
. Self-loops that were not marked will still not be routed.true
if all self-loops should keep their routes, false
otherwisesetKeepAllSelfloopLayoutsEnabled(boolean)
public void setKeepAllSelfloopLayoutsEnabled(boolean keepAllSelfloopLayouts)
When enabled, no self-loop will be routed, instead the existing self-loop layout will be moved with its node.
DataProvider
registered with
KEEP_SELF_LOOP_LAYOUT_DPKEY
. Self-loops that were not marked will still not be routed.keepAllSelfloopLayouts
- true
if all self-loops should keep their routes,
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 |