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 bends on the GraphDecorator which is returned by decorator on an IGraph.
This decorator can be used to conveniently decorate the lookup of IBends in an IGraph. It serves as a factory for predefined LookupDecorator<TDecoratedType, TInterface> instances that are specifically useful for the IBend type.
Examples
The bend can be decorated in various ways. addConstant decorates the bend's lookup to return the same instance for each bend.
graph.decorator.bends.handle.addConstant(new ConstantHandle())addConstant with a predicate decorates the bend's lookup only to return the same instance for each bend for which the predicate returns true.
graph.decorator.bends.handle.addConstant(
(bend) => bend.tag !== null,
new ConstantHandle(),
)addFactory calls the provided factory method to return a new instance of the queried type created for the given bend or for bends for which the predicate returns true, respectively:
graph.decorator.bends.handle.addFactory((bend) => new CustomHandle(bend))
graph.decorator.bends.handle.addFactory(
(bend) => bend.tag !== null,
(bend) => new CustomHandle(bend),
)addWrapperFactory calls the provided factory method to return a new instance of the queried type which wraps the default implementation, once for all bends and once only for bends for which the predicate returns true.
graph.decorator.bends.handle.addWrapperFactory(
(bend, original) => new HandleWrapper(bend!, original),
)
graph.decorator.bends.handle.addWrapperFactory(
(bend) => bend.tag !== null,
(bend, original) => new HandleWrapper(bend!, original),
)Finally hide hides the default implementation by letting the lookup always return null for all bends and for bends for which the predicate returns true, respectively
graph.decorator.bends.handle.hide()
graph.decorator.bends.handle.hide((bend) => bend.tag !== null)Each of these methods returns a IContextLookupChainLink which can be used to remove the modified behavior again:
constructor() {}
registerLookup(graph: IGraph): void {
this.chainLink = graph.decorator.bends.handle.addFactory(
(bend) => new CustomHandle(bend),
)!
}
deregisterLookup(graph: IGraph): void {
graph.decorator.bends.remove(this.chainLink)
}See Also
Developer's Guide
API
- GraphDecorator, LookupDecorator
Members
Constructors
Initializes a new instance of the BendDecorator class.
Parameters
- decorator: ILookupDecorator
- The decorator to use.
Properties
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IClipboardHelper type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IFocusRenderer<IBend> type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IHandle type for IBends this instance has been created for.
Custom IHandle implementations can be used to change the way the user can drag a bend interactively to change its position in a GraphComponent. This interface is mainly used by the HandleInputMode in GraphEditorInputMode. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
When the decorated IHandle is sometimes present and sometimes not, a call to requeryHandles may be necessary to refresh the displayed handles.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IHandleProvider type for IBends this instance has been created for.
Custom IHandleProvider implementations provide interactive draggable handles for the user to change the geometry or other aspects of IBends 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.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IHighlightRenderer<IBend> type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ILassoTestable type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IMarqueeTestable type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IMementoSupport type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IObstacleProvider type for IBends this instance has been created for.
Property Value
See Also
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IPositionHandler type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ISelectionRenderer<IBend> type for IBends this instance has been created for.
Property Value
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IBendSnapResultProvider type for IBends this instance has been created for.
Property Value
Methods
Adds an IContextLookupChainLink.
Parameters
- link: IContextLookupChainLink
- The lookup chain link to add.
getDecoratorFor
<TInterface> (interfaceType: Constructor<TInterface>): LookupDecorator<IBend, TInterface>Creates a LookupDecorator<TDecoratedType, TInterface> for IBends that can be used to decorate TInterface types of the bends.
getDecoratorFor
<TInterface> (interfaceType: Constructor<TInterface>): LookupDecorator<IBend, TInterface>TInterface types of the bends.Parameters
- interfaceType: Constructor<TInterface>
- The type of the interface that should be decorated of the instances' lookup.
Return Value
- LookupDecorator<IBend, TInterface>
- A new LookupDecorator<TDecoratedType, TInterface> for the specified interface.
Removes an IContextLookupChainLink that has been added by one of the various decorators for IBends.
Parameters
- link: IContextLookupChainLink
- The lookup chain link to remove.
Examples
constructor() {}
registerLookup(graph: IGraph): void {
this.chainLink = graph.decorator.bends.handle.addFactory(
(bend) => new CustomHandle(bend),
)!
}
deregisterLookup(graph: IGraph): void {
graph.decorator.bends.remove(this.chainLink)
}