Packagecom.yworks.yfiles.layout.tree
Classpublic class GenericTreeLayouter
InheritanceGenericTreeLayouter Inheritance CanonicMultiStageLayouter Inheritance YObject Inheritance Object

This class implements the basis of a generic tree layout algorithm. It can be customized easily to control the placement and order of child nodes, the edge routing and port assignment on a per node basis. Using com.yworks.yfiles.base.DataProvider s, one can specify objects that implement the com.yworks.yfiles.layout.tree.NodePlacer interface. Those instances are responsible for the arrangement of the subtrees of the node's they are registered with and the routing of the connecting edges. Likewise instances of com.yworks.yfiles.layout.tree.PortAssignment are responsible for the assignment of the ports and Comparator instances can be used to sort the outgoing edges of each node. Customization of this class should be done via own implementations of the com.yworks.yfiles.layout.tree.NodePlacer, possibly com.yworks.yfiles.layout.tree.PortAssignment, and Comparator instances.

Here is an example output that shows multiple different configurations in one layout using com.yworks.yfiles.layout.tree.DefaultNodePlacer instances:

See also

com.yworks.yfiles.layout.tree.NodePlacer
com.yworks.yfiles.layout.tree.DefaultNodePlacer
com.yworks.yfiles.layout.tree.PortAssignment
com.yworks.yfiles.layout.tree.DefaultPortAssignment
com.yworks.yfiles.base.DataProvider
Comparator


Public Properties
 PropertyDefined By
 InheritedcomponentLayouter : LayoutStage
Specifies the LayoutStage responsible for laying out the connected components of the graph.
CanonicMultiStageLayouter
 InheritedcomponentLayouterEnabled : Boolean
Getter: Returns whether or not ComponentLayouter is enabled.
CanonicMultiStageLayouter
  defaultChildComparator : Comparator
Getter: Returns the default Comparator instance or null that will be used for those subtrees, that don't have their own specific instance set via the appropriate DataProvider.
GenericTreeLayouter
  defaultLeafPlacer : NodePlacer
Specifies the default com.yworks.yfiles.layout.tree.NodePlacer instance that will be used for the leaf nodes of the tree.
GenericTreeLayouter
  defaultNodePlacer : NodePlacer
Specifies the default com.yworks.yfiles.layout.tree.NodePlacer instance that will be used for those subtrees, that don't have their own specific instance set via the appropriate DataProvider.
GenericTreeLayouter
  defaultPortAssignment : PortAssignment
Specifies the default com.yworks.yfiles.layout.tree.PortAssignment instance that will be used for those subtrees, that don't have their own specific instance set via the appropriate DataProvider.
GenericTreeLayouter
  groupingSupported : Boolean
Whether or not grouping support should be enabled.
GenericTreeLayouter
 InheritedgroupNodeHider : LayoutStage
Specifies the LayoutStage that is responsible for hiding away grouping information for the layout algorithm.
CanonicMultiStageLayouter
 InheritedhideGroupNodes : Boolean
Specifies whether or not to hide away group nodes before the layout begins.
CanonicMultiStageLayouter
  integratedEdgeLabeling : Boolean
Getter: Returns whether integrated edge labeling is enabled (extension of the shapes of subtrees with the labels of the edges).
GenericTreeLayouter
  integratedNodeLabeling : Boolean
Getter: Returns whether integrated node labeling is enabled (extension of the shapes of the nodes with its labels).
GenericTreeLayouter
 InheritedlabelLayouter : LayoutStage
Getter: Returns the algorithm used for placing labels.
CanonicMultiStageLayouter
 InheritedlabelLayouterEnabled : Boolean
Getter: Returns whether or not LabelLayouter is enabled.
CanonicMultiStageLayouter
 InheritedlayoutOrientation : int
Specifies the main layout orientation.
CanonicMultiStageLayouter
  multiParentAllowed : Boolean
Determines whether or not multi-parent structures are allowed for this tree layout.
GenericTreeLayouter
 InheritedorientationLayouter : LayoutStage
Specifies the LayoutStage that is responsible for changing the orientation of the computed layout.
CanonicMultiStageLayouter
 InheritedorientationLayouterEnabled : Boolean
Getter: Returns whether or not the OrientationLayouter is enabled.
CanonicMultiStageLayouter
 InheritedparallelEdgeLayouter : LayoutStage
Getter: Returns the LayoutStage responsible for routing parallel edges.
CanonicMultiStageLayouter
 InheritedparallelEdgeLayouterEnabled : Boolean
Getter: Returns whether or not the ParallelEdgeLayouter is enabled.
CanonicMultiStageLayouter
 InheritedselfLoopLayouter : LayoutStage
