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.
1
0.5
2
Default Values of Properties
aspectRatio | 1 | |
childAlignmentPolicy | LEADING
| |
childArrangement | VERTICAL
| The child nodes are placed in vertical columns. |
horizontalDistance | 40 | |
rootPlacement | CORNER
| The root node is placed to the top left of all children. |
verticalDistance | 40 |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new instance of AspectRatioSubtreePlacer with default settings.
Parameters
A map of options to pass to the method.
- childArrangement - ChildArrangementPolicy
- How the children are arranged. This option sets the childArrangement property on the created object.
- verticalDistance - number
- The vertical distance between the SubtreeShapes. This option sets the verticalDistance property on the created object.
- horizontalDistance - number
- The horizontal distance between the SubtreeShapes. This option sets the horizontalDistance property on the created object.
- aspectRatio - number
- The preferred aspect ratio (width/height) for the subtrees. This option sets the aspectRatio property on the created object.
- childAlignmentPolicy - AspectRatioChildAlignmentPolicy
- How children are aligned with each other. This option sets the childAlignmentPolicy property on the created object.
- rootPlacement - RootPlacementPolicy
- Where the root node of the subtree is placed. This option sets the rootPlacement property on the created object.
- minimumFirstSegmentLength - number
- The minimum length for the first segment of an edge. This option sets the minimumFirstSegmentLength property on the created object.
- minimumLastSegmentLength - number
- The minimum length for the last segment of an edge. This option sets the minimumLastSegmentLength property on the created object.
Properties
Gets or sets the preferred aspect ratio (width/height) for the subtrees.
Remarks
This ratio determines among how many rows/columns the nodes will be distributed.
The aspect ratio needs to be positive.
Default Value
1
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified aspect ratio is
0
or negative
Sample Graphs
Gets or sets how children are aligned with each other.
Default Value
LEADING.Property Value
Gets or sets how the children are arranged.
Default Value
Property Value
See Also
Sample Graphs
Gets or sets the horizontal distance between the SubtreeShapes.
Remarks
The nodes will be placed next to each other, keeping this distance.
The distance needs to be non-negative.
Default Value
40
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
Sample Graphs
Gets or sets the minimum length for the first segment of an edge.
Remarks
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.
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the minimum segment length is negative
Sample Graphs
Gets or sets the minimum length for the last segment of an edge.
Remarks
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.
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the minimum segment length is negative
Sample Graphs
Gets or sets where the root node of the subtree is placed.
Default Value
Property Value
See Also
Sample Graphs
Gets or sets the vertical distance between the SubtreeShapes.
Remarks
The nodes will be placed below each other, keeping this distance.
The distance needs to be non-negative.
Default Value
40
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
Sample Graphs
Methods
Returns a clone of this ISubtreePlacer instance.
Returns
- ↪any
- an exact copy of this ISubtreePlacer instance
Creates an edge comparison function which takes the initial coordinates of the nodes into account.
Remarks
Returns
- ↪function(LayoutEdge, LayoutEdge):number
- the comparison function for the edges
Signature Details
function(x: LayoutEdge, y: LayoutEdge) : number
Encapsulates a method that compares two objects.Parameters
- x - LayoutEdge
- The first object to compare.
- y - LayoutEdge
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
Implements
createProcessor
(treeLayout: TreeLayout, graph: LayoutGraph, currentRoot: LayoutNode) : ISubtreePlacerProcessorCreates an optional ISubtreePlacerProcessor for pre- and post-processing.
Remarks
null
. Hence, no pre- or post-processing will be done.Parameters
A map of options to pass to the method.
- treeLayout - TreeLayout
- the current TreeLayout instance
- graph - LayoutGraph
- the input graph
- currentRoot - LayoutNode
- the root node handled by this ISubtreePlacer
Returns
- ↪ISubtreePlacerProcessor?
null
Implements
determineChildConnectors
(localRoot: LayoutNode, connectorMap: IMapper<LayoutNode,ParentConnectorDirection>)Provides the direction of the connector to the SubtreeShape for each child node.
Parameters
A map of options to pass to the method.
- 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
Implements
placeSubtree
(nodeShapeProvider: IMapper<LayoutNode,SubtreeShape>, subtreeShapeProvider: IMapper<LayoutNode,SubtreeShape>, graph: LayoutGraph, localRoot: LayoutNode, parentConnectorDirection: ParentConnectorDirection) : SubtreeShapeInitializes the local data structures and then arranges the local root relative to the SubtreeShape of its children.
Parameters
A map of options to pass to the method.
- 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
Returns
- ↪SubtreeShape
- the merged SubtreeShape for the subtree rooted at the local root node
Implements
Fields
The graph instance this class is working on.