Specifies custom data for the TreeLayout.
Examples
The following example shows how to create a new instance of TreeLayoutData and use it with an TreeLayout:
In many cases the complete initialization of TreeLayoutData can also be done in a single object initializer:
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.tree.TreeLayoutData
See Also
Constructors
Creates a new instance of TreeLayoutData which helps configuring TreeLayout.
Parameters
A map of options to pass to the method.
- nodePlacers - ItemMapping<INode,ITreeLayoutNodePlacer>
The mapping from nodes to their ITreeLayoutNodePlacer. This option sets the nodePlacers property on the created object.
- portAssignments - ItemMapping<INode,ITreeLayoutPortAssignment>
The mapping from nodes to their ITreeLayoutPortAssignment. This option sets the portAssignments property on the created object.
- outEdgeComparers - ItemMapping<INode,system.Comparison<IEdge>>
The mapping from nodes to comparison functions used to sort the nodes' outgoing edges. This option sets the outEdgeComparers property on the created object.
- nodeHalos - ItemMapping<INode,NodeHalo>
- nodeTypes - ItemMapping<INode,Object>
The mapping from nodes to an object defining the node type, which influences the ordering of child nodes such that those with same type are preferably placed next to each other. This option sets the nodeTypes property on the created object.
- sourcePortConstraints - ItemMapping<IEdge,PortConstraint>
A mapping from edges to their source PortConstraint. This option sets the sourcePortConstraints property on the created object.
- targetPortConstraints - ItemMapping<IEdge,PortConstraint>
A mapping from edges to their target PortConstraint. This option sets the targetPortConstraints property on the created object.
- assistantNodes - ItemCollection<INode>
The collection of nodes the AssistantNodePlacer considers as assistants. This option sets the assistantNodes property on the created object.
- delegatingNodePlacerPrimaryNodes - ItemCollection<INode>
The collection of nodes the DelegatingNodePlacer places with its primaryPlacer. This option sets the delegatingNodePlacerPrimaryNodes property on the created object.
- leftRightNodePlacerLeftNodes - ItemCollection<INode>
The set of nodes that are placed on the left side of the bus. This option sets the leftRightNodePlacerLeftNodes property on the created object.
- gridNodePlacerRowIndices - ItemMapping<INode,number>
The mapping from nodes to the index of the row the GridNodePlacer shall place the node in. This option sets the gridNodePlacerRowIndices property on the created object.
- abortHandler - AbortHandler
The AbortHandler used during the layout. This option sets the abortHandler property on the created object.
- treeRoot - SingleItem<INode>
The mapping for marking the node that will be used as root node of the tree. This option sets the treeRoot property on the created object.
- edgeLabelPreferredPlacement - ItemMapping<ILabel,PreferredPlacementDescriptor>
The mapping that provides a PreferredPlacementDescriptor instance for edge ILabels. This option sets the edgeLabelPreferredPlacement property on the created object.
- compactNodePlacerStrategyMementos - IMapper<INode,Object>
A mapper from nodes to a strategy memento object for the CompactNodePlacer. This option sets the compactNodePlacerStrategyMementos property on the created object.
- criticalEdgePriorities - ItemMapping<IEdge,number>
A mapping from edges to their priority to be a 'critical' edge. This option sets the criticalEdgePriorities property on the created object.
Properties
Gets or sets the AbortHandler used during the layout.
Remarks
An AbortHandler can be used to gracefully stop or cancel a running layout and offers options for automatically doing so after a predetermined time.
An AbortHandler configured or set here overrides the one on LayoutExecutor.
Examples
The most common use case would be to just configure the AbortHandler here, e.g. to set timeouts for a graceful stop or canceling the running layout:
layoutData.abortHandler.stopDuration = TimeSpan.fromSeconds(10) layoutData.abortHandler.cancelDuration = TimeSpan.fromSeconds(30)
layoutData.abortHandler!.stopDuration = TimeSpan.fromSeconds(10) layoutData.abortHandler!.cancelDuration = TimeSpan.fromSeconds(30)
If there's already an AbortHandler instance that's pre-configured or will be used in a different place to, e.g., cancel the layout when the user presses a button, you can also set one explicitly:
layoutData.abortHandler = abortHandler
See Also
Gets or sets the collection of nodes the AssistantNodePlacer considers as assistants.
Remarks
Examples
Specifying which nodes to lay out as assistant nodes can be done in various ways, depending on which option is more convenient at the moment. For example, if you already have a collection or IEnumerable<T> somewhere that contains all nodes that should be treated as assistant nodes, then the easiest option usually is to use the source property:
In some cases only some nodes may need to be directly set as assistant nodes, but are not already in a collection, in which case the items property can be used directly to add them:
In cases where it's directly apparent from a node whether to lay it out as an assistant node, the best option usually is to use a delegate:
See Also
Sample Graphs
Gets or sets a mapper from nodes to a strategy memento object for the CompactNodePlacer.
Remarks
This property has an effect only if CompactNodePlacer is selected as node placer for at least one subtree of the input graph. Then, given that this property is set, the node placer stores the applied placement strategy for the nodes' children and keeps it in subsequent layout runs. This is useful to maintain similar layout styles over subsequent runs. Otherwise, even for small changes in the graph structure, the results produced by CompactNodePlacer can drastically change.
The actual values stored in this mapper are opaque objects only intended for internal use by CompactNodePlacer.
Examples
layoutData.compactNodePlacerStrategyMementos = new Mapper()
See Also
Gets or sets a mapping from edges to their priority to be a 'critical' edge.
Remarks
The layout tries to align each node pair that is connected by a critical edge (integer value > 0).
Critical edges highlight different edge paths that are relevant for a user. The layout tries to align each node pair that is connected by a critical edge. Conflicts between different critical edges are always resolved in favor of the higher priority.
Examples
Critical edges are often determined by some external data source and are often part of a larger path. The following example shows how two different such paths can be made 'critical' with different priorities:
Alternatively, a delegate may be used as well, if determining edge criticality is easier when looking at the edge itself:
See Also
Gets or sets the collection of nodes the DelegatingNodePlacer places with its primaryPlacer.
Gets or sets the mapping that provides a PreferredPlacementDescriptor instance for edge ILabels.
Examples
Depending on how much customization is needed, some ways of setting PreferredPlacementDescriptors are more convenient than others. For example, to set the same descriptor for all labels, you can just use the constant property:
If some labels should use custom placement or this has to be configured ahead of time, you can use the mapper instead:
When the preferred placement can be inferred from the label itself, a delegate is usually the easiest choice:
Note that the preferred placement can also be inferred from an arbitrary ILabelModelParameter:
See Also
Gets or sets the mapping from nodes to the index of the row the GridNodePlacer shall place the node in.
Gets or sets the set of nodes that are placed on the left side of the bus.
Remarks
Examples
See Also
Sample Graphs
Gets or sets the mapping from nodes to their NodeHalo.
Remarks
Examples
The easiest option is to reserve the same space around all nodes, by setting a constant NodeHalo:
Handling only certain nodes differently can be done easily by using the mapper property:
In cases where the NodeHalo for each node can be determined by looking at the node itself it's often easier to just set a delegate instead of preparing a mapper:
See Also
Gets or sets the mapping from nodes to their ITreeLayoutNodePlacer.
Remarks
null
, then the default node placer applies for that node.Examples
Depending on the customization needed, ItemMapping<TItem,TValue> has several options that work well in different situations. To change the default only for some nodes that are known beforehand, it's often easiest to just use the mapper:
In case the desired configuration can readily be inferred from each node, the most convenient option usually is to use a delegate:
See Also
Gets or sets the mapping from nodes to an object defining the node type, which influences the ordering of child nodes such that those with same type are preferably placed next to each other.
Remarks
See Also
Sample Graphs
Gets or sets the mapping from nodes to comparison functions used to sort the nodes' outgoing edges.
See Also
Gets or sets the mapping from nodes to their ITreeLayoutPortAssignment.
Remarks
Examples
Depending on the customization needed, ItemMapping<TItem,TValue> has several options that work well in different situations. To change the default only for some nodes that are known beforehand, it's often easiest to just use the mapper:
In case the desired configuration can readily be inferred from each node, the most convenient option usually is to use a delegate:
See Also
Gets or sets a mapping from edges to their source PortConstraint.
Remarks
Examples
If all edges should exit their source node on the same side, you can simply set a constant constraint for all edges:
To change the constraints for individual edges, it's usually easiest to use the mapper:
If a PortConstraint can readily be created from an edge, using a delegate is often easier:
See Also
Sample Graphs
Gets or sets a mapping from edges to their target PortConstraint.
Remarks
Examples
If all edges should exit their source node on the same side, you can simply set a constant constraint for all edges:
To change the constraints for individual edges, it's usually easiest to use the mapper:
If a PortConstraint can readily be created from an edge, using a delegate is often easier:
See Also
Sample Graphs
Gets or sets the mapping for marking the node that will be used as root node of the tree.
Examples
The simplest way to set a custom root node for the layout, if you already have an INode for that, would be to use the item to specify it as the root:
In cases where it's easier to look at an INode to determine whether it should be the root node or not, it's often most convenient to use the delegate property:
Sometimes there might also be a collection that usually holds just the single node that should be the root, in which case source can be useful:
See Also
Methods
Combines this instance with the given layout data.
Remarks
Parameters
A map of options to pass to the method.
- data - LayoutData
- The LayoutData to combine this instance with.
Returns
- ↪LayoutData
- The combined layout data.