C

AspectRatioSubtreePlacer

This ISubtreePlacer places the subtrees such that the overall aspect ratio of the arranged subtree will be close to the specified aspect ratio.

Remarks

Layout Style

The aspect ratio describes the relation between width and height of the subtree. To achieve the desired aspect ratio, this ISubtreePlacer divides the child SubtreeShapes into as much rows as needed. The edges are either routed along the rows or along the columns.

Aspect ratio 1

Aspect ratio 0.5

Aspect ratio 2

Default Values of Properties

NameDefaultDescription
aspectRatio1
childAlignmentPolicyAspectRatioChildAlignmentPolicy.LEADING
childArrangementChildArrangementPolicy.VERTICAL
The child nodes are placed in vertical columns.
horizontalDistance40
rootPlacementRootPlacementPolicy.CORNER
The root node is placed to the top left of all children.
verticalDistance40

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new instance of AspectRatioSubtreePlacer with default settings.

Parameters

Properties

Gets or sets the preferred aspect ratio (width/height) for the subtrees.

This ratio determines among how many rows/columns the nodes will be distributed.

The aspect ratio needs to be positive.

final

Property Value

the preferred ratio between width and height

Throws

Exception ({ name: 'ArgumentError' })
if the specified aspect ratio is 0 or negative

Default Value

The default value is: 1

Sample Graphs

ShownSetting: 0.5
Gets or sets how children are aligned with each other.
conversionfinal

Property Value

One of the predefined child alignment policies

Default Value

Gets or sets how the children are arranged.
conversionfinal

Property Value

HORIZONTAL for horizontal rows, VERTICAL for vertical columns, and AUTOMATIC for choosing automatically between rows and columns.

Default Value

The default value is: ChildArrangementPolicy.VERTICAL
The child nodes are placed in vertical columns.

Sample Graphs

ShownSetting: VERTICAL
Gets or sets the horizontal distance between the SubtreeShapes.

The nodes will be placed next to each other, keeping this distance.

The distance needs to be non-negative.

final

Property Value

the horizontal distance between elements

Throws

Exception ({ name: 'ArgumentError' })
if the specified distance is negative

Default Value

The default value is: 40

Sample Graphs

ShownSetting: 40
Gets or sets the minimum length for the first segment of an edge.

During layout calculation, the edges of the tree are directed. Hence, the first segment is always the segment that is attached to the source, which is the local root node.

The length needs to be non-negative.

final

Property Value

the non-negative minimum segment length

Throws

Exception ({ name: 'ArgumentError' })
if the minimum segment length is negative

Default Value

The default value is: 20

Sample Graphs

ShownSetting: 15
Gets or sets the minimum length for the last segment of an edge.

During layout calculation, the edges of the tree are directed. Hence, the last segment is always the segment that is attached to the target, which is a child node.

The length needs to be non-negative.

final

Property Value

the non-negative minimum segment length

Throws

Exception ({ name: 'ArgumentError' })
if the minimum segment length is negative

Default Value

The default value is: 20

Sample Graphs

ShownSetting: 15
Gets or sets where the root node of the subtree is placed.
conversionfinal

Property Value

CENTER for centered placement, CORNER for placement completely to the top left of all children, and CORNER_COMPACT for placement in the top left corner, but the children may be placed below or to the right.

Default Value

The default value is: RootPlacementPolicy.CORNER
The root node is placed to the top left of all children.

Sample Graphs

ShownSetting: CORNER
Gets or sets the vertical distance between the SubtreeShapes.

The nodes will be placed below each other, keeping this distance.

The distance needs to be non-negative.

final

Property Value

the vertical distance between elements

Throws

Exception ({ name: 'ArgumentError' })
if the specified distance is negative

Default Value

The default value is: 40

Sample Graphs

ShownSetting: 40

Methods

Returns a clone of this ISubtreePlacer instance.
final

Return Value

any
an exact copy of this ISubtreePlacer instance
Creates an edge comparison function which takes the initial coordinates of the nodes into account.
This comparison function defines the order of the outgoing edges of a node before the actual placement of the node's subtree is calculated. It also considers how the children are arranged. An arrangement of AUTOMATIC defaults to the same behavior as HORIZONTAL.
Combining from sketch mode with AUTOMATIC can have unintended results. It is recommended to set the child arrangement policy to either HORIZONTAL or VERTICAL.
final

Return Value

function(LayoutEdge, LayoutEdge): number
the comparison function for the edges
Creates an optional ISubtreePlacerProcessor for pre- and post-processing.
This implementation returns null. Hence, no pre- or post-processing will be done.

Parameters

treeLayout: TreeLayout
the current TreeLayout instance
graph: LayoutGraph
the input graph
currentRoot: LayoutNode
the root node handled by this ISubtreePlacer

Return Value

ISubtreePlacerProcessor
null
Provides the direction of the connector to the SubtreeShape for each child node.
final

Parameters

localRoot: LayoutNode
The local root node
connectorMap: IMapper<LayoutNode, ParentConnectorDirection>
The IMapper<K, V> that is used for storing the direction specifiers of the child nodes
Initializes the local data structures and then arranges the local root relative to the SubtreeShape of its children.
final

Parameters

nodeShapeProvider: IMapper<LayoutNode, SubtreeShape>
the IMapper<K, V> for obtaining an initial shape of the root node
subtreeShapeProvider: IMapper<LayoutNode, SubtreeShape>
the IMapper<K, V> for accessing the pre-calculated shapes of the subtrees
graph: LayoutGraph
the input graph
localRoot: LayoutNode
the root of the subtree that should be arranged by this method
parentConnectorDirection: ParentConnectorDirection
the direction specifier for the connector of the local root node to its parent node

Return Value

SubtreeShape
the merged SubtreeShape for the subtree rooted at the local root node

Fields

The graph instance this class is working on.