Packagecom.yworks.yfiles.layout
Classpublic class ComponentLayouter
InheritanceComponentLayouter Inheritance AbstractLayoutStage Inheritance YObject Inheritance Object
Subclasses IsolatedGroupComponentLayouter

This layout stage arranges the connected components of a graph.

It is possible to specify a core layout algorithm that will be invoked on all connected components of the graph before this layouter arranges the components themselves.

ComponentLayouter will handle hierarchically grouped graphs in a special way. The contents of a group node will always belong to the same component as the group node itself.



Public Properties
 PropertyDefined By
  componentArrangement : Boolean
Specifies whether or not the separately laid out components of the input graph should be arranged by this class.
ComponentLayouter
  componentSpacing : Number
Specifies the current component spacing.
ComponentLayouter
  considerLabels : Boolean
Determines whether or not to take node and edge labels into account when calculating the bounding box of the graph components.
ComponentLayouter
 InheritedcoreLayouter : Layouter
Specifies the core layouter.
AbstractLayoutStage
  gridSpacing : Number
Specifies the current grid spacing.
ComponentLayouter
  groupingActive : Boolean
Getter: Determines whether or not grouping information bound to the graph will be used to calculate the components.
ComponentLayouter
  preferredLayoutSize : YDimension
Specifies the preferred layout size for this layouter.
ComponentLayouter
  style : int
Specifies the component arrangement style used by this ComponentLayouter.
ComponentLayouter
Public Methods
 MethodDefined By
  
ComponentLayouter(init:Boolean = true)
Initializes a new ComponentLayouter instance.
ComponentLayouter
  
canLayout(graph:LayoutGraph):Boolean
[override] Determines if the preconditions for the graph layout algorithm are fulfilled, by applying them to the connected components.
ComponentLayouter
  
doLayout(graph:LayoutGraph):void
[override] Calculate the layout.
ComponentLayouter
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
ComponentLayouter
 Inherited
hashCode():int
YObject
  
[static] Initializes a new ComponentLayouter instance.
ComponentLayouter
  
[static] Initializes a new ComponentLayouter instance.
ComponentLayouter
  
setPreferredLayoutSize(width:Number, height:Number):void
Sets the preferred layout size for this layouter.
ComponentLayouter
Protected Methods
 MethodDefined By
  
arrangeComponents(graph:LayoutGraph, nodes:Vector.<Object>, edges:Vector.<Object>, bbox:Vector.<Object>, boxes:Vector.<Object>):void
Produces a non-overlapping component graph layout.
ComponentLayouter
  
arrangeFields(graph:LayoutGraph, nodes:Vector.<Object>, edges:Vector.<Object>, bbox:Vector.<Object>, boxes:Vector.<Object>, circular:Boolean, fill:Boolean, fromSketch:Boolean):void
ComponentLayouter
  
Calculates and returns the bounding box of a graph component including node halos.
ComponentLayouter
 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
  
findGraphComponents(graph:LayoutGraph, compNumber:NodeMap):int
Determines which nodes will belong to the same graph component.
ComponentLayouter
 Inherited
AbstractLayoutStage
 Inherited
AbstractLayoutStage
  
Initializes this object.
ComponentLayouter
  
initComponentLayouter2(coreLayouter:Layouter):void
Initializes this object.
ComponentLayouter
  
Sets the origin for a subgraph.
ComponentLayouter
Public Constants
 ConstantDefined By
  GIVEN_COMPONENT_ID_DPKEY : Object = y.layout.ComponentLayouter.GIVEN_COMPONENT_ID_DPKEY
[static] DataProvider key that can be used to determine components by hand.
ComponentLayouter
  LAYOUT_NODE_DPKEY : Object = y.layout.ComponentLayouter.LAYOUT_NODE_DPKEY
[static] DataProvider key that can be used to determine which nodes should be laid out.
ComponentLayouter
  STYLE_MASK : int = 31
[static] Use this constant for masking actual styles constants from style modifiers.
ComponentLayouter
  STYLE_MODIFIER_AS_IS : int = 32
[static] Modifier constant that can be added to normal style constants to indicate that the arrangement strategy should take the initial positions of the components into account.
ComponentLayouter
  STYLE_MODIFIER_NO_OVERLAP : int = 64
