Search this API

y.layout
Class SelfLoopLayouter

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.SelfLoopLayouter
All Implemented Interfaces:
Layouter, LayoutStage

public class SelfLoopLayouter
extends AbstractLayoutStage

A layout algorithm that routes the self-loops (reflexive edges) of a graph. By default, this layouter routes self-loops in an orthogonal fashion. It places the self-loop in the least crowded quadrant around a node.

A core layout algorithm can be specified for this class. In that case, the performed layout process of this class is subdivided into four stages:

  1. Remove all self-loops of the input graph
  2. Invoke the core layouter on the now self-loops free graph
  3. Reinsert all formerly removed self-loops of the graph
  4. Layout the self-loops of the input graph


Field Summary
static Object KEEP_SELF_LOOP_LAYOUT_DPKEY
          This DataProvider key can be used to register a DataProvider with the graph to be laid out.
static byte STYLE_ORTHOGONAL
          Edge layout style modifier.
static byte STYLE_ROUNDED
          Edge layout style modifier.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
SelfLoopLayouter()
          Instantiates a new SelfLoopLayouter.
SelfLoopLayouter(Layouter coreLayouter)
          Instantiates a new SelfLoopLayouter.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Whether or not this layouter can layout the given graph.
 void doLayout(LayoutGraph graph)
          Lays out the given graph.
 int getCornerApproximationPointsCount()
          Returns the number of points that are used to round the corner of the selfloops.
 byte getLayoutStyle()
          Returns the layout style to be used.
 double getLineDistance()
          Returns the distance between two adjacent paths that run in parallel.
 boolean isKeepAllSelfloopLayoutsEnabled()
          Returns whether this algorithm should keep the existing layout of all self-loops.
 boolean isSmartSelfloopPlacementEnabled()
          Whether or not smart selfloop placement should be enabled.
protected  void layoutSelfLoops(LayoutGraph graph)
          Lays out the self-loops of the given graph.
 void setCornerApproximationPointsCount(int cornerApproximationPointsCount)
          Sets the number of points that are used to round the corner of the selfloops.
 void setKeepAllSelfloopLayoutsEnabled(boolean keepAllSelfloopLayouts)
          Sets whether this algorithm should keep all self loops.
 void setLayoutStyle(byte layoutStyle)
          Sets the layout style to be used.
 void setLineDistance(double distance)
          Sets the distance between two selfloops incident to the same node.
 void setSmartSelfloopPlacementEnabled(boolean smartSelfloopPlacementEnabled)
          Whether or not smart selfloop placement should be enabled.
 
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

KEEP_SELF_LOOP_LAYOUT_DPKEY

public static final Object KEEP_SELF_LOOP_LAYOUT_DPKEY
This DataProvider key can be used to register a DataProvider with the graph to be laid out. This algorithm will query for each self-loop the boolean value from the data provider to determine whether the current layout of the self-loop should be kept. I.e., if the DataProvider instance obtained from the graph using this key returns true for a self-loop, that self-loop will not be laid out by this stage but the bends will be moved by that stage according to the movement of their node.

See Also:
setKeepAllSelfloopLayoutsEnabled(boolean)

STYLE_ORTHOGONAL

public static final byte STYLE_ORTHOGONAL
Edge layout style modifier. Using this style, selfloops are routed in an orthogonal fashion, i.e., the route consists of an alternating sequence of horizontal and vertical line segments. This style can be set with method setLayoutStyle(byte).

See Also:
setLayoutStyle(byte), Constant Field Values

STYLE_ROUNDED

public static final byte STYLE_ROUNDED
Edge layout style modifier. Using this style, the routes of selfloops are rounded. This style can be set with method setLayoutStyle(byte).

See Also:
setLayoutStyle(byte), Constant Field Values
Constructor Detail

SelfLoopLayouter

public SelfLoopLayouter()
Instantiates a new SelfLoopLayouter.


SelfLoopLayouter

public SelfLoopLayouter(Layouter coreLayouter)
Instantiates a new SelfLoopLayouter. The core layout routine will be delegated to the given layouter.

Method Detail

getCornerApproximationPointsCount

public int getCornerApproximationPointsCount()
Returns the number of points that are used to round the corner of the selfloops.

Returns:
the number of points
See Also:
setCornerApproximationPointsCount(int)

setCornerApproximationPointsCount

public void setCornerApproximationPointsCount(int cornerApproximationPointsCount)
Sets the number of points that are used to round the corner of the selfloops. If this value is set to one the corners are drawn orthogonal. This value is only considered if style STYLE_ROUNDED is used.

Parameters:
cornerApproximationPointsCount -
See Also:
STYLE_ROUNDED

setLineDistance

public void setLineDistance(double distance)
Sets the distance between two selfloops incident to the same node. This value is only considered for layout style STYLE_ROUNDED.

See Also:
STYLE_ROUNDED

getLineDistance

public double getLineDistance()
Returns the distance between two adjacent paths that run in parallel.


isSmartSelfloopPlacementEnabled

public boolean isSmartSelfloopPlacementEnabled()
Whether or not smart selfloop placement should be enabled.

Returns:
true if smart selfloop placement is enabled.
See Also:
setSmartSelfloopPlacementEnabled(boolean)

setSmartSelfloopPlacementEnabled

public void setSmartSelfloopPlacementEnabled(boolean smartSelfloopPlacementEnabled)
Whether or not smart selfloop placement should be enabled. If this option is enabled, selfloops are placed on one of the four corners of the corresponding node. For the choice of the corner the algorithm considers all incident edges. Otherwise the selfloops are always placed at the upper left corner of the corresponding node.

Parameters:
smartSelfloopPlacementEnabled - whether or not smart selfloop placement should be enabled.

getLayoutStyle

public byte getLayoutStyle()
Returns the layout style to be used.

Returns:
the used layout style.
See Also:
setLayoutStyle(byte)

setLayoutStyle

public void setLayoutStyle(byte layoutStyle)
Sets the layout style to be used. Possible values are STYLE_ORTHOGONAL (default) and STYLE_ROUNDED.

Parameters:
layoutStyle - the layout style to be used.
See Also:
STYLE_ORTHOGONAL, STYLE_ROUNDED

doLayout

public void doLayout(LayoutGraph graph)
Lays out the given graph.


canLayout

public boolean canLayout(LayoutGraph graph)
Whether or not this layouter can layout the given graph. Returns true if the core layouter can handle the given graph after all of its self-loops (reflexive) edges have been hidden.


layoutSelfLoops

protected void layoutSelfLoops(LayoutGraph graph)
Lays out the self-loops of the given graph. This method will be called after the core layouter has laid out the graph and all self-loops have been reinserted in the graph again.


isKeepAllSelfloopLayoutsEnabled

public boolean isKeepAllSelfloopLayoutsEnabled()
Returns whether this algorithm should keep the existing layout of all self-loops. If this property is set, the KEEP_SELF_LOOP_LAYOUT_DPKEY data provider will be ignored. No layout for any self-loop will be calculated, instead the existing self-loop layout will be moved with its node.
The default is false.

Returns:
whether all self loops should be kept.

setKeepAllSelfloopLayoutsEnabled

public void setKeepAllSelfloopLayoutsEnabled(boolean keepAllSelfloopLayouts)
Sets whether this algorithm should keep all self loops. If this property is set, the KEEP_SELF_LOOP_LAYOUT_DPKEY DataProvider will be ignored. No layout for any self-loop will be calculated, instead the existing self-loop layout will be moved with its node.

Parameters:
keepAllSelfloopLayouts - whether all self loops should be kept.
See Also:
isKeepAllSelfloopLayoutsEnabled()

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.