A foundational abstract implementation of INodeStyle that delegates its behavior to pre-configured style instances.
Implements
- I
- I
Remarks
This class supports three primary use cases:
- Wrapping another style with a customized API. This is ideal for providing a simpler or domain-specific API by mapping properties from a subclass to the corresponding values of the delegated style. Subclasses typically return the preconfigured instance from getStyle and modify it in the constructor or through custom property setters.
- Dynamically reconfiguring a style based on the target node. In this scenario, the implementation keeps one or more style instances as fields and switches between them in getStyle, depending on attributes of the node, such as its tag property. This approach may also involve dynamically reconfiguring the style instance for specific node instances. When appropriate, implementations may override clone to simply return
this. - Replacing one part of the implementation of another style. Instead of subclassing another style, the implementation delegates to all but a subset of the various aspects to an existing implementation and provides its own implementation, otherwise, via overriding specific methods of the base NodeStyleBase<TVisual> class.
Subclasses must implement getStyle and should ensure that it executes quickly and without allocations.
See Also
Developer's Guide
API
- getStyle
Members
Show:
Constructors
Properties
Gets the renderer implementation for this instance.
Gets the renderer implementation for this instance.
The private implementation will delegate all API calls back to this instance.
readonlyfinal
Defined in
NodeStyleBase.rendererMethods
Returns a memberwise clone.
Returns a memberwise clone.
Note that stateless subclasses that implement the flyweight pattern and do not carry any state can override this method and return
this, instead, as the base implementation is completely stateless.Return Value
- Object
- A clone of this instance.
Overrides
NodeStyleBase.cloneprotected
Parameters
- context: IRenderContext
- The render context.
- node: INode
- The node to which this style instance is assigned.
Return Value
- Visual
- The visual as required by the createVisual interface.
See Also
API
- updateVisual
Overrides
NodeStyleBase.createVisualprotected
Parameters
- context: ICanvasContext
- The canvas context.
- node: INode
- The node to which this style instance is assigned.
Return Value
- Rect
- The visual bounds of the visual representation.
Overrides
NodeStyleBase.getBoundsprotected
Parameters
- node: INode
- The node to which this style instance is assigned.
- inner: Point
- The coordinates of a point lying inside the shape.
- outer: Point
- The coordinates of a point lying outside the shape.
Return Value
- Point
- The intersection point if one has been found or
null, otherwise.
Overrides
NodeStyleBase.getIntersectionOverriding this method allows for advanced customizations such as using a SimpleNode with modified layout and use it for rendering while preserving the original node's structure.
protected
Parameters
- node: INode
- The original node to be rendered.
Return Value
- INode
- The node used for rendering. By default, this method returns the provided
node. Subclasses can override this method to return a different node, such as a SimpleNode, to customize rendering behavior.
protected
Parameters
- node: INode
- The node to get the outline for.
Return Value
- GeneralPath
- The outline of the visual representation or
null.
Overrides
NodeStyleBase.getOutlineProvides the core implementation of this style, returning the instance to delegate rendering logic.
Provides the core implementation of this style, returning the instance to delegate rendering logic.
This method should ideally return the same instance for identical items to ensure optimal performance. It should avoid performing expensive operations as it will be invoked frequently during rendering and other operations like hit-testing. Ideally, it should be implemented allocation-free.
protectedabstract
Parameters
- node: INode
- The node for which the style instance should be returned and applied.
Return Value
- INodeStyle
- The INodeStyle instance responsible for handling all related requests.
See Also
Developer's Guide
protected
Parameters
- context: IInputModeContext
- The input mode context.
- location: Point
- The point to test.
- node: INode
- The node to which this style instance is assigned.
Return Value
- boolean
trueif the specified node is hit;falseotherwise.
Overrides
NodeStyleBase.isHitprotected
Parameters
- context: IInputModeContext
- The input mode context.
- rectangle: Rect
- The marquee selection box.
- node: INode
- The node to which this style instance is assigned.
Return Value
- boolean
trueif the specified node is visible and selected by the marquee rectangle;falseotherwise.
Overrides
NodeStyleBase.isInBoxprotected
Parameters
- context: IInputModeContext
- The input mode context.
- path: GeneralPath
- The lasso selection path.
- node: INode
- The node to which this style instance is assigned.
Return Value
- boolean
trueif the specified node is visible and selected by the lasso path;falseotherwise.
Overrides
NodeStyleBase.isInPathprotected
Parameters
Return Value
- boolean
- Whether the point is considered to lie inside the shape.
Overrides
NodeStyleBase.isInsideprotected
Parameters
- context: ICanvasContext
- The canvas context.
- rectangle: Rect
- The clipping rectangle.
- node: INode
- The node to which this style instance is assigned.
Return Value
- boolean
trueif the specified node is visible in the clipping rectangle;falseotherwise.
Overrides
NodeStyleBase.isVisibleprotected
Parameters
- node: INode
- The node to use for the context lookup.
- type: Constructor
- The type to query.
Return Value
- any
- An implementation of the
typeornull.
Overrides
NodeStyleBase.lookupprotected
Parameters
- context: IRenderContext
- The render context.
- oldVisual: Visual
- The visual that has been created in the call to createVisual.
- node: INode
- The node to which this style instance is assigned.
Return Value
- Visual
- The visual as required by the createVisual interface.
See Also
API
- createVisual