[static] Modifier constant that can be added to normal style constants to indicate that the arrangement strategy should produce a non-overlapping component layout.
ComponentLayouter
  STYLE_MULTI_ROWS : int = 8
[static] Style specification constant describing a component arrangement strategy that places components in multiple rows.
ComponentLayouter
  STYLE_MULTI_ROWS_COMPACT : int = 9
[static] Style specification constant describing a component arrangement strategy that places components in multiple rows.
ComponentLayouter
  STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED : int = 10
[static] Style specification constant describing a component arrangement strategy.
ComponentLayouter
  STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACT : int = 11
[static] Style specification constant describing a component arrangement strategy.
ComponentLayouter
  STYLE_MULTI_ROWS_WIDTH_CONSTRAINED : int = 12
[static] Style specification constant describing a component arrangement strategy.
ComponentLayouter
  STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACT : int = 13
[static] Style specification constant describing a component arrangement strategy.
ComponentLayouter
  STYLE_NONE : int = 0
[static] Style specification constant describing no special component arrangement at all.
ComponentLayouter
  STYLE_PACKED_CIRCLE : int = 6
[static] Style specification constant describing a component arrangement strategy that tries to place components like in a cloud around the biggest component.
ComponentLayouter
  STYLE_PACKED_COMPACT_CIRCLE : int = 7
[static] Style specification constant describing a component arrangement strategy that tries to place components like in a cloud around the biggest component.
ComponentLayouter
  STYLE_PACKED_COMPACT_RECTANGLE : int = 5
[static] Style specification constant describing a component arrangement strategy that tries to place components like in a rectangular cloud around the biggest component.
ComponentLayouter
  STYLE_PACKED_RECTANGLE : int = 4
[static] Style specification constant describing a component arrangement strategy that tries to place components like in a rectangular cloud around the biggest component.
ComponentLayouter
  STYLE_ROWS : int = 1
[static] Style specification constant describing a component arrangement strategy that tries to place components in multiple rows so that the overall aspect ratio of all components gets as close to the aspect ratio of the preferred layout size as possible.
ComponentLayouter
  STYLE_SINGLE_COLUMN : int = 3
[static] Style specification constant describing a component arrangement strategy that places components above each other in a single column.
ComponentLayouter
  STYLE_SINGLE_ROW : int = 2
[static] Style specification constant describing a component arrangement strategy that places components next to each other in a single row.
ComponentLayouter
Property Detail
componentArrangementproperty
componentArrangement:Boolean

Specifies whether or not the separately laid out components of the input graph should be arranged by this class.

By default this feature is enabled.


Implementation
    public function get componentArrangement():Boolean
    public function set componentArrangement(value:Boolean):void
componentSpacingproperty 
componentSpacing:Number

Specifies the current component spacing. This value represents the minimum allowed distance between the bounding boxes of to components.


Implementation
    public function get componentSpacing():Number
    public function set componentSpacing(value:Number):void
considerLabelsproperty 
considerLabels:Boolean

Determines whether or not to take node and edge labels into account when calculating the bounding box of the graph components.

By default this feature is enabled.


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

See also

gridSpacingproperty 
gridSpacing:Number

Specifies the current grid spacing. Components will be moved by multiples of this value, thus keeping their offset to the grid. That way, components or parts of them that were placed on a grid before, will stay on their original grid. The grid spacing also influences the distance between the components.

Note that this option keeps existing grid locations intact but won't correct the location of a component to the grid specified here.

If grid spacing equals 0, the grid won't be considered at all.


Implementation
    public function get gridSpacing():Number
    public function set gridSpacing(value:Number):void
groupingActiveproperty 
groupingActive:Boolean

Getter: Determines whether or not grouping information bound to the graph will be used to calculate the components.

The default value is true.

Setter: Specifies whether or not grouping information bound to the graph should be used to determine the connectedness of the graph structure.

The default value is true.


Implementation
    public function get groupingActive():Boolean
    public function set groupingActive(value:Boolean):void
preferredLayoutSizeproperty 
preferredLayoutSize:YDimension

Specifies the preferred layout size for this layouter.


