Packagecom.yworks.yfiles.layout.hierarchic
Classpublic class HierarchicLayouter
InheritanceHierarchicLayouter Inheritance CanonicMultiStageLayouter Inheritance YObject Inheritance Object
Subclasses HierarchicGroupLayouter

This class implements a layout algorithm for drawing directed graphs in a hierarchic way.

The algorithm places nodes in different horizontal layers, in such a way that most edges in the graph run from top to bottom.

Here is a sample output of the algorithm using top to bottom orientation and PENDULUM layout style.

HierarchicLayouter can handle port constraints. See classes com.yworks.yfiles.layout.PortConstraint and com.yworks.yfiles.layout.PortConstraintKeys on how to setup port constraint information for this algorithm.

HierarchicLayouter can consider edge label data when laying out a graph. That means that the layout of edge labels will be part of the resulting layout and the layout of nodes and edges is chosen in such a way that the edge labels do not conflict with the rest of the layout. See classes com.yworks.yfiles.layout.LabelLayoutData, com.yworks.yfiles.layout.LabelLayoutConstants com.yworks.yfiles.layout.LabelLayoutKeys and com.yworks.yfiles.layout.LabelLayoutTranslator on how to setup the integrated edge labeling algorithm.

See also

PENDULUM
com.yworks.yfiles.layout.PortConstraint
com.yworks.yfiles.layout.PortConstraintKeys
com.yworks.yfiles.layout.LabelLayoutData
com.yworks.yfiles.layout.LabelLayoutConstants
com.yworks.yfiles.layout.LabelLayoutKeys
com.yworks.yfiles.layout.LabelLayoutTranslator


Public Properties
 PropertyDefined By
  bendReductionThreshold : int
Specifies the limit, when bends are removed and a straight line is drawn instead.
HierarchicLayouter
 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
  drawer : Drawer
Specifies the Drawer, which is responsible for the third phase of the algorithm.
HierarchicLayouter
 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
 InheritedlabelLayouter : LayoutStage
Getter: Returns the algorithm used for placing labels.
CanonicMultiStageLayouter
 InheritedlabelLayouterEnabled : Boolean
Getter: Returns whether or not LabelLayouter is enabled.
CanonicMultiStageLayouter
  layerer : OldLayerer
Specifies the Layerer, which is responsible for the first phase of the algorithm.
HierarchicLayouter
  layeringStrategy : int
Getter: Returns the currently set layering strategy.
HierarchicLayouter
  layerSequencer : LayerSequencer
Specifies the LayerSequencer, which is responsible for the second phase of the algorithm.
HierarchicLayouter
 InheritedlayoutOrientation : int
Specifies the main layout orientation.
CanonicMultiStageLayouter
  layoutStyle : int
Getter: Returns the currently set layout style or -1 if the style cannot be determined Setter: Sets the layout style for this layouter.
HierarchicLayouter
  maximalDuration : uint
Specifies a time limit for the algorithm in milliseconds
HierarchicLayouter
  mementoSupport : MementoSupport
[read-only] Gets the cookie for the memento support of the hierarchic layout algorithm.
HierarchicLayouter
  minimalEdgeDistance : Number
Specifies the minimal distance between edges that run in parallel.
HierarchicLayouter
  minimalFirstSegmentLength : Number
Specifies the minimal length of first and last edge segments for edge routing.
HierarchicLayouter
  minimalLayerDistance : Number
Specifies the minimal distance between two layers.
HierarchicLayouter
  minimalNodeDistance : Number
Specifies the minimal distance between two nodes in the same layer.
HierarchicLayouter
  optimizePortConstraints : Boolean
Specifies whether the algorithm should try to optimize PortConstraints, that are either com.yworks.yfiles.layout.PortConstraint.ANY_SIDE or null.
HierarchicLayouter
  optimizeSameLayerEdgeRouting : Boolean
Getter: Returns whether the algorithm tries to optimize the routing of same layer edges whose PortConstraints don't impose the routing.
HierarchicLayouter
 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
  removeFalseCrossings : Boolean
Specifies whether or not false crossings should be removed from the layout.
HierarchicLayouter
  routingStyle : int
Getter: Returns the routing style being used.
HierarchicLayouter
 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
Public Methods
 MethodDefined By
  
HierarchicLayouter(init:Boolean = true)
Instantiates a new HierarchicLayouter.
HierarchicLayouter
 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] Always returns true.
HierarchicLayouter
  
