C

PortDecorator

Helps in decorating the lookup method of IPort 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 ports on the GraphDecorator which is returned by decorator on an IGraph.

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

Examples

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

graph.decorator.ports.handleProvider.addConstant(
  new ConstantHandleProvider(),
)

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

graph.decorator.ports.handleProvider.addConstant(
  (port) => port.tag !== null,
  new ConstantHandleProvider(),
)

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

graph.decorator.ports.handleProvider.addFactory(
  (port) => new CustomHandleProvider(port),
)
graph.decorator.ports.handleProvider.addFactory(
  (port) => port.tag !== null,
  (port) => new CustomHandleProvider(port),
)

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

graph.decorator.ports.handleProvider.addWrapperFactory(
  (port, original) => new HandleProviderWrapper(port!, original),
)
graph.decorator.ports.handleProvider.addWrapperFactory(
  (port) => port.tag !== null,
  (port, original) => new HandleProviderWrapper(port!, original),
)

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

graph.decorator.ports.handleProvider.hide()
graph.decorator.ports.handleProvider.hide((port) => port.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.ports.handleProvider.addFactory(
    (port) => new CustomHandleProvider(port),
  )!
}

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

See Also

Developer's Guide

API

GraphDecorator, LookupDecorator

Members

Show:

Constructors

Initializes a new instance of the PortDecorator class.

Parameters

decorator: ILookupDecorator
The decorator to use.

Properties

Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IClipboardHelper type for IPorts 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 IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IEdgePathCropper type for IPorts this instance has been created for.
Custom IEdgePathCropper implementations can be used to change the way the path of PathEdgeStyleBase implementations calculate the GeneralPath of the visual representation of an IEdge in a GraphComponent. This interface is mainly used by styles using a polyline to find the intersection of an edge with the bounds of the adjacent node to properly crop the edge path. 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 IEdgePathCropper instances on IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IFocusRenderer<IPort> type for IPorts this instance has been created for.
Custom IFocusRenderer<IPort> implementations can be used to change the way the focus of an IPort 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<IPort> instances on IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IHandle type for IPorts this instance has been created for.

Custom IHandle implementations can be used to change the way the user can drag a IPort interactively to change its position in a GraphComponent. This interface is mainly used by the HandleInputMode in GraphEditorInputMode which obtains the IHandle from the IPort by querying the IHandleProvider from it, which in turn will query the IHandle from itself. Alternatively, selected nodes can put the IHandle of their ports into their IHandleProvider implementation. 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.

By default, port handles are provided by an IEdgePortHandleProvider. In that case, changes to this property don't have an effect. Instead, a custom IEdgePortHandleProvider implementation has to be set to the edges's portHandleProvider.
readonlyfinal

Property Value

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

Custom IHandleProvider implementations provide interactive draggable handles for the user to change the geometry or other aspects of IPorts 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.

By default, port handles are provided by an IEdgePortHandleProvider. In that case, changes to this property don't have an effect. Instead, a custom IEdgePortHandleProvider implementation has to be set to the edges's portHandleProvider.
readonlyfinal

Property Value

A decorator that can be used to modify the queries for IHandleProvider instances on IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IHighlightRenderer<IPort> type for IPorts this instance has been created for.
Custom IHighlightRenderer<IPort> implementations can be used to change the way the highlighting of an IPort 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<IPort> instances on IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ILassoTestable type for IPorts this instance has been created for.
Custom ILassoTestable implementations can be used to change the way tests for lasso inclusions are performed on IPorts 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 IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IMarqueeTestable type for IPorts this instance has been created for.
Custom IMarqueeTestable implementations can be used to change the way tests for marquee inclusions are performed on IPorts 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 IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IMementoSupport type for IPorts 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 IPorts. 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 IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IObstacleProvider type for IPorts 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 IPorts.

See Also

API
GraphObstacleProvider, BridgeManager
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IPositionHandler type for IPorts this instance has been created for.
Custom IPositionHandler implementations can be used to restrict or enhance the way the user moves IPorts 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 IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ISelectionRenderer<IPort> type for IPorts this instance has been created for.
Custom ISelectionRenderer<IPort> implementations can be used to change the way the selection of an IPort 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<IPort> instances on IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the ISnapReferenceProvider type for IPorts this instance has been created for.
Custom ISnapReferenceProvider implementations can be used to provide custom SnapReferences based on the IPorts this instance has been created for. This could e.g., be a OrthogonalSnapLine with a horizontal or vertical offset to the port's location. This interface is mainly used by the GraphSnapContext to collect all available SnapReferences. 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 IPorts.
Gets a LookupDecorator<TDecoratedType, TInterface> that decorates the IPortSnapResultProvider type for IPorts this instance has been created for.
Custom IPortSnapResultProvider implementations can be used to provide custom SnapResults based on the IPorts this instance has been created for. This could e.g., be a SnapResult describing that the port wants to snap to a grid point. This interface is mainly used by the PortLocationModelParameterHandle to collect SnapResults during a drag gesture for the port. 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 IPortSnapResultProvider instances on IPorts.

Methods

Note that the various decorators for ports 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 IPorts that can be used to decorate TInterface types of the ports.
final

Parameters

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

Return Value

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

Parameters

link: IContextLookupChainLink
The lookup chain link to remove.

Examples

registerLookup(graph: IGraph): void {
  this.chainLink = graph.decorator.ports.handleProvider.addFactory(
    (port) => new CustomHandleProvider(port),
  )!
}

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