Packagecom.yworks.yfiles.layout.tree
Classpublic class TreeReductionStage
InheritanceTreeReductionStage Inheritance AbstractLayoutStage Inheritance YObject Inheritance Object

This stage can be used to layout non-tree structures with a tree layout algorithm. First this stage transforms a graph into a tree or forest by removing some edges. Then it invokes the core layout algorithm on the reduced graph. Finally, it reinserts the hidden non-tree edges to the graph again and optionally routes these edges.

Typical usage:

 TreeLayouter tl = new TreeLayouter(); TreeReductionStage trs = new TreeReductionStage(); trs.setNonTreeEdgeRouter(new OrganicEdgeRouter()); trs.setNonTreeEdgeSelectionKey(OrganicEdgeRouter.ROUTE_EDGE_DPKEY); tl.appendStage(trs); new BufferedLayouter(tl).doLayout(graph); tl.removeStage(trs); 

Note that if there are edges between group nodes, the com.yworks.yfiles.layout.tree.TreeLayouter may throw a com.yworks.yfiles.base.InvalidGraphStructureException -Exception. Such exceptions can be prevented by temporarily removing those edges.

Note that this layout stage is also able to handle multi-parent structures, i.e., structures of multiple nodes that share the same predecessors as well as the same successors. More precisely, if the specified core layout can handle multi-parent structures (see com.yworks.yfiles.layout.tree.GenericTreeLayouter.multiParentAllowed) and option multiParentAllowed is enabled, this stage does not hide such structures (i.e., the multi-parents are passed to the core layouter).

See also

com.yworks.yfiles.layout.router.OrganicEdgeRouter
com.yworks.yfiles.layout.router.polyline.EdgeRouter
com.yworks.yfiles.layout.router.OrthogonalEdgeRouter
com.yworks.yfiles.layout.tree.TreeLayouter
com.yworks.yfiles.base.InvalidGraphStructureException
com.yworks.yfiles.layout.tree.GenericTreeLayouter.multiParentAllowed
multiParentAllowed


Public Properties
 PropertyDefined By
 InheritedcoreLayouter : Layouter
Specifies the core layouter.
AbstractLayoutStage
  multiParentAllowed : Boolean
Specifies whether or not multi-parent structures (structures of multiple nodes that share the same predecessors as well as the same successors) are allowed.
TreeReductionStage
  nonTreeEdgeRouter : Layouter
Getter: Returns the currently set edge router for non-tree edges.
TreeReductionStage
  nonTreeEdgeSelectionKey : Object
Getter: Returns the currently set non-tree edge selection key.
TreeReductionStage
Public Methods
 MethodDefined By
  
TreeReductionStage(init:Boolean = true)
TreeReductionStage
  
canLayout(graph:LayoutGraph):Boolean
[override] Returns true.
TreeReductionStage
  
Creates a layouter that can be used to route all non-tree edges as a single straight-line segment.
TreeReductionStage
  
doLayout(graph:LayoutGraph):void
[override]
TreeReductionStage
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
TreeReductionStage
 Inherited
hashCode():int
YObject
  
[static]
TreeReductionStage
Protected Methods
 MethodDefined By
 Inherited
canLayoutCore(graph:LayoutGraph):Boolean
Queries the core layouter whether or not the given graph can be laid out.
AbstractLayoutStage
 Inherited
Invokes the layout routine of the core layouter.
AbstractLayoutStage
 Inherited
AbstractLayoutStage
 Inherited
AbstractLayoutStage
  
TreeReductionStage
  
routeNonTreeEdges(graph:LayoutGraph, nonTreeEdgeMap:EdgeMap):void
Routes the non-tree edges.
TreeReductionStage
Public Constants
 ConstantDefined By
  NON_TREE_EDGES_DPKEY : Object = TreeReductionStage#NON_TREE_EDGES_DPKEY
[static] DataProvider key that can be used to explicitly mark (some) edges that should not be considered to belong to a tree.
TreeReductionStage
Property Detail
multiParentAllowedproperty
multiParentAllowed:Boolean

Specifies whether or not multi-parent structures (structures of multiple nodes that share the same predecessors as well as the same successors) are allowed.

More precisely, if this option is enabled and the specified core layout can handle multi-parent structures (see com.yworks.yfiles.layout.tree.GenericTreeLayouter.multiParentAllowed), this stage does not hide such structures (i.e., the multi-parent structures are passed to the core layouter).


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

See also

nonTreeEdgeRouterproperty 
nonTreeEdgeRouter:Layouter

Getter: Returns the currently set edge router for non-tree edges.

Setter: Sets the edge router for non-tree edges. Very often, this method should be used in conjunction with nonTreeEdgeSelectionKey to control the set of edges that should be handled by the edge router.


Implementation
    public function get nonTreeEdgeRouter():Layouter
    public function set nonTreeEdgeRouter(value:Layouter):void

See also

nonTreeEdgeSelectionKeyproperty 
nonTreeEdgeSelectionKey:Object

Getter: Returns the currently set non-tree edge selection key.

Setter: Sets the DataProvider key that will be used by the non-tree edge router to determine the set of edges that should be routed.


Implementation
    public function get nonTreeEdgeSelectionKey():Object
    public function set nonTreeEdgeSelectionKey(value:Object):void

See also

Constructor Detail
TreeReductionStage()Constructor
public function TreeReductionStage(init:Boolean = true)



Parameters
init:Boolean (default = true)
Method Detail
canLayout()method
override public function canLayout(graph:LayoutGraph):Boolean

Returns true.

Parameters

graph:LayoutGraph

Returns
Boolean
createStraightlineRouter()method 
public function createStraightlineRouter():Layouter

Creates a layouter that can be used to route all non-tree edges as a single straight-line segment.

Returns
Layouter

See also

doLayout()method 
override public function doLayout(graph:LayoutGraph):void

Parameters

graph:LayoutGraph

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

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

newTreeReductionStage()method 
public static function newTreeReductionStage():TreeReductionStage

Returns
TreeReductionStage
routeNonTreeEdges()method 
protected function routeNonTreeEdges(graph:LayoutGraph, nonTreeEdgeMap:EdgeMap):void

Routes the non-tree edges.

Parameters

graph:LayoutGraph — graph that can contain tree and non-tree edges.
 
nonTreeEdgeMap:EdgeMap — an edge map that marks all non-tree edges in the graph with boolean value true.

Constant Detail
NON_TREE_EDGES_DPKEYConstant
public static const NON_TREE_EDGES_DPKEY:Object = TreeReductionStage#NON_TREE_EDGES_DPKEY

DataProvider key that can be used to explicitly mark (some) edges that should not be considered to belong to a tree.