Disposes the memento support if it is existent, i.e.
HierarchicLayouter
 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] Layout the given graph.
HierarchicLayouter
 Inherited
Disables all layout stages and performs only the core layouter.
CanonicMultiStageLayouter
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
HierarchicLayouter
 Inherited
hashCode():int
YObject
  
[static] Instantiates a new HierarchicLayouter.
HierarchicLayouter
 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
  
getLayerSequence(g:LayoutGraph, LAYER_KEY:NodeMap, maxLayer:int):Vector.<Object>
Determines the order of the nodes within their layers.
HierarchicLayouter
 Inherited
CanonicMultiStageLayouter
  
Initializes this object.
HierarchicLayouter
Public Constants
 ConstantDefined By
  LAYERING_BFS : int = 4
[static] Layering strategy specifier.
HierarchicLayouter
  LAYERING_FROM_SKETCH : int = 5
[static] Layering strategy specifier.
HierarchicLayouter
  LAYERING_HIERARCHICAL_DOWNSHIFT : int = 3
[static] Layering strategy specifier.
HierarchicLayouter
  LAYERING_HIERARCHICAL_OPTIMAL : int = 1
[static] Layering strategy specifier.
HierarchicLayouter
  LAYERING_HIERARCHICAL_TIGHT_TREE : int = 2
[static] Layering strategy specifier.
HierarchicLayouter
  LAYERING_HIERARCHICAL_TOPMOST : int = 0
[static] Layering strategy specifier.
HierarchicLayouter
  LAYERING_STRATEGY_UNKNOWN : int = -1
[static] Dummy layering strategy specifier.
HierarchicLayouter
  LAYERING_USER_DEFINED : int = 6
[static] Layering strategy specifier.
HierarchicLayouter
  LINEAR_SEGMENTS : int = 1
[static] Layout style specifier.
HierarchicLayouter
  MEDIAN_SIMPLEX : int = 5
[static] Layout style specifier.
HierarchicLayouter
  PENDULUM : int = 0
[static] Layout style specifier.
HierarchicLayouter
  POLYLINE : int = 2
[static] Layout style specifier.
HierarchicLayouter
  ROUTE_ORTHOGONAL : int = 1
[static] Edge routing style specifier.
HierarchicLayouter
  ROUTE_POLYLINE : int = 0
[static] Edge routing style specifier.
HierarchicLayouter
  SIMPLEX : int = 4
[static] Layout style specifier.
HierarchicLayouter
  TREE : int = 3
[static] Layout style specifier.
HierarchicLayouter
Property Detail
bendReductionThresholdproperty
bendReductionThreshold:int

Specifies the limit, when bends are removed and a straight line is drawn instead.


Implementation
    public function get bendReductionThreshold():int
    public function set bendReductionThreshold(value:int):void
drawerproperty 
drawer:Drawer

Specifies the Drawer, which is responsible for the third phase of the algorithm. The Drawer is responsible for the layout style of this layouter.


Implementation
    public function get drawer():Drawer
    public function set drawer(value:Drawer):void
layererproperty 
layerer:OldLayerer

Specifies the Layerer, which is responsible for the first phase of the algorithm.


Implementation
    public function get layerer():OldLayerer
    public function set layerer(value:OldLayerer):void
layeringStrategyproperty 
layeringStrategy:int

Getter: Returns the currently set layering strategy.

Setter: Sets a predefined layering strategy. This layouter assigns the nodes to separate layers. The nodes within each layer will be placed on the same horizontal line. The layers will be arranged vertically starting with the small-numbered layers. The rank of a node is the number of the layer it belongs to.

An important layering strategy for the hierarchic layout style is called Hierarchical Layering. A hierarchical layering tries to assign nodes to layers in a way that as much as possible edges of the graph will point to the main layout direction, i.e. the start nodes of the edges will have a smaller rank than the corresponding end nodes. Also, a hierarchical layering will never put two connected nodes in the same layer.

By default the layering strategy LAYERING_HIERARCHICAL_TIGHT_TREE is set.


Implementation
    public function get layeringStrategy():int
    public function set layeringStrategy(value:int):void

See also

layerSequencerproperty 
layerSequencer:LayerSequencer

Specifies the LayerSequencer, which is responsible for the second phase of the algorithm.


Implementation
    public function get layerSequencer():LayerSequencer
    public function set layerSequencer(value:LayerSequencer):void
layoutStyleproperty 
layoutStyle:int

Getter: Returns the currently set layout style or -1 if the style cannot be determined