Implementation
    public function get preferredLayoutSize():YDimension
    public function set preferredLayoutSize(value:YDimension):void

Throws
IllegalArgumentException — when the specified width or height is negative or zero.

See also

styleproperty 
style:int

Specifies the component arrangement style used by this ComponentLayouter.

The default is STYLE_ROWS.


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

See also

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

Initializes a new ComponentLayouter instance.

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
arrangeComponents()method
protected function arrangeComponents(graph:LayoutGraph, nodes:Vector.<Object>, edges:Vector.<Object>, bbox:Vector.<Object>, boxes:Vector.<Object>):void

Produces a non-overlapping component graph layout. This method moves the graph components in such a fashion that their bounding boxes do not overlap. The arrangement strategy used takes the ratio of the overall layout area into account.

Subclasses may want to overwrite this method.

Parameters

graph:LayoutGraph — the layout graph.
 
nodes:Vector.<Object> — array of type NodeList. The i-th NodeList contains all nodes of the i-th graph component.
 
edges:Vector.<Object> — array of type EdgeList. The i-th EdgeList contains all edges of the i-th graph component.
 
bbox:Vector.<Object> — array of type YRectangle. The i-th YRectangle contains the current bounding box of the i-th graph component.
 
boxes:Vector.<Object> — array of type Rectangle2D. The i-th Rectangle2D contains the extended bounding box of the i-th graph component. The method arranges these boxes in such a way that they do not overlap. Then the i-th graph component must be placed inside the i-th box.

arrangeFields()method 
protected function arrangeFields(graph:LayoutGraph, nodes:Vector.<Object>, edges:Vector.<Object>, bbox:Vector.<Object>, boxes:Vector.<Object>, circular:Boolean, fill:Boolean, fromSketch:Boolean):void

Parameters

graph:LayoutGraph
 
nodes:Vector.<Object>
 
edges:Vector.<Object>
 
bbox:Vector.<Object>
 
boxes:Vector.<Object>
 
circular:Boolean
 
fill:Boolean
 
fromSketch:Boolean

calcBoundingBox()method 
protected function calcBoundingBox(graph:LayoutGraph):Rectangle2D

Calculates and returns the bounding box of a graph component including node halos. This method will be invoked for each component of the graph. Depending on the state of property labelAwarenessEnabled the returned bounding box will also take node and edge labels into account.

Parameters

graph:LayoutGraph

Returns
Rectangle2D
canLayout()method 
override public function canLayout(graph:LayoutGraph):Boolean

Determines if the preconditions for the graph layout algorithm are fulfilled, by applying them to the connected components.

Parameters

graph:LayoutGraph

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

Calculate the layout. This is done by decomposing the graph in its connected components and applying the core layout algorithm on each component.

Parameters

graph:LayoutGraph

See also

findGraphComponents()method 
protected function findGraphComponents(graph:LayoutGraph, compNumber:NodeMap):int

Determines which nodes will belong to the same graph component. Additionally to normal connectedness a group node and all of its children will belong to the same component.

Parameters

graph:LayoutGraph — the input graph
 
compNumber:NodeMap — return value that will hold the zero-based number of the component that it belongs to. The component number of Node v is compNum.getInt(v).

Returns
int — the number of connected components of this graph.
getClass()method 
override public function getClass():Class

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

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

See also

initComponentLayouter2()method 
protected final function initComponentLayouter2(coreLayouter:Layouter):void

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

Parameters

coreLayouter:Layouter

See also

newComponentLayouter1()method 
public static function newComponentLayouter1():ComponentLayouter

Initializes a new ComponentLayouter instance.

Returns
ComponentLayouter

See also

newComponentLayouter2()method 
public static function newComponentLayouter2(coreLayouter:Layouter):ComponentLayouter

Initializes a new ComponentLayouter instance.

Parameters

coreLayouter:Layouter — the layout algorithm that is invoked for connected components of the input graph.

Returns
ComponentLayouter

See also

setOrigin()method 
protected function setOrigin(graph:LayoutGraph, nl:NodeList, el:EdgeList, org:YPoint, r:YRectangle):void

Sets the origin for a subgraph.

Parameters

graph:LayoutGraph
 
nl:NodeList
 
el:EdgeList
 
org:YPoint
 
r:YRectangle

