The LeftRightSubtreePlacer arranges the children in a subtree on the left and the right of a vertical bus.
Remarks
Layout Style
The default settings generate a layout with a single vertical bus, where children are placed left and right of it. By adjusting the branchCount, it is possible to generate multiple vertical buses (i.e. branches) that are placed next to each other, below the root node.Default Values of Properties
branchCount | 1 | The layout consists of a single branch. |
horizontalDistance | 20 | |
placeLastOnBottom | true | The last child is centered below its siblings |
spacing | 20 | |
verticalDistance | 20 |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new LeftRightSubtreePlacer instance.
Parameters
A map of options to pass to the method.
- horizontalDistance - number
- The horizontal distance between nodes or subtrees. This option sets the horizontalDistance property on the created object.
- verticalDistance - number
- The vertical distance between nodes or subtrees. This option sets the verticalDistance property on the created object.
- branchCount - number
- The number of branches (buses) of the subtree layout. This option sets the branchCount 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.
- placeLastOnBottom - boolean
- Whether or not the last child is placed centered, aligned with the bus and below the other child nodes. This option sets the placeLastOnBottom property on the created object.
- transformation - SubtreeTransform
- The modification matrix that defines the direction of the subtree. This option sets the transformation property on the created object.
- alignPorts - boolean
- Whether nodes are placed so that the source and target port of an edge are aligned. This option sets the alignPorts property on the created object.
- spacing - number
- The spacing between subtrees. This option sets the spacing property on the created object.
Properties
Gets or sets whether nodes are placed so that the source and target port of an edge are aligned.
Remarks
Dependent on the SubtreeRootAlignment type the subtree root is moved in a way that the edge connecting the root to one of its children is straightened.
This setting only applies to the following SubtreeRootAlignments:
Default Value
false
.Ports are not aligned.
Property Value
true
if the ports are to be aligned, false
otherwiseSample Graphs
Gets or sets the number of branches (buses) of the subtree layout.
Remarks
Default Value
1
.The layout consists of a single branch.
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given branch count is smaller than
1
Sample Graphs
Gets or sets the horizontal distance between nodes or subtrees.
Remarks
Default Value
20
.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
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
Gets or sets whether or not the last child is placed centered, aligned with the bus and below the other child nodes.
Remarks
Default Value
true
.The last child is centered below its siblings
Property Value
true
if the last child is separated, false
otherwiseSample Graphs
Gets or sets the spacing between subtrees.
Remarks
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given spacing is negative
Sample Graphs
Gets the modification matrix that defines the direction of the subtree.
Gets or sets the vertical distance between nodes or subtrees.
Remarks
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
Sample Graphs
Methods
Creates an edge comparison which takes the initial coordinates of the nodes into account.
Remarks
Returns
- ↪function(LayoutEdge, LayoutEdge):number
- the comparison 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
.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?
- a ISubtreePlacerProcessor instance or
null
Implements
determineChildConnectors
(localRoot: LayoutNode, connectorMap: IMapper<LayoutNode,ParentConnectorDirection>)Provides the direction of the connector to the SubtreeShape for each child node.
Remarks
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) : SubtreeShapeArranges the SubtreeShapes of the local root and its children and routes the edges that connect them.
Remarks
This method is the main method of the tree layout algorithm. It is called by TreeLayout in each recursion step to place the local root in relation to its children. Their shapes will be merged into one SubtreeShape, which is returned by this method.
The SubtreeShape for the local root can be obtained from the nodeShapeProvider
. subtreeShapeProvider
contains the SubtreeShapes assigned to the child nodes.
Due to the order in which the tree nodes are processed, it is guaranteed that at the time of the invocation of this method the SubtreeShape of every descendant node has already been calculated.
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 combined shape of the whole subtree
Implements
Constants
A data key for assigning nodes to the left or the right side of the bus.
Remarks
Assign true
to a node that should be placed to the left side of the bus, or false
if it should be placed to the right side of the bus.
If no IMapper<K,V> is specified using this key, the nodes will be placed alternating from left to right.