C

LabelDecorator

Helps in decorating the lookup method of ILabel instances by providing access to decorators for the most common types.
Inheritance Hierarchy

Remarks

Predefined LookupDecorator<TDecoratedType, TInterface> are made available through properties like e.g. highlightRenderer. Note that the list of possible decorations that are available using this class is not exhaustive in any way. This is merely a way to provide access to those interfaces that are more commonly being decorated by the developer.

Typically, a configured instance of this class is available through labels on the GraphDecorator which is returned by decorator on an IGraph.

This decorator can be used to conveniently decorate the lookup of ILabels in an IGraph. It serves as a factory for predefined LookupDecorator<TDecoratedType, TInterface> instances that are specifically useful for the ILabel type.

Examples

The label can be decorated in various ways. addConstant decorates the label's lookup to return the same instance for each label.

graph.decorator.labels.editLabelHelper.addConstant(
  new ConstantEditLabelHelper(),
)

addConstant with a predicate decorates the label's lookup only to return the same instance for each label for which the predicate returns true.

graph.decorator.labels.editLabelHelper.addConstant(
  (label) => label.tag !== null,
  new ConstantEditLabelHelper(),
)

addFactory calls the provided factory method to return a new instance of the queried type created for the given label or for labels for which the predicate returns true, respectively:

graph.decorator.labels.editLabelHelper.addFactory(
  (label) => new CustomEditLabelHelper(label),
)
graph.decorator.labels.editLabelHelper.addFactory(
  (label) => label.tag !== null,
  (label) => new CustomEditLabelHelper(label),
)

addWrapperFactory calls the provided factory method to return a new instance of the queried type which wraps the default implementation, once for all labels and once only for labels for which the predicate returns true.

graph.decorator.labels.editLabelHelper.addWrapperFactory(
  (label, original) => new EditLabelHelperWrapper(label!, original),
)
graph.decorator.labels.editLabelHelper.addWrapperFactory(
  (label) => label.tag !== null,
  (label, original) => new EditLabelHelperWrapper(label!, original),
)

Finally hide hides the default implementation by letting the lookup always return null for all labels and for labels for which the predicate returns true, respectively

graph.decorator.labels.editLabelHelper.hide()
graph.decorator.labels.editLabelHelper.hide((label) => label.tag !== null)

Each of these methods returns a IContextLookupChainLink which can be used to remove the modified behavior again:

registerLookup(graph: IGraph): void {
  this.chainLink = graph.decorator.labels.editLabelHelper.addFactory(
    (label) => new CustomEditLabelHelper(label),
  )!
}

deregisterLookup(graph: IGraph): void {
  graph.decorator.labels.remove(this.chainLink)
}

See Also

Developer's Guide

API

GraphDecorator, LookupDecorator

Members

Show:

Constructors

Initializes a new instance of the LabelDecorator class.

Parameters

decorator: ILookupDecorator
The decorator to use.

Properties

Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IClipboardHelper type for ILabels this instance has been created for.
Custom IClipboardHelper implementations can be used to customize the way the clipboard operations are performed by GraphClipboard. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IClipboardHelper instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IEditLabelHelper type for ILabels this instance has been created for.
Custom IEditLabelHelper implementations can be used to change or customize interactive label editing. This interface is mainly used by the GraphEditorInputMode which uses the callbacks from the implementation to determine whether the label can be edited, as well as to customize the TextEditorInputMode appearance for the upcoming edit. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IEditLabelHelper instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IFocusRenderer<ILabel> type for ILabels this instance has been created for.
Custom IFocusRenderer<ILabel> implementations can be used to change the way the focus of an ILabel is represented in a GraphComponent. This interface is mainly used by the FocusIndicatorManager<T> in the GraphComponent. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IFocusRenderer<ILabel> instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IHandleProvider type for ILabels this instance has been created for.

Custom IHandleProvider implementations provide interactive draggable handles for the user to change the geometry or other aspects of ILabels in the GraphComponent. This interface is mainly used by the HandleInputMode in the GraphEditorInputMode. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.

When the decorated IHandleProvider provides a set of handles that may change over time, a call to requeryHandles may be necessary to refresh the displayed handles.

readonlyfinal

Property Value

