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

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

A collinear bend forms a straight line with its preceding bend and its subsequent bend. The angle between the connecting edge segments is either 0 or 180 degrees.

 
Your browser does not support SVG content.

Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
RemoveColinearBendsStage()
          Creates a new RemoveColinearBendsStage instance with default settings.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all general graphs.
 void doLayout(LayoutGraph graph)
          Removes collinear bends of the edges in the given graph.
 double getScale()
          Returns the scale that defines how accurate the algorithm is when it comes to comparing the coordinates of two bends.
 boolean isRemoveStraightOnly()
          Returns whether the algorithm removes only collinear bends which lie in the middle of their neighbors or all collinear bends.
 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)
          Specifies the scale that defines how accurate the algorithm is when it comes to comparing the coordinates of two bends.
 
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()
Creates a new RemoveColinearBendsStage instance with default settings.

Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all general graphs.

Parameters:
graph - the input graph
Returns:
true for all graphs
See Also:
Layouter.doLayout(LayoutGraph)

getScale

public double getScale()
Returns the scale that defines how accurate the algorithm is when it comes to comparing the coordinates of two bends.

This value determines how the values of the coordinates are rounded. If rounded coordinates lead to a collinear bend, this bend will be removed. The larger the value, the higher the precision is.

Returns:
the scale
See Also:
setScale(double)

setScale

public void setScale(double scale)
Specifies the scale that defines how accurate the algorithm is when it comes to comparing the coordinates of two bends.

This value determines how the values of the coordinates are rounded. If rounded coordinates lead to a collinear bend, this bend will be removed. The larger the value, the higher the precision is.

Default Value:
The default value is 2. Bend coordinates are rounded to the second decimal position before comparing.
Parameters:
scale - the scale

isRemoveStraightOnly

public boolean isRemoveStraightOnly()
Returns 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 degrees.

Returns:
true if only bends with 180 degrees are removed, false otherwise

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 degrees.

Default Value:
The default value is false. All collinear bends are removed from the edges.
Parameters:
removeStraightOnly - true if only bends with 180 degrees are removed, false otherwise

doLayout

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

Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

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