The MultiLayerSubtreePlacer arranges the children/subtrees of a local root into multiple layers.
Remarks
Layout Style
The children/subtrees are assigned to the layers with multiLayerSubtreePlacerLayerIndices. If there is no layer mapping provided, the layer assignment is made automatically - the produced structure will be square-like with respect to the child count, ignoring actual subtree sizes. For example, if there are nine children, a structure with three layers each containing three nodes is generated.
The edges from the children to the local root are routed in a bus-like style. The placement of the bus can be configured using the property busPlacement. The alignment of the root node can be configured using rootAlignment. To align the root node with the bus, use BUS_ALIGNED. A bus-aligned root in conjunction with CENTER produces a symmetric multi-layer structure with the bus and root aligned in the middle.
Default Values of Properties
busPlacement | LEADING
| The bus is placed leading, left of the child nodes. |
rootAlignment | BUS_ALIGNED
| |
spacing | 20 |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new MultiLayerSubtreePlacer instance.
Parameters
A map of options to pass to the method.
- rootAlignment - MultiLayerSubtreePlacerRootAlignment
- The alignment of the local root with its subtrees (optional). The default value is BUS_ALIGNED.
- busPlacement - BusPlacement
- The placement of the bus with respect to the child nodes. This option sets the busPlacement 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.
- spacing - number
- The spacing between subtrees. This option sets the spacing property on the created object.
Properties
Gets or sets the MultiLayerSubtreePlacerRootAlignment that defines how the root node is aligned with its children and their shapes.
Default Value
BUS_ALIGNED.Property Value
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.
Methods
Creates a comparison that sorts the outgoing edges according to the rows and x-coordinates of their target nodes.
Remarks
Returns
- ↪function(LayoutEdge, LayoutEdge):number
- a comparison that orders edges lexicographically by row and x-coordinates of their target nodes
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
See Also
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 local layers.
Remarks
Assign each child of the local root to its layer index (starting with 0
).
If no IMapper<K,V> is registered with this key, all nodes will be placed in the same layer.