Setter: Sets the layout style for this layouter. Possible values are POLYLINE, LINEAR_SEGMENTS, MEDIAN_SIMPLEX, SIMPLEX, PENDULUM, and TREE. The default is set to LINEAR_SEGMENTS


Implementation
    public function get layoutStyle():int
    public function set layoutStyle(value:int):void

See also

maximalDurationproperty 
maximalDuration:uint

Specifies a time limit for the algorithm in milliseconds


Implementation
    public function get maximalDuration():uint
    public function set maximalDuration(value:uint):void
mementoSupportproperty 
mementoSupport:MementoSupport  [read-only]

Gets the cookie for the memento support of the hierarchic layout algorithm. If there was no memento support registered with this instance before, this call will instantiate the memento support, otherwise the existing instance will be returned.


Implementation
    public function get mementoSupport():MementoSupport
minimalEdgeDistanceproperty 
minimalEdgeDistance:Number

Specifies the minimal distance between edges that run in parallel.


Implementation
    public function get minimalEdgeDistance():Number
    public function set minimalEdgeDistance(value:Number):void
minimalFirstSegmentLengthproperty 
minimalFirstSegmentLength:Number

Specifies the minimal length of first and last edge segments for edge routing. This will be used for orthogonal edge routing, self-loops, same layer edges and bus connectors.


Implementation
    public function get minimalFirstSegmentLength():Number
    public function set minimalFirstSegmentLength(value:Number):void
minimalLayerDistanceproperty 
minimalLayerDistance:Number

Specifies the minimal distance between two layers.


Implementation
    public function get minimalLayerDistance():Number
    public function set minimalLayerDistance(value:Number):void
minimalNodeDistanceproperty 
minimalNodeDistance:Number

Specifies the minimal distance between two nodes in the same layer.


Implementation
    public function get minimalNodeDistance():Number
    public function set minimalNodeDistance(value:Number):void
optimizePortConstraintsproperty 
optimizePortConstraints:Boolean

Specifies whether the algorithm should try to optimize PortConstraints, that are either com.yworks.yfiles.layout.PortConstraint.ANY_SIDE or null.

Default is false.


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

See also

optimizeSameLayerEdgeRoutingproperty 
optimizeSameLayerEdgeRouting:Boolean

Getter: Returns whether the algorithm tries to optimize the routing of same layer edges whose PortConstraints don't impose the routing.

Setter: Determines whether the algorithm should try to optimize the routing of same layer edges whose PortConstraints don't impose the routing. Default is true.


Implementation
    public function get optimizeSameLayerEdgeRouting():Boolean
    public function set optimizeSameLayerEdgeRouting(value:Boolean):void
removeFalseCrossingsproperty 
removeFalseCrossings:Boolean

Specifies whether or not false crossings should be removed from the layout. A false crossing is a crossing between two edges that connect to the same upper or lower node.


Implementation
    public function get removeFalseCrossings():Boolean
    public function set removeFalseCrossings(value:Boolean):void
routingStyleproperty 
routingStyle:int

Getter: Returns the routing style being used.

Setter: Sets the edge routing style. Possible values are ROUTE_POLYLINE and ROUTE_ORTHOGONAL. By default ROUTE_POLYLINE is set.


Implementation
    public function get routingStyle():int
    public function set routingStyle(value:int):void

See also

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

Instantiates a new HierarchicLayouter.

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
canLayoutCore()method
override public function canLayoutCore(graph:LayoutGraph):Boolean

Always returns true.

Parameters

graph:LayoutGraph

Returns
Boolean
disposeMementoSupport()method 
public function disposeMementoSupport():void

Disposes the memento support if it is existent, i.e. if it has been queried before by getMementoSupport()

doLayoutCore()method 
override public function doLayoutCore(g:LayoutGraph):void

Layout the given graph.

Parameters

g:LayoutGraph

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

Returns
Class
getLayerSequence()method 
protected function getLayerSequence(g:LayoutGraph, LAYER_KEY:NodeMap, maxLayer:int):Vector.<Object>

Determines the order of the nodes within their layers.

Parameters

g:LayoutGraph
 
LAYER_KEY:NodeMap
 
maxLayer:int

Returns
Vector.<Object>
initHierarchicLayouter()method 
protected final function initHierarchicLayouter():void

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

See also

newHierarchicLayouter()method 
public static function newHierarchicLayouter():HierarchicLayouter

Instantiates a new HierarchicLayouter.

