A LevelAlignedSubtreePlacer arranges the nodes of a subtree into layers such that nodes on the same level/depth are aligned.
Remarks
Layout Style
Nodes that have the same depth in the tree will be placed in the same horizontal layer. They will be vertically aligned.
Default Values of Properties
busAlignment | 0.5 | |
dendrogramStyle | false | The nodes are assigned to the topmost layer. |
edgeRoutingStyle | STRAIGHT_LINE
| |
layerSpacing | 40 | |
rootAlignment | TRAILING
| |
spacing | 20 | |
verticalAlignment | 0.5 | Nodes are center aligned. |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new LevelAlignedSubtreePlacer instance.
Parameters
A map of options to pass to the method.
- id - any
- The ID of this instance, used for identifying LevelAlignedSubtreePlacers that share information about the layer height. Using different IDs allows aligned layouts within different subtrees.
- busAlignment - number
- The vertical bus alignment for orthogonally routed edges. This option sets the busAlignment property on the created object.
- rootAlignment - SubtreeRootAlignment
- The SubtreeRootAlignment that defines how the root node is aligned with its children and their shapes. This option sets the rootAlignment property on the created object.
- polylineLabeling - boolean
- Whether or not straight edges are extended to avoid label overlaps. This option sets the polylineLabeling property on the created object.
- verticalAlignment - number
- The relative vertical alignment of nodes within their respective layers. This option sets the verticalAlignment property on the created object.
- edgeRoutingStyle - LevelAlignedSubtreePlacerRoutingStyle
- The routing style for the edges in the subtree. This option sets the edgeRoutingStyle property on the created object.
- layerSpacing - number
- The distance between two adjacent layers. This option sets the layerSpacing property on the created object.
- dendrogramStyle - boolean
- Whether or not the layering is done dendrogram-like. This option sets the dendrogramStyle 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 vertical bus alignment for orthogonally routed edges.
Remarks
The bus alignment determines the relative position of an edge bus in between two subsequent layers of nodes.
Values for a valid vertical alignment are in the range [0..1]
, such that:
- A value of
0.0
places the bus at the top, right below the parent node. - A value of
0.5
places the bus in the middle between parent and child nodes. - A value of
1.0
places the bus at the bottom, right above the child nodes.
Default Value
0.5
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified alignment is outside
[0..1]
See Also
Sample Graphs
Gets or sets whether or not the layering is done dendrogram-like.
Remarks
Default Value
false
.The nodes are assigned to the topmost layer.
Property Value
true
if the graph is layered as a dendrogram, false
otherwiseSample Graphs
Gets or sets the routing style for the edges in the subtree.
Default Value
STRAIGHT_LINE.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified routing style specifier is unknown
Gets or sets the distance between two adjacent layers.
Remarks
Default Value
40
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified spacing is negative
See Also
Sample Graphs
Gets or sets whether or not straight edges are extended to avoid label overlaps.
Remarks
Default Value
false
.Edges are only routed straight.
Property Value
true
if polyline connectors are added, false
otherwiseSample Graphs
Gets or sets the SubtreeRootAlignment that defines how the root node is aligned with its children and their shapes.
Default Value
TRAILING.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given root alignment is
null
Gets or sets the spacing between subtrees.
Remarks
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given spacing is negative
See Also
Sample Graphs
Gets the modification matrix that defines the direction of the subtree.
Gets or sets the relative vertical alignment of nodes within their respective layers.
Remarks
A value of 0
means that nodes are top-aligned; a value of 0.5
means that nodes are center-aligned; a value of 1
means that nodes are bottom-aligned;
Values for a valid vertical alignment are in the range [0..1]
.
Default Value
0.5
.Nodes are center aligned.
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified alignment is outside
[0..1]
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