Specifies custom data for the GenericLabeling.
Examples
The following example shows how to create a new instance of LabelingData and use it with a GenericLabeling:
In many cases the complete initialization of LabelingData 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.labeling.LabelingData
See Also
Constructors
Creates a new instance of LabelingData which helps configuring GenericLabeling.
Parameters
A map of options to pass to the method.
- affectedLabels - DpKeyItemCollection<ILabel>
The collection of labels that shall be placed by the algorithm. This option sets the affectedLabels property on the created object.
- nodeLabelModels - ItemMapping<ILabel,INodeLabelLayoutModel>
The mapping from node labels to an INodeLabelLayoutModel used by the labeling algorithm instead of the original label model. This option sets the nodeLabelModels property on the created object.
- edgeLabelModels - ItemMapping<ILabel,IEdgeLabelLayoutModel>
The mapping from edge labels to an IEdgeLabelLayoutModel used by the labeling algorithm instead of the original label model. This option sets the edgeLabelModels property on the created object.
- sourceGroupIds - ItemMapping<IEdge,Object>
A mapping from edges to an object representing their source edge group. This option sets the sourceGroupIds property on the created object.
- targetGroupIds - ItemMapping<IEdge,Object>
A mapping from edges to an object representing their target edge group. This option sets the targetGroupIds property on the created object.
- nodeHalos - ItemMapping<INode,NodeHalo>
- abortHandler - AbortHandler
The AbortHandler used during the layout. This option sets the abortHandler 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.
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 labels that shall be placed by the algorithm.
Remarks
Examples
Defining the subset of labels that should be laid out can be done in various ways, mostly depending on which option is more convenient for a particular use case. You can use the ItemCollection<TItem>'s source property to use any .NET collection or IEnumerable<T>:
Alternatively, ItemCollection<TItem> also has an items property, which is a collection that already exists, in case the items may have to be added one by one. This can be more convenient than defining an own list and setting it to source:
A powerful option that doesn't use a collection is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
See Also
Gets or sets the mapping from edge labels to an IEdgeLabelLayoutModel used by the labeling algorithm instead of the original label model.
Remarks
If a label has no mapping, the original model is used as normal.
A model parameter that fits the calculated position of the replacement model best is set for the original label model.
This feature is especially useful to restrict a free model. For example, to place a label upon its associated edge, a centered SliderEdgeLabelLayoutModel can be used as replacement model.
Examples
Specifying a custom label model for edge labels can be done in different ways, depending on which option is the most convenient for a given use case. If only a few labels must be customized in this way and most should be left alone, using the mapper is usually the easiest option:
When the label model to use is easy to determine from each label itself, using a delegate is often easier:
Finally, to override the default behavior in the same way for every single label, a constant could also be used:
See Also
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 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 node labels to an INodeLabelLayoutModel used by the labeling algorithm instead of the original label model.
Remarks
If a label has no mapping, the original model is used as normal.
A model parameter that fits the calculated position of the replacement model best is set for the original label model.
This feature is especially useful to restrict a free model. For example, to place a label upon its associated node, a centered DiscreteNodeLabelLayoutModel can be used as replacement model.
Examples
Specifying a custom label model for node labels can be done in different ways, depending on which option is the most convenient for a given use case. If only a few labels must be customized in this way and most should be left alone, using the mapper is usually the easiest option:
When the label model to use is easy to determine from each label itself, using a delegate is often easier:
Finally, to override the default behavior in the same way for every single label, a constant could also be used:
See Also
Gets or sets a mapping from edges to an object representing their source edge group.
Remarks
See Also
Gets or sets a mapping from edges to an object representing their target edge group.
Remarks
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.