Returns
HierarchicLayouter
Constant Detail
LAYERING_BFSConstant
public static const LAYERING_BFS:int = 4

Layering strategy specifier. Layering based on a breadth first search (bfs). All edges will span at most one layer in the resulting drawing. Edges between nodes that belong to the same layer are possible. The nodes that will be placed in the first layer can be provided by a data provider bound to the input graph using the key com.yworks.yfiles.layout.hierarchic.BFSLayerer.CORE_NODES. If this data provider is not given, then nodes that have no incoming edges are placed in the first layer.

See also

LAYERING_FROM_SKETCHConstant 
public static const LAYERING_FROM_SKETCH:int = 5

Layering strategy specifier. A layer assignment strategy that uses the initial y-coordinates of the nodes (x-coordinates when the layout orientation is horizontal) to determine a node layering. It tries to find a layering that is similar to the one in the input graph. When this layering strategy is used, the layouter may place nodes in the same layer, even though they are connected by an edge. These inner layer edges are always routed in an orthogonal style.

See also

LAYERING_HIERARCHICAL_DOWNSHIFTConstant 
public static const LAYERING_HIERARCHICAL_DOWNSHIFT:int = 3

Layering strategy specifier. A fast heuristic that improves the the ranking done by LAYERING_HIERARCHICAL_TOPMOST by down shifting some nodes in the layering. The quality is usually worse than the one produced by Tight Tree Heuristic.

See also

LAYERING_HIERARCHICAL_OPTIMALConstant 
public static const LAYERING_HIERARCHICAL_OPTIMAL:int = 1

Layering strategy specifier. An optimal hierarchical layering strategy. The layer distance of an edge is the absolute difference between the layer numbers of its source and target node. Layer assignment will be done in such a way that the overall sum of the layer distances of all edges in the layout is minimal.

See also

LAYERING_HIERARCHICAL_TIGHT_TREEConstant 
public static const LAYERING_HIERARCHICAL_TIGHT_TREE:int = 2

Layering strategy specifier. A heuristic that approximates the ranking done by LAYERING_HIERARCHICAL_OPTIMAL.

See also

LAYERING_HIERARCHICAL_TOPMOSTConstant 
public static const LAYERING_HIERARCHICAL_TOPMOST:int = 0

Layering strategy specifier. A simple hierarchical layering variant. All nodes with indegree zero will be assigned to the topmost layer of the layout. The number of separate layers will be as small as possible.

See also

LAYERING_STRATEGY_UNKNOWNConstant 
public static const LAYERING_STRATEGY_UNKNOWN:int = -1

Dummy layering strategy specifier. Returned by layeringStrategy if the current strategy is not known.

See also

LAYERING_USER_DEFINEDConstant 
public static const LAYERING_USER_DEFINED:int = 6

Layering strategy specifier. The ranks of the nodes will be given by the user. The node ranks must be provided by a data provider bound to the input graph using the key com.yworks.yfiles.layout.hierarchic.GivenLayersLayerer.LAYER_ID_KEY . Like LAYERING_FROM_SKETCH this layering allows inner layer edges.

See also

LINEAR_SEGMENTSConstant 
public static const LINEAR_SEGMENTS:int = 1

Layout style specifier. Draws the edges in a way that at most two bends are used per edge unless two edges cross.

MEDIAN_SIMPLEXConstant 
public static const MEDIAN_SIMPLEX:int = 5

Layout style specifier. Similar to SIMPLEX but more symmetric for the cost of a few more bends.

PENDULUMConstant 
public static const PENDULUM:int = 0

Layout style specifier. Draws the edges in a way that nodes are balanced nicely and the number of bends on an edge is kept small.

Note that this layout style is more time consuming than most of the other ones.

POLYLINEConstant 
public static const POLYLINE:int = 2

Layout style specifier. Draws the edges in a polyline fashion. The layout tends to be very compact but the number of edge bends may be high.

ROUTE_ORTHOGONALConstant 
public static const ROUTE_ORTHOGONAL:int = 1

Edge routing style specifier. Routes the edges orthogonally, i.e. all edge segments are either vertically or horizontally aligned.

ROUTE_POLYLINEConstant 
public static const ROUTE_POLYLINE:int = 0

Edge routing style specifier. Routes the edges as polylines.

SIMPLEXConstant 
public static const SIMPLEX:int = 4

Layout style specifier. Gives tight layouts with rather few bends.

TREEConstant 
public static const TREE:int = 3

Layout style specifier. Gives nice layouts if the graph is a tree.