The CompactNodePlacer produces a compact placement of the children.
Remarks
Layout Style
This ITreeLayoutNodePlacer uses a dynamic optimization approach that chooses a placement strategy of the children of the associated local root such that the overall result is compact with respect to a specified aspect ratio. The set of applied strategies is predefined and cannot be customized. A node can either be a normal tree node or an assistant node, in which case the AssistantNodePlacer is chosen automatically (i.e., you shouldn't explicitly map nodes to instances of AssistantNodePlacer but mark them by means of key ASSISTANT_NODE_DP_KEY).
Default Values of Properties
horizontalDistance | 20 | |
preferredAspectRatio | 1 | |
verticalDistance | 20 |
Type Details
- yfiles module
- layout-tree
- yfiles-umd modules
- layout-orthogonal-compact, layout-orthogonal, layout-tree, layout
- Legacy UMD name
- yfiles.tree.CompactNodePlacer
See Also
Constructors
Creates a new CompactNodePlacer instance with default settings.
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.
- preferredAspectRatio - number
The preferred aspect ratio (width/height) for the subtrees. This option sets the preferredAspectRatio 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 horizontal distance between nodes or subtrees.
Remarks
Default Value
20
.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
.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
.Throws
- Exception({ name: 'ArgumentError' })
- if the minimum segment length is negative
Sample Graphs
Gets or sets the preferred aspect ratio (width/height) for the subtrees.
Remarks
Default Value
1
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified aspect ratio is negative
0
, the algorithm automatically chooses one that leads to a small overall area.Gets or sets the vertical distance between nodes or subtrees.
Remarks
Default Value
20
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
See Also
Sample Graphs
Methods
Returns a clone of this ITreeLayoutNodePlacer instance.
Creates a IProcessor.
Parameters
A map of options to pass to the method.
- layouter - TreeLayout
- the current TreeLayout instance
- graph - LayoutGraph
- the input graph
- currentRoot - YNode
- the root node handled by this ITreeLayoutNodePlacer
Returns
- ↪IProcessor
- a IProcessor instance or
null
Overrides
Determines a connector direction for the given child node.
Remarks
Parameters
A map of options to pass to the method.
- child - YNode
- the child node
Returns
- ↪ParentConnectorDirection
- a direction specifier as defined in the ITreeLayoutNodePlacer interface
Implements
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 - YNode
- the local root node
- connectorMap - IDataMap
- the map that must be used for storing the direction specifiers of the child nodes
Overrides
Returns the SubtreeShape for the given node.
Remarks
This is a convenience method that retrieves a SubtreeShape for a single node from the corresponding IDataProvider.
This method is used in placeSubtreeOfNode for retrieving the SubtreeShapes for the local root nodes. It may be overridden to return a custom implementation of SubtreeShape.
Parameters
A map of options to pass to the method.
- node - YNode
- the node
Returns
- ↪SubtreeShape
- the SubtreeShape for the given node
Defined in
Returns the SubtreeShape for the subtree rooted at the given node.
Remarks
This is a convenience method that retrieves a SubtreeShape of a complete subtree from the corresponding IDataProvider.
This method is used in placeSubtreeOfNode for retrieving the SubtreeShapes for the subtrees that are arranged. It may be overridden to return a custom implementation of SubtreeShape.
Parameters
A map of options to pass to the method.
- node - YNode
- the local root node
Returns
- ↪SubtreeShape
- the SubtreeShape of the subtree rooted at the given local root node
Defined in
placeSubtree
(nodeShapeProvider: IDataProvider, subtreeShapeProvider: IDataProvider, graph: LayoutGraph, localRoot: YNode, parentConnectorDirection: ParentConnectorDirection) : SubtreeShapeInitializes the local data structures and then delegates the work to the abstract variant of this method (placeSubtreeOfNode)
Parameters
A map of options to pass to the method.
- nodeShapeProvider - IDataProvider
- the IDataProvider for obtaining an initial shape of the root node
Domain YNode Values SubtreeShape the shape of the node - subtreeShapeProvider - IDataProvider
- the IDataProvider for accessing the pre-calculated shapes of the subtrees
Domain YNode Values SubtreeShape the shape of the subtree rooted at the node - graph - LayoutGraph
- the input graph
- localRoot - YNode
- 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
See Also
Implements
placeSubtreeOfNode
(localRoot: YNode, parentConnectorDirection: ParentConnectorDirection) : SubtreeShapeArranges the local root relative to the SubtreeShape of its children.
Remarks
Parameters
A map of options to pass to the method.
- localRoot - YNode
- the local root node
- parentConnectorDirection - ParentConnectorDirection
- the direction of the connector
Returns
- ↪SubtreeShape
- a SubtreeShape instance that describes the shape of the whole subtree rooted at the given local root
Implements
Fields
The graph instance this class is working on.
Defined in
Constants
A data acceptor key for storing/restoring the placement strategy of the children of nodes.
Remarks
Domain | YNode | the nodes of the input graph |
Values | Object | an object that stores the placement strategy of the node's children |