The SingleLayerSubtreePlacer arranges the subtrees of a local root in a single layer.
Remarks
Layout Style
With its default settings, this placer generates tree layouts with orthogonal edge routes and child nodes that are placed next to each other and below their parent node.
The layout style can be customized in several ways. Subtrees sharing the same local root node are either placed above or below each other.
Features
SubtreeShapes can be arranged in each main direction specified in transformation. That way, the subtrees of the same graph can have different directions.
This subtree placer aligns the local root node according to a chosen alignment.
There are various routing styles that result in different edge routes.
Default Values of Properties
edgeRoutingStyle | ORTHOGONAL
| |
minimumChannelSegmentDistance | 0 | |
rootAlignment | CENTER
| |
verticalAlignment | -1 | Nodes are not aligned. |
Type Details
- yFiles module
- algorithms
See Also
Constructors
SingleLayerSubtreePlacer
(transformation?: SubtreeTransform, rootAlignment?: SingleLayerSubtreePlacerRootAlignment, edgeRoutingStyle?: SingleLayerSubtreePlacerRoutingStyle, verticalDistance?: number, horizontalDistance?: number, minFirstSegmentLength?: number, minLastSegmentLength?: number, minSlope?: number, minSlopeHeight?: number)Creates a new SingleLayerSubtreePlacer instance.
Parameters
A map of options to pass to the method.
- transformation - SubtreeTransform
- The modification matrix that defines the direction of the subtree. Default is NONE.
- rootAlignment - SingleLayerSubtreePlacerRootAlignment
- The alignment specifier describing how the root node is aligned with its child nodes. Default is CENTER.
- edgeRoutingStyle - SingleLayerSubtreePlacerRoutingStyle
- The routing style specifier. Default is ORTHOGONAL.
- verticalDistance - number
- The vertical distance between the SubtreeShapes. Default is
20.0d
. - horizontalDistance - number
- The horizontal distance between the SubtreeShapes. Default is
20.0d
. - minFirstSegmentLength - number
- The minimum length of the first edge segment (connected to the root node). Default is
20.0
. - minLastSegmentLength - number
- The minimum length of the last edge segment (connected to the child node). Default is
20.0
. - minSlope - number
- The minimum slope between the root node and the SubtreeShapes. Default is
0.0
. - minSlopeHeight - number
- The minimum vertical height of sloped edge segments. Default is
0.0
. - minimumChannelSegmentDistance - number
- The minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see ORTHOGONAL). This option sets the minimumChannelSegmentDistance property on the created object.
- alignPorts - boolean
- Whether or not 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.
- verticalAlignment - number
- The relative vertical alignment of nodes with the same parent. This option sets the verticalAlignment 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.
- minimumSlope - number
- The minimum slope of the polyline edge segments. This option sets the minimumSlope property on the created object.
- minimumSlopeHeight - number
- The minimum height for polyline edge segments. This option sets the minimumSlopeHeight property on the created object.
See Also
Properties
Gets or sets whether or not nodes are placed so that the source and target port of an edge are aligned.
Remarks
Dependent on the root alignment 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 rootAlignments:
Default Value
false
.Ports are not aligned.
Property Value
true
if the ports are to be aligned, false
otherwiseSee Also
Sample Graphs
Gets or sets the style in which edge paths are routed.
Default Value
ORTHOGONAL.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified routing style is unknown
Gets or sets the horizontal distance between nodes or SubtreeShapes.
Remarks
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
Sample Graphs
Gets or sets the minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see ORTHOGONAL).
Remarks
0
, all segments are routed in a bus-like style.Default Value
0
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is smaller than
0
Sample Graphs
0
, minimumSlopeHeight is equal to 0
, edgeRoutingStyle is ORTHOGONAL and rootAlignment is not equal to LEADING_ON_BUS or TRAILING_ON_BUS.0
are especially useful if the ITreeLayoutPortAssigner distributes the ports at the nodes' border.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
See Also
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 the minimum slope of the polyline edge segments.
Remarks
These polyline segments are between the vertical first and last segment of the edge.
The segments may become steeper but they will have at least the specified slope. Negative minimum slopes can lead to edge routes looking like spider legs.
Default Value
0.1d
.Property Value
See Also
Sample Graphs
Gets or sets the minimum height for polyline edge segments.
Remarks
These polyline segments are between the vertical first and last segment of the edge.
The segments may become steeper to reach the specified height.
Default Value
0
.Property Value
See Also
Sample Graphs
Gets or sets how the root node is aligned with its children and their SubtreeShapes.
Gets the modification matrix that defines the direction of the subtree.
Gets or sets the relative vertical alignment of nodes with the same parent.
Remarks
All values between 0
and 1
result in a valid alignment.
0
- nodes are top-aligned0.5
- nodes are center-aligned1
- nodes are bottom-aligned
Values outside the interval [0,1]
will result in a more compact node placement with unaligned nodes.
Default Value
-1
.Nodes are not aligned.
Property Value
Sample Graphs
Gets or sets the vertical distance between nodes or SubtreeShapes.
Remarks
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
See Also
Sample Graphs
Methods
calculateSlopedSourceEdgeLayout
(rootLayout: NodeLayout, childShape: SubtreeShape, edge: LayoutEdge, childForkCoordinate: number, rootForkCoordinate: number)Calculates the routing of the source side of the edge to the given child node.
Remarks
Parameters
A map of options to pass to the method.
- rootLayout - NodeLayout
- the NodeLayout of the local root node
- childShape - SubtreeShape
- the SubtreeShape instance of the corresponding child's subtree
- edge - LayoutEdge
- the edge
- childForkCoordinate - number
- the y-coordinate of the second (= last) bend of the edge if the placement is horizontal, the x-coordinate otherwise
- rootForkCoordinate - number
- the y-coordinate of the first bend of the edge if the placement is horizontal, the x-coordinate otherwise
Calculates the routing of the source side of the edge to the given child node.
Remarks
This implementation adds bends to the LayoutEdge of the given edge according to the specified routing style and transformation. It also updates the target points in the SubtreeShape.
This method is called by calculateSlopedSourceEdgeLayout to route the edges. It may be overridden to implement a custom edge routing style.
Parameters
A map of options to pass to the method.
- rootLayout - NodeLayout
- the NodeLayout of the local root node
- childShape - SubtreeShape
- the SubtreeShape of the child's subtree that is connected through the given edge
- edge - LayoutEdge
- the edge
Calculates the routing of the target side of the edge to the given child node.
Remarks
This implementation just resets the current LayoutEdge.
This method is called by the implementation of placeSubtree after the shapes of the local root's children are placed. It may be overridden to add some target points to the edge.
Parameters
A map of options to pass to the method.
- rootLayout - NodeLayout
- the NodeLayout of the local root node
- childShape - SubtreeShape
- the SubtreeShape of the child's subtree that is connected through the given edge
- edge - LayoutEdge
- the edge
Returns a clone of this ISubtreePlacer instance.
Returns
- ↪any
- an exact copy of this ISubtreePlacer instance
Creates a comparison for outgoing edges which takes the initial coordinates of the edges' targets into account.
Remarks
Returns
- ↪function(LayoutEdge, LayoutEdge):number
- a comparison that considers the initial coordinates of the 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
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>)Determines the connector direction for each subtree based on the selected transformation applied to the subtree.
Remarks
- If the subtree is positioned below the root node (using NONE or FLIP_X), the connector direction will be UP.
- If the subtree is positioned above the root node (using FLIP_Y or ROTATE_180), the connector direction will be DOWN.
- If the subtree is positioned to the left of the root node (using ROTATE_RIGHT or ROTATE_RIGHT_FLIP_Y), the connector direction will be LEFT.
- If the subtree is positioned to the right of the root node (using ROTATE_LEFT or ROTATE_LEFT_FLIP_Y), the connector direction will be RIGHT.
Parameters
A map of options to pass to the method.
- localRoot - LayoutNode
- The local root node for which the connector direction is determined.
- connectorMap - IMapper<LayoutNode,ParentConnectorDirection>
- The IMapper<K,V> used to store the connector direction specifiers for the subtrees.
See Also
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