C

WebGLLabelStyle

A label style for use in WebGL2 rendering.
ImplementsInheritance Hierarchy

Remarks

Note that unlike other ILabelStyle implementations, this class is immutable. All properties are read-only and immutable, and the class cannot be subclassed, either.

See Also

Developer's Guide

API

WebGLIconLabelStyle

Members

No filters for this type

Constructors

Creates a new label style that is rendered with WebGL2.
To use the default value for a color option, set it to null.

Parameters

font?: Font
The font for the label's text. Defaults to '12px Arial'.
textColor?: Color
The color of the label's text. Defaults to BLACK.
backgroundColor?: Color
The color of the label's background. Defaults to TRANSPARENT, which does not render a background.
backgroundStroke?: WebGLStroke
The color of the label's background border. Defaults to NONE, which does not render a stroke.
horizontalTextAlignment?: HorizontalTextAlignment
The horizontal alignment of the label's text. Defaults to LEFT.
padding?: Insets
The padding of the text within the label's bounds. Defaults to empty insets.
shape?: WebGLLabelShape
The shape of the label's background. Defaults to RECTANGLE
effect?: WebGLEffect
The effect around the label. Defaults to NONE.
samplingRate?: number
The super-sampling rate to render text at a higher resolution into the intermediate bitmap. When no value is specified, the rate is determined dynamically from the font size. For 12px it will be 2.0 and it will go up as far as 10.0 for smaller font sizes. For fonts larger than 64px it will be 0.5 and for the font sizes in between the rate will be interpolated accordingly. This works well for many fonts when textureRendering is set to SDF.
textureRendering?: WebGLTextureRendering
Rendering hint on how to resolve text blurriness on large zoom values. Defaults to SDF.
wrapping?: TextWrapping
The wrapping and trimming behavior for the label.
textWrappingShape?: TextWrappingShape
The shape the label text shall be wrapped in.
textWrappingPadding?: number
The padding between the wrapped text and the text wrapping shape.
verticalTextAlignment?: VerticalTextAlignment
The vertical text alignment to use if the label is assigned more space than needed.

Properties

Gets the color of the label's background.
readonlyfinal
Gets the color and thickness of the label's background border.
readonlyfinal
Gets the set of applied effects on this style.
readonlyfinal
Gets the font for the label.
readonlyfinal
Gets the horizontal text alignment for the label.
The default value is LEFT.
readonlyfinal
Gets the padding of the text within the label's bounds.
readonlyfinal
Gets the renderer implementation that can be queried for implementations that provide details about the visual appearance and visual behavior for a given label and this style instance.
The idiom for retrieving, e.g. an IVisualCreator implementation for a given style is:
const creator = style.renderer.getVisualCreator(label, style)
const visual = creator.createVisual(context)
readonlyfinal
Gets a super sampling rate to render text at a higher resolution.
Default value is 2. When sampling size is not set, sampling size is automatically adjusted for very small font sizes. For sizes smaller than 12, we recommend either setting no sampling size, or setting a larger one.
readonlyfinal
Gets the shape of the label's background.
Adjust the padding to ensure that rounded shapes still contain the complete text.
readonlyfinal
Gets the color of the label's text.
readonlyfinal
Gets the rendering hint on how to resolve text blurriness on large zoom values.
Default value is SDF
readonlyfinal
Gets the padding between the wrapped text and the textWrappingShape.

Note that this padding is only considered if TextWrapping is not NONE.

The default value is 0.

readonlyfinal
Gets the shape the label text shall be wrapped in when rendered.

The shape is fitted inside the label layout and text is wrapped to stay inside the shape. If a padding is set, this padding is kept between the shape and the text.

Also padding determine areas that should not be rendered into. The padding has an influence on the size and positioning of the shape, whereas the insets are overlaid.

Note: For wrapping shapes other than RECTANGLE it is recommended to adjust the style's padding and textWrappingPadding, too. Also, the preferredSize needs to be set to a suitable value to get the desired effect or a respective ILabelModel needs to be used that provides a suitable label layout.

If the value is set to RECTANGLE or TextWrapping is set to NONE, the preferred size calculation will take into account the extra space that is required by a label shape of PILL to completely render the text contents within the outline of the shape. In the case of ROUND_RECTANGLE suitable constant padding value can be configure to prevent the text from intersecting with the rounded corners.

For the cases where the value is set to other values, the calculation of the preferred size will be unaffected by the shape. This will typically lead to preferred sizes that cannot ensure that the text content is rendered within the outline. Since these values are typically used for rendering larger amounts of text that needs to wrap within a shape, a preferred size is either not required or not feasible to determine unambiguously. So developers need to either come up with and manually set an adjusted preferred size that suits the users or let the users determine the size of the label rendering, interactively. The latter can be done by letting the user interactively change the preferred size or by using a label model that does not even consider the preferred size, like the StretchNodeLabelModel with CENTER parameter which derives the size of the label from the size of the owning node.

For the majority of use-cases where label texts are only a few lines or likely a single line of text or even word, you probably want to be using the RECTANGLE which has good support for accurate preferred size calculations that lead to compact labels even with the non-rectangular label background shapes. More sophisticated label wrapping shapes are mostly meant to be used without a label background and shape but are rendered on top of another node or graph element that has its own corresponding shape and where the label is stretched across the element.

Note that values other than RECTANGLE are only considered if TextWrapping is not NONE.

The default value is RECTANGLE.

readonlyfinal
Gets the vertical text alignment to use if the label is assigned more space than needed.
The default value is TOP.
readonlyfinal

Property Value

The vertical text alignment.
Gets the text wrapping and trimming behavior.
The default value is TRIM_CHARACTER_ELLIPSIS.
readonlyfinal

Methods

Create a clone of this object.
final

Return Value

Object
A clone of this object.