setPreferredLayoutSize()method 
public function setPreferredLayoutSize(width:Number, height:Number):void

Sets the preferred layout size for this layouter.

Parameters

width:Number — the preferred width of the calculated graph layout.
 
height:Number — the preferred height of the calculated graph layout.


Throws
IllegalArgumentException — when width or height is negative or zero.

See also

Constant Detail
GIVEN_COMPONENT_ID_DPKEYConstant
public static const GIVEN_COMPONENT_ID_DPKEY:Object = y.layout.ComponentLayouter.GIVEN_COMPONENT_ID_DPKEY

DataProvider key that can be used to determine components by hand. The algorithm will use the com.yworks.yfiles.base.DataProvider.getObject() method to query for object instances that will be used to determine components: If null is returned for a node that node's component will be determined as usual. If non-null values are returned, they will be compared using their natural order ( com.yworks.bridge.util.Comparable) to determine the component order.

See also

LAYOUT_NODE_DPKEYConstant 
public static const LAYOUT_NODE_DPKEY:Object = y.layout.ComponentLayouter.LAYOUT_NODE_DPKEY

DataProvider key that can be used to determine which nodes should be laid out. Note that components will be laid out if and only if at least one of the nodes that make up the component returns true if queried through the DataProvider instance. If no such instance is registered with the graph, all components will be laid out by the core layout algorithm.

STYLE_MASKConstant 
public static const STYLE_MASK:int = 31

Use this constant for masking actual styles constants from style modifiers.

See also

STYLE_MODIFIER_AS_ISConstant 
public static const STYLE_MODIFIER_AS_IS:int = 32

Modifier constant that can be added to normal style constants to indicate that the arrangement strategy should take the initial positions of the components into account. Combining this modifier is supported with the following styles: STYLE_SINGLE_ROW, STYLE_SINGLE_COLUMN, STYLE_PACKED_RECTANGLE, STYLE_PACKED_COMPACT_RECTANGLE, STYLE_PACKED_CIRCLE, and STYLE_PACKED_COMPACT_CIRCLE.

See also

STYLE_MODIFIER_NO_OVERLAPConstant 
public static const STYLE_MODIFIER_NO_OVERLAP:int = 64

Modifier constant that can be added to normal style constants to indicate that the arrangement strategy should produce a non-overlapping component layout. Combining this modifier is supported with STYLE_NONE.

Note that non-overlapping component layout (in the sense that no elements from adjacent components overlap) is inherently supported by the following styles: STYLE_PACKED_RECTANGLE, STYLE_PACKED_COMPACT_RECTANGLE, STYLE_PACKED_CIRCLE, and STYLE_PACKED_COMPACT_CIRCLE.

See also

STYLE_MULTI_ROWSConstant 
public static const STYLE_MULTI_ROWS:int = 8

Style specification constant describing a component arrangement strategy that places components in multiple rows. In contrast to STYLE_ROWS, each row may also be divided into further sub-rows, thus especially being advantageous, if there are few very large components and many significantly smaller ones. The strategy tries to arrange the components such that the aspect ratio of the final component placement gets as close as possible to the aspect ratio of the preferred layout size, configurable using setPreferredLayoutSize().

See also

STYLE_MULTI_ROWS_COMPACTConstant 
public static const STYLE_MULTI_ROWS_COMPACT:int = 9

Style specification constant describing a component arrangement strategy that places components in multiple rows. In contrast to STYLE_ROWS, each row may also be divided into further sub-rows, thus especially being advantageous, if there are few very large components and many significantly smaller ones. The strategy tries to arrange the components such that the aspect ratio of the final component placement gets close to the aspect ratio of the preferred layout size, configurable using setPreferredLayoutSize() . But in contrast to STYLE_MULTI_ROWS, this strategy tries not always to come as close to the preferred view ratio, if not necessary, i.e. if a ratio close to the preferred ratio only induces a lot of unused view space. This unused space will be minimized.

See also

STYLE_MULTI_ROWS_HEIGHT_CONSTRAINEDConstant 
public static const STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED:int = 10

