Packagecom.yworks.yfiles.layout.router
Classpublic class OrganicEdgeRouter
InheritanceOrganicEdgeRouter Inheritance YObject Inheritance Object
Implements LayoutStage

This algorithm routes edges using an organic-like layout approach and style. It is implemented as a LayoutStage so that it can easily be appended to another stage, by setting the other stage as the core of this one. Note that this algorithm only works correctly if it is guaranteed that nodes are at least approximately twice as far away from each other as the minimal edge distance, which has been set for this algorithm. This can be achieved by using the createNodeEnlargementStage() layout stage in combination with a stage that removes node overlaps as the core of this layouter.

Here is a sample output of the router using as input a straight-line drawing created by com.yworks.yfiles.layout.organic.SmartOrganicLayouter:

See also

createNodeEnlargementStage()
com.yworks.yfiles.layout.organic.SmartOrganicLayouter


Public Properties
 PropertyDefined By
  coreLayouter : Layouter
Specifies the core layouter.
OrganicEdgeRouter
  edgeNodeOverlapAllowed : Boolean
Specifies whether or not edge-node overlaps are allowed.
OrganicEdgeRouter
  minimalDistance : Number
Getter: Returns the minimal distance between nodes and non-incident edges.
OrganicEdgeRouter
  routingAll : Boolean
Specifies whether edges should be rerouted even if they do not obey all constraints initially.
OrganicEdgeRouter
  usingBends : Boolean
Specifies whether given bend coordinates are taken into account when determining initial bend positions.
OrganicEdgeRouter
Public Methods
 MethodDefined By
  
OrganicEdgeRouter(init:Boolean = true)
Creates a new instance of OrganicEdgeRouter with an initial minimal distance of 10.
OrganicEdgeRouter
  
canLayout(graph:LayoutGraph):Boolean
OrganicEdgeRouter
  
Returns a layout stage which can be used to ensure that the nodes do not overlap.
OrganicEdgeRouter
  
doLayout(graph:LayoutGraph):void
OrganicEdgeRouter
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
OrganicEdgeRouter
 Inherited
hashCode():int
YObject
  
[static] Creates a new instance of OrganicEdgeRouter with an initial minimal distance of 10.
OrganicEdgeRouter
  
[static] Creates a new instance of OrganicEdgeRouter using the given initial minimal distance
OrganicEdgeRouter
Protected Methods
 MethodDefined By
  
checkGroupNodeSize(layout:GraphLayout, node:Object):void
This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given group node object is zero.
OrganicEdgeRouter
  
checkNodeSize(layout:GraphLayout, node:Object):void
This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given node object is zero.
OrganicEdgeRouter
  
Initializes this object.
OrganicEdgeRouter
  
initOrganicEdgeRouter2(minNodeDistance:Number):void
Initializes this object.
OrganicEdgeRouter
Public Constants
 ConstantDefined By
  ROUTE_EDGE_DPKEY : Object = y.layout.router.OrganicEdgeRouter.ROUTE_EDGE_DPKEY
[static] Use this key to provide the algorithm with boolean values for each edge, specifying the ones which should be rerouted.
OrganicEdgeRouter
Property Detail
coreLayouterproperty
coreLayouter:Layouter

Specifies the core layouter.


Implementation
    public function get coreLayouter():Layouter
    public function set coreLayouter(value:Layouter):void
edgeNodeOverlapAllowedproperty 
edgeNodeOverlapAllowed:Boolean

