A label style for use in WebGL2 rendering.
Remarks
Type Details
- yfiles module
- view-webgl
- yfiles-umd modules
- view-webgl, view
- Legacy UMD name
- yfiles.view.WebGL2DefaultLabelStyle
See Also
Constructors
WebGL2DefaultLabelStyle
(font?: Font, textColor?: Color, backgroundColor?: Color, backgroundStroke?: WebGL2Stroke, textAlignment?: HorizontalTextAlignment, insets?: number, shape?: WebGL2LabelShape, effect?: WebGL2Effect, samplingRate?: number, textureRendering?: WebGL2TextureRendering, wrapping?: TextWrapping, textWrappingShape?: TextWrappingShape, textWrappingPadding?: number, verticalTextAlignment?: VerticalTextAlignment)Creates a new label style that is rendered with WebGL2.
Remarks
null
.Parameters
A map of options to pass to the method.
- 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 - WebGL2Stroke
- The color of the label's background border. Defaults to NONE, which does not render a stroke.
- textAlignment - HorizontalTextAlignment
- The horizontal alignment of the label's text. Defaults to LEFT.
- insets - number
- The padding of the text within the label's bounds. Defaults to
0
. - shape - WebGL2LabelShape
- The shape of the label's background. Defaults to RECTANGLE
- effect - WebGL2Effect
- 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 as10.0
for smaller font sizes. For fonts larger than 64px it will be0.5
and for the font sizes in between the rate will be interpolated accordingly. This works well for many fonts whentextureRendering
is set to SDF. - textureRendering - WebGL2TextureRendering
- 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.
Gets the color and thickness of the label's background border.
Gets the set of applied effects on this style.
Gets the font for the label.
Gets a super sampling rate to render text at a higher resolution.
Remarks
Gets the shape of the label's background.
Remarks
Gets the horizontal text alignment for the label.
Gets the color of the label's text.
Gets the rendering hint on how to resolve text blurriness on large zoom values.
Remarks
Gets the padding between the wrapped text and the textWrappingShape.
Remarks
Note that this padding is only considered if TextWrapping is not NONE.
The default value is 0
.
Gets the shape the label text shall be wrapped in when rendered.
Remarks
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 insets 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 insets 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 insets 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 InteriorStretchLabelModel 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.
Gets the vertical text alignment to use if the label is assigned more space than needed.
Remarks
Gets the text wrapping and trimming behavior.