java.lang.Object
com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
com.vaadin.flow.component.map.configuration.style.TextStyle
All Implemented Interfaces:
Serializable

public class TextStyle extends AbstractConfigurationObject
Text style that defines how to render texts on the map.
See Also:
  • Constructor Details

    • TextStyle

      public TextStyle()
  • Method Details

    • getType

      public String getType()
      Description copied from class: AbstractConfigurationObject
      The unique type name of this class. Used by the client-side synchronization mechanism to determine which OpenLayers class to synchronize into.
      Specified by:
      getType in class AbstractConfigurationObject
    • getFont

      public String getFont()
      The font style as CSS `font` value.
      Returns:
      the font style
    • setFont

      public void setFont(String font)
      Sets the font style as CSS `font` value. See CanvasRenderingContext2D.font. Default is 13px sans-serif.
      Parameters:
      font - the new font style
    • getOffset

      public TextStyle.TextOffset getOffset()
      The offset of the text from its anchor point.
      Returns:
      the offset
    • setOffset

      public void setOffset(TextStyle.TextOffset offset)
      Sets the offset of the text from whatever it is anchored to, in pixels. For example, a marker text is anchored to the marker's position, and then shifted by the specified offset. Default is {x: 0, y: 10}
      Parameters:
      offset - the new offset
    • setOffset

      public void setOffset(int x, int y)
      Sets the offset of the text from whatever it is anchored to, in pixels. For example, a marker text is anchored to the marker's position, and then shifted by the specified offset. Default is {x: 0, y: 10}
      Parameters:
      x - the horizontal offset in pixels
      y - the vertical offset in pixels
    • getScale

      public double getScale()
      The scaling to apply to the text.
      Returns:
      the scale value
    • setScale

      public void setScale(double scale)
      Sets the scaling factor to apply to the text. Default value is 1.
      Parameters:
      scale - the new scaling factor.
    • getRotation

      public double getRotation()
      The rotation to apply to the text, in radians.
      Returns:
      the rotation, in radians
    • setRotation

      public void setRotation(double rotation)
      Sets the rotation to apply to the text, in radians. Default value is 0.
      Parameters:
      rotation - the new rotation, in radians
    • isRotateWithView

      public boolean isRotateWithView()
      Whether to rotate the text with the view.
      Returns:
      whether to rotate the text with the view
    • setRotateWithView

      public void setRotateWithView(boolean rotateWithView)
      Sets whether to rotate the text with the view. Default value is false.
      Parameters:
      rotateWithView - whether to rotate the text with the view
    • getTextAlign

      public TextStyle.TextAlign getTextAlign()
      The horizontal text alignment based from the text's anchor point.
      Returns:
      the horizontal alignment
    • setTextAlign

      public void setTextAlign(TextStyle.TextAlign textAlign)
      Sets the horizontal alignment based from the text's anchor point, including the offset set using setOffset(TextOffset). Default value is TextStyle.TextAlign.CENTER.
      Parameters:
      textAlign - the new alignment
    • getTextBaseline

      public TextStyle.TextBaseline getTextBaseline()
      The vertical baseline for aligning the text based on its anchor point.
      Returns:
      the vertical baseline
    • setTextBaseline

      public void setTextBaseline(TextStyle.TextBaseline textBaseline)
      Sets the vertical baseline for aligning the text based on its anchor point, including the offset set using setOffset(TextOffset). Default value is TextStyle.TextBaseline.MIDDLE.
      Parameters:
      textBaseline - the new baseline
    • getFill

      public Fill getFill()
      The fill color to use for rendering the text.
      Returns:
      the text's fill color
    • setFill

      public void setFill(Fill fill)
      Sets the fill color to use for rendering the text. This is effectively the text's color, which can be complemented by an outline by setting setStroke(Stroke). The fill's color value must be a valid CSS color. The default fill color is #333.
      Parameters:
      fill - the new fill color
    • setFill

      public void setFill(String fillColor)
      Sets the fill color to use for rendering the text. This is effectively the text's color, which can be complemented by an outline by setting setStroke(Stroke). The fill's color value must be a valid CSS color. The default fill color is #333.
      Parameters:
      fillColor - the new fill color
    • getStroke

      public Stroke getStroke()
      The stroke to use for rendering the text.
      Returns:
      the text's stroke
    • setStroke

      public void setStroke(Stroke stroke)
      Sets the stroke to use for rendering the text. This effectively renders an outline around the text, see setFill(Fill) for setting the text's main color. The stroke's color must be a valid CSS color, and its width is specified in pixels. The default stroke's color is #fff, and the default width is 3 pixels.
      Parameters:
      stroke - the new stroke
    • setStroke

      public void setStroke(String strokeColor, int strokeWidth)
      Sets the stroke to use for rendering the text. This effectively renders an outline around the text, see setFill(Fill) for setting the text's main color. The stroke's color must be a valid CSS color, and its width is specified in pixels. The default stroke's color is #fff, and the default width is 3 pixels.
      Parameters:
      strokeColor - the new stroke color
      strokeWidth - the new stroke width
    • getBackgroundFill

      public Fill getBackgroundFill()
      The fill color to use for the background of the text.
      Returns:
      the text's background fill
    • setBackgroundFill

      public void setBackgroundFill(Fill backgroundFill)
      Sets the fill color to use for the background of the text. The fill's color must be a valid CSS color. By default, the text does not use a background color.
      Parameters:
      backgroundFill - the new background fill color
    • setBackgroundFill

      public void setBackgroundFill(String fillColor)
      Sets the fill color to use for the background of the text. The fill's color must be a valid CSS color. By default, the text does not use a background color.
      Parameters:
      fillColor - the new background fill color
    • getBackgroundStroke

      public Stroke getBackgroundStroke()
      The stroke with which to render the texts background border.
      Returns:
      the text's background stroke
    • setBackgroundStroke

      public void setBackgroundStroke(Stroke backgroundStroke)
      Sets the stroke with which to render the texts background border. The stroke's color must be a valid CSS color, and its width is specified in pixels. By default, the text does not use a background stroke.
      Parameters:
      backgroundStroke - the new background stroke
    • setBackgroundStroke

      public void setBackgroundStroke(String strokeColor, int strokeWidth)
      Sets the stroke with which to render the texts background border. The stroke's color must be a valid CSS color, and its width is specified in pixels. By default, the text does not use a background stroke.
      Parameters:
      strokeColor - the new background stroke color
      strokeWidth - the new background stroke width
    • getPadding

      public int getPadding()
      The padding for the text's background.
      Returns:
      the background padding
    • setPadding

      public void setPadding(int padding)
      Sets the padding for the text's background. The padding is applied to all sides of the background. Default value is 0.
      Parameters:
      padding - the new padding