Helps in decorating the lookup method of INode instances by providing access to decorators for the most common types.
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 nodes on the GraphDecorator which is returned by decorator on an IGraph.
This decorator can be used to conveniently decorate the lookup of INodes in an IGraph. It serves as a factory for predefined LookupDecorator<TDecoratedType,TInterface> instances that are specifically useful for the INode type.
Examples
The node can be decorated in various ways. addConstant decorates the node's lookup to return the same instance for each node.
graph.decorator.nodes.sizeConstraintProvider.addConstant(
new ConstantSizeConstraintProvider(),
)
addConstant with a predicate decorates the node's lookup only to return the same instance for each node for which the predicate returns true
.
graph.decorator.nodes.sizeConstraintProvider.addConstant(
(node) => node.tag !== null,
new ConstantSizeConstraintProvider(),
)
addFactory calls the provided factory method to return a new instance of the queried type created for the given node or for nodes for which the predicate returns true
, respectively:
graph.decorator.nodes.sizeConstraintProvider.addFactory(
(node) => new CustomSizeConstraintProvider(node),
)
graph.decorator.nodes.sizeConstraintProvider.addFactory(
(node) => node.tag !== null,
(node) => new CustomSizeConstraintProvider(node),
)
addWrapperFactory calls the provided factory method to return a new instance of the queried type which wraps the default implementation, once for all nodes and once only for nodes for which the predicate returns true
.
graph.decorator.nodes.sizeConstraintProvider.addWrapperFactory(
(node, originalProvider) =>
new SizeConstraintProviderWrapper(node, originalProvider),
)
graph.decorator.nodes.sizeConstraintProvider.addWrapperFactory(
(node) => node.tag !== null,
(node, originalProvider) =>
new SizeConstraintProviderWrapper(node, originalProvider),
)
Finally hide hides the default implementation by letting the lookup always return null
for all nodes and for nodes for which the predicate returns true
, respectively
graph.decorator.nodes.sizeConstraintProvider.hide()
graph.decorator.nodes.sizeConstraintProvider.hide(
(node) => node.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.nodes.sizeConstraintProvider.addFactory(
(node) => new CustomSizeConstraintProvider(node),
)!
}
deregisterLookup(graph: IGraph): void {
graph.decorator.nodes.remove(this.chainLink)
}
Type Details
- yFiles module
- view
See Also
Constructors
Initializes a new instance of the NodeDecorator class.
Parameters
A map of options to pass to the method.
- decorator - ILookupDecorator
- The decorator to use.
Properties
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IClipboardHelper type for INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IEditLabelHelper type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IFocusRenderer<INode> type for INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IGroupBoundsCalculator type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IGroupPaddingProvider type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IHandleProvider type for INodes this instance has been created for.
Remarks
Custom IHandleProvider implementations provide interactive draggable handles for the user to change the geometry or other aspects of INodes 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<INode> type for INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the ILassoTestable type for INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IMarqueeTestable type for INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IMementoSupport type for INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IObstacleProvider type for INodes this instance has been created for.
Remarks
Property Value
See Also
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IPortCandidateProvider type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IPositionHandler type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IReshapeHandleProvider type for the INodes this instance has been created for.
Remarks
Custom IReshapeHandleProvider implementations can be used to change the number and type of IHandles that can be used by the user to reshape the INodes interactively in the editor. This interface is mainly used by the GraphEditorInputMode which passes the IHandles to the HandleInputMode. This is a convenient alternative to the direct usage of the ILookupDecorator that is provided by the IGraph's lookup.
When the decorated IReshapeHandleProvider 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 IReshapeHandler type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the INodeReshapeSnapResultProvider type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the ISelectionRenderer<INode> type for INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the IShapeGeometry type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the INodeSizeConstraintProvider type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the ISnapReferenceProvider type for the INodes this instance has been created for.
Remarks
Property Value
Gets a LookupDecorator<TDecoratedType,TInterface> that decorates the INodeSnapResultProvider type for the INodes this instance has been created for.
Remarks
Property Value
Methods
Adds an IContextLookupChainLink.
Remarks
Parameters
A map of options to pass to the method.
- link - IContextLookupChainLink
- The lookup chain link to add.
addGenericLookup
(genericLink: function(INode, Constructor, IContextLookup):any) : IContextLookupChainLinkAdds a generic callback as a chain link to the lookup.
Remarks
Parameters
A map of options to pass to the method.
- genericLink - function(INode, Constructor, IContextLookup):any
- The generic callback to add to the lookup chain.
Signature Details
function(arg1: INode, arg2: Constructor, arg3: IContextLookup) : any
Encapsulates a method that has three parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg1 - INode
- The first parameter of the method that this delegate encapsulates.
- arg2 - Constructor
- The second parameter of the method that this delegate encapsulates.
- arg3 - IContextLookup
- The third parameter of the method that this delegate encapsulates.
Returns
- any
- The return value of the method that this delegate encapsulates.
Returns
- ↪IContextLookupChainLink
- An IContextLookupChainLink that has been added to the lookup.
getDecoratorFor
<TInterface>(interfaceType: Constructor<TInterface>) : LookupDecorator<INode,TInterface>Creates a LookupDecorator<TDecoratedType,TInterface> for INodes that can be used to decorate TInterface
types of the nodes.
Type Parameters
- TInterface
- The type of the interface that should be decorated of the instances'
.
Parameters
A map of options to pass to the method.
- interfaceType - Constructor<TInterface>
- The type of the interface that should be decorated of the instances' lookup.
Returns
- ↪LookupDecorator<INode,TInterface>
- A new LookupDecorator<TDecoratedType,TInterface> for the specified interface.
Removes an IContextLookupChainLink that has been added by one of the various decorators for nodes.
Parameters
A map of options to pass to the method.
- link - IContextLookupChainLink
- The lookup chain link to remove.
Examples
registerLookup(graph: IGraph): void {
this.chainLink =
graph.decorator.nodes.sizeConstraintProvider.addFactory(
(node) => new CustomSizeConstraintProvider(node),
)!
}
deregisterLookup(graph: IGraph): void {
graph.decorator.nodes.remove(this.chainLink)
}