Getter: Returns the LayoutStage used for routing Self-loops.
CanonicMultiStageLayouter
 InheritedselfLoopLayouterEnabled : Boolean
Getter: Returns whether or not the SelfLoopLayouter is enabled.
CanonicMultiStageLayouter
 InheritedsubgraphLayouter : LayoutStage
Specifies the LayoutStage that is responsible for constraining the layout process to a subgraph of the target graph.
CanonicMultiStageLayouter
 InheritedsubgraphLayouterEnabled : Boolean
Getter: Returns whether or not the SubgraphLayouter is enabled.
CanonicMultiStageLayouter
Protected Properties
 PropertyDefined By
  graph : LayoutGraph
the graph this layout is running on
GenericTreeLayouter
  sourceGroupDataAcceptor : DataAcceptor
[read-only] Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite edge grouping at source temporarily for use during the layout.
GenericTreeLayouter
  sourcePortConstraintDataAcceptor : DataAcceptor
[read-only] Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite the source port constraint ( com.yworks.yfiles.layout.PortConstraint temporarily for use during the layout.
GenericTreeLayouter
  targetGroupDataAcceptor : DataAcceptor
[read-only] Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite edge grouping at target temporarily for use during the layout.
GenericTreeLayouter
  targetPortConstraintDataAcceptor : DataAcceptor
[read-only] Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite the target port constraint ( com.yworks.yfiles.layout.PortConstraint temporarily for use during the layout.
GenericTreeLayouter
Public Methods
 MethodDefined By
  
GenericTreeLayouter(init:Boolean = true)
Creates a new GenericTreeLayouter with a default com.yworks.yfiles.layout.tree.NodePlacer, a default com.yworks.yfiles.layout.tree.PortAssignment instance and no default edge comparator.
GenericTreeLayouter
 Inherited
Appends a stage to the layout pipeline.
CanonicMultiStageLayouter
 Inherited
Returns a layout for the given layout graph.
CanonicMultiStageLayouter
 Inherited
Returns a layout for the given graph interface and layout.
CanonicMultiStageLayouter
 Inherited
canLayout(graph:LayoutGraph):Boolean
Tests whether or not the given graph can be laid out by this layouter.
CanonicMultiStageLayouter
  
canLayoutCore(graph:LayoutGraph):Boolean
[override]
GenericTreeLayouter
 Inherited
doLayout(layoutGraph:LayoutGraph):void
Calculates a layout for the given graph.
CanonicMultiStageLayouter
 Inherited
Calculates a layout for the given graph interface and layout.
CanonicMultiStageLayouter
  
[override]
GenericTreeLayouter
 Inherited
Disables all layout stages and performs only the core layouter.
CanonicMultiStageLayouter
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
GenericTreeLayouter
 Inherited
hashCode():int
YObject
  
[static] Creates a new GenericTreeLayouter with a default com.yworks.yfiles.layout.tree.NodePlacer, a default com.yworks.yfiles.layout.tree.PortAssignment instance and no default edge comparator.
GenericTreeLayouter
 Inherited
Prepends a stage to the layout pipeline.
CanonicMultiStageLayouter
 Inherited
Removes a LayoutStage that has been previously added by the methods appendStage() or prependStage().
CanonicMultiStageLayouter
Protected Methods
 MethodDefined By
 Inherited
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.
CanonicMultiStageLayouter
 Inherited
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.
CanonicMultiStageLayouter
  
This method is called initially with the graph to calculate a rooted tree.
GenericTreeLayouter
  
This method returns a Comparator instance or null that will be used for the sorting of the outgoing edges at the given Node.
GenericTreeLayouter
  
This method returns a com.yworks.yfiles.layout.tree.NodePlacer instance that will be used for the placement of the root node and the subtree shapes.
GenericTreeLayouter
  
Factory method that creates a SubtreeShape for a given node, that consists of the bounds of the node only.
GenericTreeLayouter
  
This method returns a com.yworks.yfiles.layout.tree.PortAssignment instance that will be used for the port assignments at the given Node.
GenericTreeLayouter
  
getRootsArray(root:Node):Vector.<Object>
Returns the array of the nodes to be laid out.
GenericTreeLayouter
  
Provides access to the SubTreeShape instances for each node.
GenericTreeLayouter
 Inherited
CanonicMultiStageLayouter
  
Initializes this object.
GenericTreeLayouter
  
This is the core method of the algorithm.
GenericTreeLayouter
  
reverseEdges(reversedEdges:EdgeList):void
This method is used for the actual reversal of edges.
GenericTreeLayouter
Public Constants
 ConstantDefined By
  CHILD_COMPARATOR_DPKEY : Object = y.layout.tree.GenericTreeLayouter.CHILD_COMPARATOR_DPKEY
[static] DataProvider key that can be registered with the graph to provide each node with its own Comparator instance that will be used to sort its outgoing edges.
GenericTreeLayouter
  CRITICAL_EDGE_DPKEY : Object = y.layout.tree.GenericTreeLayouter.CRITICAL_EDGE_DPKEY
[static] com.yworks.yfiles.base.DataProvider key used to store the priority (integer values) for "critical" edges.
GenericTreeLayouter
  MULTI_PARENT_DESCRIPTOR_DPKEY : Object = y.layout.tree.GenericTreeLayouter.MULTI_PARENT_DESCRIPTOR_DPKEY
[static] com.yworks.yfiles.base.DataProvider key used to retrieve com.yworks.yfiles.layout.tree.MultiParentDescriptor instances for each node that belongs to a multi-parent structure.
GenericTreeLayouter
  NODE_PLACER_DPKEY : Object = y.layout.tree.GenericTreeLayouter.NODE_PLACER_DPKEY
[static] DataProvider key that can be registered with the graph to provide each node with its own com.yworks.yfiles.layout.tree.NodePlacer instance.
GenericTreeLayouter
  PORT_ASSIGNMENT_DPKEY : Object = y.layout.tree.GenericTreeLayouter.PORT_ASSIGNMENT_DPKEY
[static] DataProvider key that can be registered with the graph to provide each node with its own com.yworks.yfiles.layout.tree.PortAssignment instance.
GenericTreeLayouter
Property Detail
defaultChildComparatorproperty
defaultChildComparator:Comparator

Getter: Returns the default Comparator instance or null that will be used for those subtrees, that don't have their own specific instance set via the appropriate DataProvider.

Setter: Sets the default Comparator instance that will be used for those subtrees that don't have their own specific instance set via the appropriate DataProvider. This can be set to null which implies no sorting by default.


Implementation
    public function get defaultChildComparator():Comparator
    public function set defaultChildComparator(value:Comparator):void

See also

Comparator
defaultLeafPlacerproperty 
defaultLeafPlacer:NodePlacer

Specifies the default com.yworks.yfiles.layout.tree.NodePlacer instance that will be used for the leaf nodes of the tree.


Implementation
    public function get defaultLeafPlacer():NodePlacer
    public function set defaultLeafPlacer(value:NodePlacer):void

See also

defaultNodePlacerproperty 
defaultNodePlacer:NodePlacer

Specifies the default com.yworks.yfiles.layout.tree.NodePlacer instance that will be used for those subtrees, that don't have their own specific instance set via the appropriate DataProvider. This should be non-null, unless it is guaranteed that for any node in the graph there is a specific instance provided by the registered DataProvider instance.


Implementation
    public function get defaultNodePlacer():NodePlacer
    public function set defaultNodePlacer(value:NodePlacer):void

See also

defaultPortAssignmentproperty 
defaultPortAssignment:PortAssignment

Specifies the default com.yworks.yfiles.layout.tree.PortAssignment instance that will be used for those subtrees, that don't have their own specific instance set via the appropriate DataProvider. This should be non-null, unless it is guaranteed that for any node in the graph there is a specific instance provided by the registered DataProvider instance.


Implementation
    public function get defaultPortAssignment():PortAssignment
    public function set defaultPortAssignment(value:PortAssignment):void

See also

graphproperty 
protected var graph:LayoutGraph

the graph this layout is running on

groupingSupportedproperty 
groupingSupported:Boolean

Whether or not grouping support should be enabled. Note that the grouping only works correctly, if each group represents a complete subtree. This means that for each group there is a node v such that the group contains exactly v and all its descendants.


Implementation
    public function get groupingSupported():Boolean
    public function set groupingSupported(value:Boolean):void
integratedEdgeLabelingproperty 
integratedEdgeLabeling:Boolean

Getter: Returns whether integrated edge labeling is enabled (extension of the shapes of subtrees with the labels of the edges).

Setter: Specifies whether or not to use integrated edge labeling (extension of the shapes of the subtrees with the labels for the edges).


Implementation
    public function get integratedEdgeLabeling():Boolean
    public function set integratedEdgeLabeling(value:Boolean):void
integratedNodeLabelingproperty 
integratedNodeLabeling:Boolean

Getter: Returns whether integrated node labeling is enabled (extension of the shapes of the nodes with its labels).

Setter: Specifies whether or not to use integrated node labeling. If set to true, the shape of the nodes will be extended with the shapes of its labels.


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

Determines whether or not multi-parent structures are allowed for this tree layout.

If multi-parent structures are allowed, the directed input graph may contain structures of multiple nodes that share the same predecessors as well as the same successors. All nodes belonging to such a structure are placed side by side and the incident edges are routed in a bus-style.

Note that if the input graph contains groups, all nodes belonging to the same multi-parent structure must be associated with the same group node, i.e., it is not possible to assign these nodes to different group nodes.

By default multi-parent structures are not allowed.

As for the different ways in which the com.yworks.yfiles.layout.tree.NodePlacer s route their edges, multi-parent structures only work for some NodePlacers:


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

See also

sourceGroupDataAcceptorproperty 
sourceGroupDataAcceptor:DataAcceptor  [read-only]

Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite edge grouping at source temporarily for use during the layout.


Implementation
    protected function get sourceGroupDataAcceptor():DataAcceptor

See also

sourcePortConstraintDataAcceptorproperty 
sourcePortConstraintDataAcceptor:DataAcceptor  [read-only]

Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite the source port constraint ( com.yworks.yfiles.layout.PortConstraint temporarily for use during the layout.


Implementation
    protected function get sourcePortConstraintDataAcceptor():DataAcceptor

See also

targetGroupDataAcceptorproperty 
targetGroupDataAcceptor:DataAcceptor  [read-only]

Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite edge grouping at target temporarily for use during the layout.


Implementation
    protected function get targetGroupDataAcceptor():DataAcceptor

See also

targetPortConstraintDataAcceptorproperty 
targetPortConstraintDataAcceptor:DataAcceptor  [read-only]

Returns a com.yworks.yfiles.base.DataAcceptor implementation that can be used to overwrite the target port constraint ( com.yworks.yfiles.layout.PortConstraint temporarily for use during the layout.


Implementation
    protected function get targetPortConstraintDataAcceptor():DataAcceptor

See also

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

Creates a new GenericTreeLayouter with a default com.yworks.yfiles.layout.tree.NodePlacer, a default com.yworks.yfiles.layout.tree.PortAssignment instance and no default edge comparator.

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.

See also

Method Detail
canLayoutCore()method
override public function canLayoutCore(graph:LayoutGraph):Boolean

Parameters

graph:LayoutGraph

Returns
Boolean
directTree()method 
protected function directTree():EdgeList

This method is called initially with the graph to calculate a rooted tree. It returns a list of edges that have to be reversed in order for the graph to become a valid rooted and directed tree.

Returns
EdgeList — an EdgeList containing all the edges that need to be reversed
doLayoutCore()method 
override public function doLayoutCore(graph:LayoutGraph):void

Parameters

graph:LayoutGraph

getChildNodeInEdgeComparator()method 
protected function getChildNodeInEdgeComparator(localRoot:Node):Comparator

This method returns a Comparator instance or null that will be used for the sorting of the outgoing edges at the given Node. This method is allowed to return a shared instance for multiple different nodes, the instances are not used after subsequent calls to this method.

Parameters

localRoot:Node — the root of the local subtree

Returns
Comparator — a readily configured instance of Comparator or null that can be used sort the outgoing edges of the given node

See also

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

Returns
Class
getNodePlacer()method 
protected function getNodePlacer(localRoot:Node):NodePlacer

This method returns a com.yworks.yfiles.layout.tree.NodePlacer instance that will be used for the placement of the root node and the subtree shapes. This method is allowed to return a shared instance for multiple different nodes, the instances are not used after subsequent calls to this method.

Parameters

localRoot:Node — the root of the local subtree

Returns
NodePlacer — a readily configured instance of com.yworks.yfiles.layout.tree.NodePlacer that can be used to layout the subtree under the given local root node.

See also

getNodeShape()method 
protected function getNodeShape(node:Node):GenericTreeLayouter_SubtreeShape

Factory method that creates a SubtreeShape for a given node, that consists of the bounds of the node only.

Parameters

node:Node — the node that will be represented by a SubTreeShape instance

Returns
GenericTreeLayouter_SubtreeShape — a newly created SubtreeShape describing the bounds of the given node
getPortAssignment()method 
protected function getPortAssignment(localRoot:Node):PortAssignment

This method returns a com.yworks.yfiles.layout.tree.PortAssignment instance that will be used for the port assignments at the given Node. This method is allowed to return a shared instance for multiple different nodes, the instances are not used after subsequent calls to this method.

Parameters

localRoot:Node — the root of the local subtree

Returns
PortAssignment — a readily configured instance of com.yworks.yfiles.layout.tree.PortAssignment that can be used to assign the ports of the edges at the given local root node.

See also

getRootsArray()method 
protected function getRootsArray(root:Node):Vector.<Object>

Returns the array of the nodes to be laid out. The order of the elements is chosen so that no parent is laid out before one of its successors.

Parameters

root:Node — the node that should be used as the root of the tree

Returns
Vector.<Object> — all nodes in the graph that should be laid out in order
getSubtreeShape()method 
protected function getSubtreeShape(localRoot:Node):GenericTreeLayouter_SubtreeShape

Provides access to the SubTreeShape instances for each node. Those instances should be modified only during the layout of the parent node.

Parameters

localRoot:Node — the node for which the subtree should be returned

Returns
GenericTreeLayouter_SubtreeShape — the SubTreeShape instance if it has been calculated already or null otherwise
initGenericTreeLayouter()method 
protected final function initGenericTreeLayouter():void

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

See also

layoutRoot()method 
protected function layoutRoot(localRoot:Node):GenericTreeLayouter_SubtreeShape

This is the core method of the algorithm. This method is invoked for each node in the tree exactly once in such an order that all of the child nodes of each node have already been calculated by the time of the method invocation. This method uses the getSubtreeShape() callback to retrieve the shapes of the subtrees of all of the children of localRoot.

Parameters

localRoot:Node — The root to be laid out together with its SubtreeShapes

Returns
GenericTreeLayouter_SubtreeShape — the combined SubtreeShape of the local root node and all of its children and connecting edges

See also

newGenericTreeLayouter()method 
public static function newGenericTreeLayouter():GenericTreeLayouter

Creates a new GenericTreeLayouter with a default com.yworks.yfiles.layout.tree.NodePlacer, a default com.yworks.yfiles.layout.tree.PortAssignment instance and no default edge comparator.

Returns
GenericTreeLayouter

See also

reverseEdges()method 
protected function reverseEdges(reversedEdges:EdgeList):void

This method is used for the actual reversal of edges. It will be called initially after the directTree() method and finally after the layout has been calculated.

Parameters

reversedEdges:EdgeList — the edges that will be reversed by this method

See also

Constant Detail
CHILD_COMPARATOR_DPKEYConstant
public static const CHILD_COMPARATOR_DPKEY:Object = y.layout.tree.GenericTreeLayouter.CHILD_COMPARATOR_DPKEY

DataProvider key that can be registered with the graph to provide each node with its own Comparator instance that will be used to sort its outgoing edges.

See also

Comparator
CRITICAL_EDGE_DPKEYConstant 
public static const CRITICAL_EDGE_DPKEY:Object = y.layout.tree.GenericTreeLayouter.CRITICAL_EDGE_DPKEY

com.yworks.yfiles.base.DataProvider key used to store the priority (integer values) for "critical" edges. The layouter tries to align each node pair that is connected by a critical edge (integer value > 0). This feature can for example be utilized to highlight different edge paths that are relevant for a user. Conflicts between different critical edges are always resolved in favor of the higher priority.

Critical edges will always align the centers of source and target node, thus replace the current root alignment of the com.yworks.yfiles.layout.tree.NodePlacer.

Note that the critical edge may not be straight if subtrees are rotated or port constraints are assigned.

This feature is only supported by the following NodePlacers:

See also

MULTI_PARENT_DESCRIPTOR_DPKEYConstant 
public static const MULTI_PARENT_DESCRIPTOR_DPKEY:Object = y.layout.tree.GenericTreeLayouter.MULTI_PARENT_DESCRIPTOR_DPKEY

com.yworks.yfiles.base.DataProvider key used to retrieve com.yworks.yfiles.layout.tree.MultiParentDescriptor instances for each node that belongs to a multi-parent structure. The returned descriptor affects the layout of the multi-parent structure.

Note that this key is only considered if multi-parent structures are allowed, see multiParentAllowed . Furthermore, all nodes belonging to the same multi-parent structure should return the same descriptor.

See also

NODE_PLACER_DPKEYConstant 
public static const NODE_PLACER_DPKEY:Object = y.layout.tree.GenericTreeLayouter.NODE_PLACER_DPKEY

DataProvider key that can be registered with the graph to provide each node with its own com.yworks.yfiles.layout.tree.NodePlacer instance.

See also

PORT_ASSIGNMENT_DPKEYConstant 
public static const PORT_ASSIGNMENT_DPKEY:Object = y.layout.tree.GenericTreeLayouter.PORT_ASSIGNMENT_DPKEY

DataProvider key that can be registered with the graph to provide each node with its own com.yworks.yfiles.layout.tree.PortAssignment instance.

See also