Specifies whether or not edge-node overlaps are allowed. Enabling this option often leads to better results if the createNodeEnlargementStage() LayoutStage is not used (e.g. because the nodes are not allowed to move) and the distances between some nodes are small. However enabling this option may produce edge-node overlaps. Furthermore, the minimal distance (set with minimalDistance cannot always be maintained in that case.


Implementation
    public function get edgeNodeOverlapAllowed():Boolean
    public function set edgeNodeOverlapAllowed(value:Boolean):void

See also

minimalDistanceproperty 
minimalDistance:Number

Getter: Returns the minimal distance between nodes and non-incident edges.

Setter: Specifies the minimal distance the algorithm should guarantee between nodes and non-incident edges. Values should be larger than 10.


Implementation
    public function get minimalDistance():Number
    public function set minimalDistance(value:Number):void
routingAllproperty 
routingAll:Boolean

Specifies whether edges should be rerouted even if they do not obey all constraints initially. This flag is initially set to false so that if edges that do not intersect with other nodes will not be rerouted by this algorithm.


Implementation
    public function get routingAll():Boolean
    public function set routingAll(value:Boolean):void
usingBendsproperty 
usingBends:Boolean

Specifies whether given bend coordinates are taken into account when determining initial bend positions.


Implementation
    public function get usingBends():Boolean
    public function set usingBends(value:Boolean):void
Constructor Detail
OrganicEdgeRouter()Constructor
public function OrganicEdgeRouter(init:Boolean = true)

Creates a new instance of OrganicEdgeRouter with an initial minimal distance of 10.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
canLayout()method
public function canLayout(graph:LayoutGraph):Boolean

Parameters

graph:LayoutGraph

Returns
Boolean
checkGroupNodeSize()method 
protected function checkGroupNodeSize(layout:GraphLayout, node:Object):void

This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given group node object is zero. It is called by the doLayout() method for each group node object in the input graph.

Parameters

layout:GraphLayout — a graph layout object.
 
node:Object — the group node object to test.


Throws
IllegalArgumentException — thrown if the width/height of the group node object is zero.

See also

checkNodeSize()method 
protected function checkNodeSize(layout:GraphLayout, node:Object):void

This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given node object is zero. It is called by the doLayout() method for each node object in the input graph.

Parameters

layout:GraphLayout — a graph layout object.
 
node:Object — the node object to test.


Throws
IllegalArgumentException — thrown if the width/height of the node object is zero.

See also

createNodeEnlargementStage()method 
public function createNodeEnlargementStage():LayoutStage

Returns a layout stage which can be used to ensure that the nodes do not overlap. Note that overlapping nodes may lead to bad routing results. The following example demonstrates how to use this stage (router denotes an instance of OrganicEdgeRouter):

 CompositeLayoutStage cls = new CompositeLayoutStage(); cls.appendStage(router.createNodeEnlargementStage()); cls.appendStage(new RemoveOverlapsLayoutStage(0)); OrganicEdgeRouter oer = new OrganicEdgeRouter(); oer.setCoreLayouter(cls); oer.doLayout(graph); 

Returns
LayoutStage
doLayout()method 
public function doLayout(graph:LayoutGraph):void

Parameters

graph:LayoutGraph

getClass()method 
override public function getClass():Class

Returns
Class
initOrganicEdgeRouter1()method 
protected final function initOrganicEdgeRouter1():void

Initializes this object. See the documentation of the corresponding factory method newOrganicEdgeRouter1() for details.

See also

initOrganicEdgeRouter2()method 
protected final function initOrganicEdgeRouter2(minNodeDistance:Number):void

Initializes this object. See the documentation of the corresponding factory method newOrganicEdgeRouter2() for details.

Parameters

minNodeDistance:Number

See also

newOrganicEdgeRouter1()method 
public static function newOrganicEdgeRouter1():OrganicEdgeRouter

Creates a new instance of OrganicEdgeRouter with an initial minimal distance of 10.

Returns
OrganicEdgeRouter
newOrganicEdgeRouter2()method 
public static function newOrganicEdgeRouter2(minNodeDistance:Number):OrganicEdgeRouter

Creates a new instance of OrganicEdgeRouter using the given initial minimal distance

Parameters

minNodeDistance:Number

Returns
OrganicEdgeRouter
Constant Detail
ROUTE_EDGE_DPKEYConstant
public static const ROUTE_EDGE_DPKEY:Object = y.layout.router.OrganicEdgeRouter.ROUTE_EDGE_DPKEY

Use this key to provide the algorithm with boolean values for each edge, specifying the ones which should be rerouted.