Search this API

y.layout
Class RemoveColinearBendsStage

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

public class RemoveColinearBendsStage
extends AbstractLayoutStage

This LayoutStage removes all collinear bends found in the graph. The algorithms traverses each edge path from source to target and removes for each triple of consecutive collinear bends the middle one.


Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
RemoveColinearBendsStage()
           
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns true iff the given graph can be laid out by this algorithm.
 void doLayout(LayoutGraph graph)
          Removes collinear bends of the edges.
 double getScale()
          Returns the current scale, to which this stage will refer, when checking for collinearity.
 boolean isRemoveStraightOnly()
          Returns the current state of the remove straight only property.
 void setRemoveStraightOnly(boolean removeStraightOnly)
          Specifies whether the algorithm removes only collinear bends which lie in the middle of their neighbors or all collinear bends.
 void setScale(double scale)
          Sets the current scale, to which this stage will refer, when checking for collinearity.
 
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
 

Constructor Detail

RemoveColinearBendsStage

public RemoveColinearBendsStage()
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Description copied from interface: Layouter
Returns true iff the given graph can be laid out by this algorithm. Calling doLayout with the given graph as its argument will only success if this method returns true.


getScale

public double getScale()
Returns the current scale, to which this stage will refer, when checking for collinearity. Default value is 2.0. Which means that values are rounded to the second position after the decimal point. If the rounded values of an edge are leading to a collinear bend, this bend will be removed.

Returns:
the current scale to which this stage will refer, when checking for collinearity.

setScale

public void setScale(double scale)
Sets the current scale, to which this stage will refer, when checking for collinearity. Default value is 2.0. Which means that values are rounded to the second position after the decimal point. If the rounded values of an edge are leading to a collinear bend, this bend will be removed.

Parameters:
scale - the current scale to which this stage will refer, when checking for collinearity.

isRemoveStraightOnly

public boolean isRemoveStraightOnly()
Returns the current state of the remove straight only property.

Returns:
true if the algorithm removes only bends for which the angle is 180 degrees.
See Also:
setRemoveStraightOnly(boolean)

setRemoveStraightOnly

public void setRemoveStraightOnly(boolean removeStraightOnly)
Specifies whether the algorithm removes only collinear bends which lie in the middle of their neighbors or all collinear bends. In the first case, the angle at the middle bend must be 180 degrees, while in the second case, the angle can be either 180 degrees or 0 degree. The default is false.

Parameters:
removeStraightOnly - whether to enable or disable this feature

doLayout

public void doLayout(LayoutGraph graph)
Removes collinear bends of the edges.

Parameters:
graph - the graph

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