Remarks
These data items can be any business or arbitrary data which should be represented by labels.
LabelCreator<TDataItem> allows to conveniently bind properties of the data item to the properties of the created ILabel to control aspects like layout and styling.
In the context of the GraphBuilder, it is responsible to create the labels from the associated NodesSource<TDataItem>s and EdgesSource<TDataItem>s.
Type Parameters
TDataItem
- The type of the data items in the source.
See Also
Developer's Guide
Members
Constructors
Properties
Gets or sets a set of ILabelDefaults that will be used for the labels.
See Also
Developer's Guide
Gets or sets an optional provider of a label model parameter that will be used as the label's layoutParameter for the source data item.
Gets or sets an optional binding that will be applied to the label.
Gets or sets an optional provider of the size that will be used as the label's preferredSize for the source data item.
true, the properties of the same instance are overwritten each time. To get fresh copies, set shareStyleInstance to false.See Also
Developer's Guide
API
- applyStyleBindings
Gets or sets an optional provider of an ILabelStyle instance that will be used as the label's style for the source data item.
See Also
Developer's Guide
API
- getStyle
Gets or sets an optional provider of an object that will be used as the label's tag for the source data item.
See Also
Developer's Guide
API
- getTag
Gets or sets an optional provider of the text that will be used as the label's text for the source data item.
null or undefined no label will be created. To force creation of an empty label, the provider must return an empty string instead.See Also
Developer's Guide
API
- getText
Methods
Adds a label on the given ILabelOwner with the values of the bindings resolved against the dataItem.
dataItem.This method will use the various helper methods in this class to determine the values for the label's properties.
If the dataItem doesn't provide a label, this method returns null.
Parameters
- graph: IGraph
- The graph.
- owner: ILabelOwner
- The owner to which the label should be added.
- dataItem: TDataItem
- The data item for which to create the label.
Return Value
- ILabel
- The newly added label.
See Also
Parameters
- graph: IGraph
- The graph to create the node in.
- owner: ILabelOwner
- The owner to which the label should be added.
- text: string
- The label's text.
- layoutParameter: ILabelModelParameter
- The layout parameter of the label.
- style: ILabelStyle
- The style of the label.
- preferredSize: Size
- The preferred size of the label.
- tag: ILabel['tag']
- The tag of the node.
Return Value
- ILabel
- The newly added label.
Resolves the preferredSizeBindings against the given dataItem and applies them to the given label preferredSize.
dataItem and applies them to the given label preferredSize.Parameters
- graph: IGraph
- The managed graph.
- label: ILabel
- The label to update.
- dataItem: TDataItem
- The data item that is used.
See Also
Parameters
- graph: IGraph
- The managed graph.
- label: ILabel
- The label to update.
- dataItem: TDataItem
- The data item that is used.
See Also
API
- updateStyle
Parameters
- dataItem: TDataItem
- The data item on which the provider is resolved.
Return Value
- ILabelModelParameter
- The value to use or
nullin case the defaults should be used.
See Also
Parameters
- dataItem: TDataItem
- The data item on which the provider is resolved.
Return Value
- Size
- The value to use or
nullin case the defaults should be used.
See Also
null, the defaults are used.Parameters
- dataItem: TDataItem
- The data item on which the provider is resolved.
Return Value
- ILabelStyle
- The value to use or
nullin case the defaults should be used.
See Also
Parameters
- dataItem: TDataItem
- The data item on which the provider is resolved.
Return Value
- any
- The value to use or
nullin case the defaults should be used.
See Also
API
- tagProvider
Parameters
- dataItem: TDataItem
- The data item on which the provider is resolved.
Return Value
- string
- The value to use or
nullin case no text should be added.
See Also
API
- textProvider
Resolves the layoutParameterProvider on the given data item.
By default, it only delegates to getLayoutParameter.
This method is called by updateLayoutParameter.
Parameters
- graph: IGraph
- The managed graph.
- label: ILabel
- The label to update.
- dataItem: TDataItem
- The data item that is used.
Return Value
- ILabelModelParameter
- The new layout parameter instance. Either the value returned by getLayoutParameter, or the default layout parameter, if getLayoutParameter returns
null.
Resolves the preferredSizeProvider and then applies the preferred size bindings.
Parameters
- graph: IGraph
- The managed graph.
- label: ILabel
- The label for which the size should be updated.
- dataItem: TDataItem
- The data item that is used.
Return Value
- Size
- Returns the label's new preferred size.
Resolves the styleProvider and then applies the style bindings.
Parameters
- graph: IGraph
- The managed graph.
- label: ILabel
- The label to update.
- dataItem: TDataItem
- The data item that is used.
Return Value
- ILabelStyle
- The updated style instance. Either the value returned by getStyle, or the default style, if getStyle returns
null.
Resolves the tagProvider on the given data item.
By default, it only delegates to getTag.
This method is called by updateLayoutParameter.
Parameters
- graph: IGraph
- The managed graph.
- label: ILabel
- The label for which the new tag should be obtained.
- dataItem: TDataItem
- The data item that is used.
Return Value
- any
- Returns the updated tag object.
Resolves the textProvider on the given data item.
By default, it only delegates to getText.
This method is called by updateLayoutParameter.
Parameters
- graph: IGraph
- The managed graph.
- label: ILabel
- The label for which the new text should be obtained.
- dataItem: TDataItem
- The data item that is used.
Return Value
- string
- Returns the new text.
Triggers the label-added event.
Triggers the label-updated event.
By default, this method only fires the label-updated event.
To update other aspects of the label instance, call the respective update methods when the label is updated or overwrite this method:
// configure the LabelCreators to update non-structural aspects
const labelCreator1 = nodeCreator.createLabelBinding((item) => item.name)
labelCreator1.addEventListener('label-updated', (evt) => {
labelCreator1.updateText(evt.graph, evt.item, evt.dataItem)
labelCreator1.updateStyle(evt.graph, evt.item, evt.dataItem)
labelCreator1.updatePreferredSize(evt.graph, evt.item, evt.dataItem)
labelCreator1.updateLayoutParameter(evt.graph, evt.item, evt.dataItem)
labelCreator1.updateTag(evt.graph, evt.item, evt.dataItem)
})
// each LabelCreator has to be configured
const labelCreator2 = nodeCreator.createLabelBinding(
(item) => item.description,
)
labelCreator2.addEventListener('label-updated', (evt) => {
// only update properties which may change
labelCreator2.updateText(evt.graph, evt.item, evt.dataItem)
})Parameters
- graph: IGraph
- The graph that contains the edge.
- label: ILabel
- The label to update.
- dataItem: TDataItem
- The data item with which the label should be updated.
Return Value
- boolean
trueif the label has been updated. Iffalsethe label information has been removed fromdataItemand therefore the label will be removed, too.
See Also
Updates the layoutParameter of the label with the given dataItem by calling getUpdatedLayoutParameter and setting the new parameter on the label.
label with the given dataItem by calling getUpdatedLayoutParameter and setting the new parameter on the label.Updates the preferredSize of the label with the given dataItem by calling getUpdatedPreferredSize and setting the new size on the label.
label with the given dataItem by calling getUpdatedPreferredSize and setting the new size on the label.Updates the style of the label with the given dataItem by calling getUpdatedStyle and applying the style to the node in the graph.
label with the given dataItem by calling getUpdatedStyle and applying the style to the node in the graph.Updates the tag of the label with the given dataItem by calling getUpdatedTag and setting the new tag on the label.
label with the given dataItem by calling getUpdatedTag and setting the new tag on the label.Updates the text of the label with the given dataItem by calling getUpdatedText and setting the new text on the label.
label with the given dataItem by calling getUpdatedText and setting the new text on the label.Events
Occurs when a label has been added.
Properties of
GraphBuilderItemEventArgs<ILabel, TDataItem>- dataItem: TDataItem
- Gets the object the item has been created from.
- item: TItem
- Gets the item that is the subject of the event.
See Also
Occurs when a label has been updated.
Properties of
GraphBuilderItemEventArgs<ILabel, TDataItem>- dataItem: TDataItem
- Gets the object the item has been created from.
- item: TItem
- Gets the item that is the subject of the event.
See Also
API
- label-added