A decorator that can be used to modify the queries for IHandleProvider instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IHighlightRenderer<ILabel> type for ILabels this instance has been created for.
Custom IHighlightRenderer<ILabel> implementations can be used to change the way the highlighting of an ILabel is represented in a GraphComponent. This interface is mainly used by the HighlightIndicatorManager<T> in the GraphComponent. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IHighlightRenderer<ILabel> instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ILabelModelParameterFinder type for ILabels this instance has been created for.
Custom ILabelModelParameterFinder implementations can be used to change the way ILabels can be dragged interactively by the user. It helps in determining the right ILabelModelParameter for a given location that has been chosen by the user. This interface is mainly used by the LabelPositionHandler in the GraphComponent. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for ILabelModelParameterFinder instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ILabelModelParameterProvider type for ILabels this instance has been created for.
Custom ILabelModelParameterProvider implementations can be used to change the set of possible ILabelModelParameters that the user can assign to a label interactively by dragging it in a GraphComponent. This interface is mainly used by the LabelPositionHandler and MoveInputMode in the GraphComponent. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for ILabelModelParameterProvider instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ILassoTestable type for ILabels this instance has been created for.
Custom ILassoTestable implementations can be used to change the way tests for lasso inclusions are performed on ILabels in the editor. This interface is mainly used by the GraphEditorInputMode. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for ILassoTestable instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IMarqueeTestable type for ILabels this instance has been created for.
Custom IMarqueeTestable implementations can be used to change the way tests for marquee inclusions are performed on ILabels in the editor. This interface is mainly used by the GraphEditorInputMode. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IMarqueeTestable instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IMementoSupport type for ILabels this instance has been created for.
Custom IMementoSupport implementations can be used to make the UndoEngine aware of changes to data that is associated with the ILabels. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IMementoSupport instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IObstacleProvider type for ILabels this instance has been created for.
Custom IObstacleProvider implementations provide information about obstacles that will be considered by GraphObstacleProvider which itself serves as a provider for geometric obstacles to BridgeManager that manages the rendering of bridges in edge paths. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IObstacleProvider instances on ILabels.

See Also

API
GraphObstacleProvider, BridgeManager
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IPositionHandler type for the ILabels this instance has been created for.
Custom IPositionHandler implementations can be used to restrict or enhance the way the user moves ILabels interactively in the editor. This interface is mainly used by the MoveInputMode. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IPositionHandler instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ISelectionRenderer<ILabel> type for ILabels this instance has been created for.
Custom ISelectionRenderer<ILabel> implementations can be used to change the way the selection of an ILabel is represented in a GraphComponent. This interface is mainly used by the SelectionIndicatorManager<T> in the GraphComponent. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for ISelectionRenderer<ILabel> instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ISnapReferenceProvider type for ILabels this instance has been created for.
Custom ISnapReferenceProvider implementations can be used to provide custom SnapReferences based on the ILabels this instance has been created for. This interface is mainly used by the label's IPositionHandler to collect snap references during a drag gesture for the label. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify queries for ISnapReferenceProvider instances on ILabels.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ILabelSnapResultProvider type for ILabels this instance has been created for.
Custom ILabelSnapResultProvider implementations can be used to provide custom SnapResults based on the ILabels this instance has been created for. This interface is mainly used by the label's IPositionHandler to collect snap results during a drag gesture for the label. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
readonlyfinal

Property Value

A decorator that can be used to modify queries for ILabelSnapResultProvider instances on ILabels.

Methods

Note that the various decorators for labels provide a more convenient way to add chain links to the lookup.
final

Parameters

link: IContextLookupChainLink
The lookup chain link to add.
Creates a LookupDecorator<TDecoratedType, TInterface> for ILabels that can be used to decorate TInterface types of the labels.
final

Parameters

interfaceType: Constructor<TInterface>
The type of the interface that should be decorated of the instances' lookup.

Return Value

LookupDecorator<ILabel, TInterface>
A new LookupDecorator<TDecoratedType, TInterface> for the specified interface.
Removes an IContextLookupChainLink that has been added by one of the various decorators for labels.
final

Parameters

link: IContextLookupChainLink
The lookup chain link to remove.

Examples

registerLookup(graph: IGraph): void {
  this.chainLink = graph.decorator.labels.editLabelHelper.addFactory(
    (label) => new CustomEditLabelHelper(label),
  )!
}

deregisterLookup(graph: IGraph): void {
  graph.decorator.labels.remove(this.chainLink)
}