LabelStyleBase<TVisualextends Visual>
An abstract base class that makes it possible to easily implement a custom ILabelStyle.
Remarks
Only createVisual and getPreferredSize need to be implemented by subclasses, however to improve rendering performance it is highly recommended to implement at least updateVisual, too.
This implementation differs from the straightforward ILabelStyle implementation in that there is no visible separation between the style and its ILabelStyleRenderer. Instead the renderer used by the base class is fixed and delegates all calls back to the style instance.
Related Programming Samples
- Custom Styles
- Shows how to create custom styles for nodes, edges, labels, ports, and edge arrows.
- 01 Rendering the Label Text
- Visualize a label using a basic text element
- 04 Preferred Label Size
- Let the label style set the desired label size
- 05 Render Performance
- Optimize the render performance of the label style
Type Parameters
- TVisual: Visual
- The optional type of the
created and updated by the and methods. This type argument can be omit, but specifying a more concrete type helps conveniently implementing with TypeScript.
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.styles.LabelStyleBase
See Also
Constructors
Initializes a new instance of the LabelStyleBase<TVisual> class.
Properties
Gets the renderer implementation for this instance.
Remarks
Implements
Methods
Creates a new object that is a copy of the current instance.
Remarks
this
.Returns
- ↪Object
- A new object that is a copy of this instance using memberwiseClone.
Implements
Creates the visual.
Remarks
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The render context.
- label - ILabel
- The label to which this style instance is assigned.
Returns
- ↪TVisual
- The visual as required by the createVisual interface.
See Also
Gets the bounds of the visual for the label in the given context.
Remarks
This method is called in response to a getBounds call to the instance that has been queried from the renderer.
This implementation simply yields the bounds of the layout of the given label.
Parameters
A map of options to pass to the method.
- context - ICanvasContext
- The canvas context.
- label - ILabel
- The label to which this style instance is assigned.
Returns
- ↪Rect
- The visual bounds of the visual representation.
Determines whether the visual representation of the label has been hit at the given location.
Remarks
This method is called in response to a isHit call to the instance that has been queried from the renderer.
This implementation returns the result of the hits method invoked for the layout of the label, the given point and the hit test radius of the canvas context.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- location - Point
- The point to test.
- label - ILabel
- The label to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified label representation is hit;false
otherwise.
Determines whether the visualization for the specified label is included in the marquee selection.
Remarks
This method is called in response to a isInBox call to the instance that has been queried from the renderer.
This implementation returns the result of the intersects method invoked on rectangle
for the layout of the label and the context
.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- rectangle - Rect
- The marquee selection box.
- label - ILabel
- The label to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified label is visible is selected by the marquee rectangle;false
otherwise.
Determines whether the visualization for the specified label is included in the lasso selection.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- path - GeneralPath
- The lasso selection path.
- label - ILabel
- The label to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified label is visible is selected by the lasso path;false
otherwise.
Determines whether the visualization for the specified label is visible in the context.
Remarks
This method is called in response to a isVisible call to the instance that has been queried from the renderer.
This implementation simply tests whether the bounds intersect the clip.
Parameters
A map of options to pass to the method.
- context - ICanvasContext
- The canvas context.
- rectangle - Rect
- The clipping rectangle.
- label - ILabel
- The label to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified label is visible in the clipping rectangle;false
otherwise.
Performs the lookup operation for the getContext that has been queried from the renderer.
Remarks
This implementation yields null
for everything but:
For these interfaces an implementation will be returned that delegates to the methods in this instance.
Parameters
A map of options to pass to the method.
Returns
- ↪any
- An implementation of the
type
ornull
.
Updates the visual previously created by createVisual.
Remarks
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The render context.
- oldVisual - TVisual
- The visual that has been created in the call to createVisual.
- label - ILabel
- The label to which this style instance is assigned.
Returns
- ↪TVisual
- The visual as required by the createVisual interface.
See Also
Static Methods
createLayoutTransform
(context: IRenderContext, layout: IOrientedRectangle, autoFlip: boolean) : MatrixCreates a transform matrix that can be applied to a Visual to arrange it according to the given layout
and autoFlip
rule.
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The render context.
- layout - IOrientedRectangle
- The layout used to create the transform matrix.
- autoFlip - boolean
- Whether to automatically flip the matrix by 180 degrees, if the result would be pointing downwards.
Returns
- ↪Matrix
- The transform matrix.
Creates a transform matrix that can be applied to a Visual to arrange it according to the given layout
and autoFlip
rule.
Remarks
Parameters
A map of options to pass to the method.
- layout - IOrientedRectangle
- The layout used to create the transform matrix.
- autoFlip - boolean
- Whether to automatically flip the matrix by 180 degrees, if the result would be pointing downwards.
Returns
- ↪Matrix
- The transform matrix (with projection).
Deprecation warning
Use the overload with the render context parameter instead.