Style specification constant describing a component arrangement strategy. It uses the same core strategy as STYLE_MULTI_ROWS, but under the restriction that the resulting height does not exceed the preferred height ( preferredLayoutSize). Note, that the preferred width and thus the aspect ratio will be ignored. In contrast to STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACT, the result will be an arrangement which uses as much height as possible, even if that means that all components will be arranged in one single column.

See also

STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACTConstant 
public static const STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED_COMPACT:int = 11

Style specification constant describing a component arrangement strategy. It uses the same core strategy as STYLE_MULTI_ROWS, but under the restriction that the resulting height does not exceed the preferred height ( preferredLayoutSize). Note, that the preferred width and thus the aspect ratio will be ignored. In comparison with STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED, the result will be compacted, which means that an arrangement with the minimum width such that the height constraint is still fulfilled will be realized.

See also

STYLE_MULTI_ROWS_WIDTH_CONSTRAINEDConstant 
public static const STYLE_MULTI_ROWS_WIDTH_CONSTRAINED:int = 12

Style specification constant describing a component arrangement strategy. It uses the same core strategy as STYLE_MULTI_ROWS, but under the restriction that the resulting width does not exceed the preferred width ( preferredLayoutSize). Note, that the preferred height and thus the aspect ratio will be ignored. In contrast to STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACT the result will be an arrangement which uses as much space in width as possible, even if that means that all components will be arranged in a single row.

See also

STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACTConstant 
public static const STYLE_MULTI_ROWS_WIDTH_CONSTRAINED_COMPACT:int = 13

Style specification constant describing a component arrangement strategy. It uses the same core strategy as STYLE_MULTI_ROWS, but under the restriction that the resulting width does not exceed the preferred width ( preferredLayoutSize). Note, that the preferred height and thus the aspect ratio will be ignored. In comparison with STYLE_MULTI_ROWS_HEIGHT_CONSTRAINED the result will be compacted, in order to minimize unused view space induced by components that are large in height.

See also

STYLE_NONEConstant 
public static const STYLE_NONE:int = 0

Style specification constant describing no special component arrangement at all. Components will be centered at the same position they resided at before the layout started. If combined with the style modifier STYLE_MODIFIER_NO_OVERLAP components might get moved so that they don't overlap after the layout.

See also

STYLE_PACKED_CIRCLEConstant 
public static const STYLE_PACKED_CIRCLE:int = 6

Style specification constant describing a component arrangement strategy that tries to place components like in a cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap.

See also

STYLE_PACKED_COMPACT_CIRCLEConstant 
public static const STYLE_PACKED_COMPACT_CIRCLE:int = 7

Style specification constant describing a component arrangement strategy that tries to place components like in a cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap. In contrast to STYLE_PACKED_CIRCLE components might even be placed in empty spaces inside other components.

See also

STYLE_PACKED_COMPACT_RECTANGLEConstant 
public static const STYLE_PACKED_COMPACT_RECTANGLE:int = 5

Style specification constant describing a component arrangement strategy that tries to place components like in a rectangular cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap. In contrast to STYLE_PACKED_RECTANGLE components might even be placed in empty spaces inside other components.

See also

STYLE_PACKED_RECTANGLEConstant 
public static const STYLE_PACKED_RECTANGLE:int = 4

Style specification constant describing a component arrangement strategy that tries to place components like in a rectangular cloud around the biggest component. Entities of different components will not overlap, however the bounding boxes of the components may overlap.

See also

STYLE_ROWSConstant 
public static const STYLE_ROWS:int = 1

Style specification constant describing a component arrangement strategy that tries to place components in multiple rows so that the overall aspect ratio of all components gets as close to the aspect ratio of the preferred layout size as possible.

See also

STYLE_SINGLE_COLUMNConstant 
public static const STYLE_SINGLE_COLUMN:int = 3

Style specification constant describing a component arrangement strategy that places components above each other in a single column. If combined with the style modifier STYLE_MODIFIER_AS_IS components will be placed in the same order as they were placed before the layout.

See also

STYLE_SINGLE_ROWConstant 
public static const STYLE_SINGLE_ROW:int = 2

Style specification constant describing a component arrangement strategy that places components next to each other in a single row. If combined with the style modifier STYLE_MODIFIER_AS_IS components will be placed in the same order as they were placed before the layout.

See also