java.lang.Object
io.jmix.mapsflowui.kit.component.model.MapObservableObject
io.jmix.mapsflowui.kit.component.model.style.text.TextStyle
All Implemented Interfaces:
Serializable

public class TextStyle extends MapObservableObject
Text style for vector features.

For more details see: Text docs

See Also:
  • Field Details

    • font

      protected String font
    • maxAngle

      protected Double maxAngle
    • offsetX

      protected Integer offsetX
    • offsetY

      protected Integer offsetY
    • overflow

      protected Boolean overflow
    • placement

      protected TextPlacement placement
    • repeat

      protected Integer repeat
    • scale

      protected Double scale
    • scaleSize

      protected Size scaleSize
    • rotateWithView

      protected Boolean rotateWithView
    • rotation

      protected Double rotation
    • text

      protected String text
    • textAlign

      protected TextAlign textAlign
    • justify

      protected TextJustify justify
    • textBaseline

      protected TextBaseline textBaseline
    • fill

      protected Fill fill
    • stroke

      protected Stroke stroke
    • backgroundFill

      protected Fill backgroundFill
    • backgroundStroke

      protected Stroke backgroundStroke
    • padding

      protected Padding padding
  • Constructor Details

    • TextStyle

      public TextStyle()
  • Method Details

    • getType

      protected String getType()
      Specified by:
      getType in class MapObservableObject
    • getFont

      public String getFont()
      Returns:
      font value or null if not set
    • setFont

      public void setFont(String font)
      Sets font style as CSS font. The default value is "10px sans-serif".

      For more details see: setFont() docs

      Parameters:
      font - font value
    • withFont

      public TextStyle withFont(String font)
      Parameters:
      font - font value
      Returns:
      current instance
    • getMaxAngle

      public Double getMaxAngle()
      Returns:
      maximum angle or null if not set
    • setMaxAngle

      public void setMaxAngle(Double maxAngle)
      Sets maximum angle between adjacent characters. It is enabled when setPlacement(TextPlacement) is set to TextPlacement.LINE. The default value is 45 degrees (PI/4).

      For more details see: setMaxAngle() docs

      Parameters:
      maxAngle - maximum angle in radians
    • withMaxAngle

      public TextStyle withMaxAngle(Double maxAngle)
      Parameters:
      maxAngle - maximum angle in radians
      Returns:
      current instance
    • getOffsetX

      public Integer getOffsetX()
      Returns:
      horizontal text offset or null if not set
    • setOffsetX

      public void setOffsetX(Integer offsetX)
      Sets the horizontal text offset in pixels. A positive will shift the text right. The default value is 0.

      For more details see: setOffsetX() docs

      Parameters:
      offsetX - horizontal text offset
    • withOffsetX

      public TextStyle withOffsetX(Integer offsetX)
      Parameters:
      offsetX - horizontal text offset
      Returns:
      current instance
    • getOffsetY

      public Integer getOffsetY()
      Returns:
      vertical text offset or null if not set
    • setOffsetY

      public void setOffsetY(Integer offsetY)
      Sets the vertical text offset in pixels. A positive will shift the text down. The default value is 0.

      For more details see: setOffsetY() docs

      Parameters:
      offsetY - vertical text offset
    • withOffsetY

      public TextStyle withOffsetY(Integer offsetY)
      Parameters:
      offsetY - vertical text offset
      Returns:
      current instance
    • getOverflow

      public Boolean getOverflow()
      Returns:
      is overflow enabled or null if not set
    • setOverflow

      public void setOverflow(Boolean overflow)
      Sets the overflow. Is used for polygon labels or when setPlacement(TextPlacement) is set to TextPlacement.LINE. Enables text to exceed the width of the polygon at the label position or the length of the path that it follows. The default value is false.

      For more details see: setOverflow() docs

      Parameters:
      overflow - whether overflow enabled
    • withOverflow

      public TextStyle withOverflow(Boolean overflow)
      Parameters:
      overflow - whether overflow enabled
      Returns:
      current instance
    • getPlacement

      public TextPlacement getPlacement()
    • setPlacement

      public void setPlacement(TextPlacement placement)
      Sets text placement. The default value is TextPlacement.POINT.

      For more details see: setPlacement() docs

      Parameters:
      placement - text placement
    • withPlacement

      public TextStyle withPlacement(TextPlacement placement)
      Parameters:
      placement - text placement
      Returns:
      current instance
    • getRepeat

      public Integer getRepeat()
      Returns:
      repeat interval or null if not set
    • setRepeat

      public void setRepeat(Integer repeat)
      Sets the repeat interval of text. If repeat is set, the text will be repeated at this interval, which specifies the distance between two text anchors in pixels. Only available when setPlacement(TextPlacement) is set to TextPlacement.LINE. Overrides setTextAlign(TextAlign).

      For more details see: setRepeat() docs

      Parameters:
      repeat - repeat interval
    • withRepeat

      public TextStyle withRepeat(Integer repeat)
      Parameters:
      repeat - repeat interval
      Returns:
      current instance
    • getScale

      public Double getScale()
      Returns:
      text scale or null if not set
    • setScale

      public void setScale(Double scale)
      Sets text scale. Note, if setScaleSize(Size) is defined, it will take precedence over scale.

      For more details see: setScale() docs

      Parameters:
      scale - text scale
    • withScale

      public TextStyle withScale(Double scale)
      Parameters:
      scale - text scale
      Returns:
      current instance
    • getScaleSize

      public Size getScaleSize()
      Returns:
      text scale size or null if not set
    • setScaleSize

      public void setScaleSize(Size scaleSize)
      Sets scale size. It takes precedence over setScale(Double).

      For more details see: setScale() docs

      Parameters:
      scaleSize - text scale size
    • withScaleSize

      public TextStyle withScaleSize(Size scaleSize)
      Parameters:
      scaleSize - text scale size
      Returns:
      current instance
    • getRotateWithView

      public Boolean getRotateWithView()
      Returns:
      whether to rotate the text with the map view or null if not set
    • setRotateWithView

      public void setRotateWithView(Boolean rotateWithView)
      Sets whether to rotate the text with the map view. The default value is false.

      For more details see: setRotateWithView() docs

      Parameters:
      rotateWithView - rotateWithView option
    • withRotateWithView

      public TextStyle withRotateWithView(Boolean rotateWithView)
      Parameters:
      rotateWithView - rotateWithView option
      Returns:
      current instance
    • getRotation

      public Double getRotation()
      Returns:
      text rotation or null if not set
    • setRotation

      public void setRotation(Double rotation)
      Sets the rotation in radians (positive rotation clockwise).

      For more details see: setRotation() docs

      Parameters:
      rotation - text rotation
    • withRotation

      public TextStyle withRotation(Double rotation)
      Parameters:
      rotation - text rotation
      Returns:
      current instance
    • getText

      public String getText()
      Returns:
      text content or null if not set
    • setText

      public void setText(String text)
      Sets text content. Text may contains line breaks "\n".

      For more details see: setText() docs

      Parameters:
      text - text content
    • withText

      public TextStyle withText(String text)
      Parameters:
      text - text content
      Returns:
      current instance
    • getTextAlign

      public TextAlign getTextAlign()
      Returns:
      text alignment or null if not set
    • setTextAlign

      public void setTextAlign(TextAlign textAlign)
      Sets text alignment. For placement TextPlacement.POINT, the default value is TextAlign.CENTER. For placement TextPlacement.LINE, the default is to let the renderer choose a placement where setMaxAngle(Double) is not exceeded.

      For more details see: setTextAlign() docs

      Parameters:
      textAlign - text alignment
    • withTextAlign

      public TextStyle withTextAlign(TextAlign textAlign)
      Parameters:
      textAlign - text alignment
      Returns:
      current instance
    • getJustify

      public TextJustify getJustify()
      Returns:
      text justify option or null if not set
    • setJustify

      public void setJustify(TextJustify justify)
      Sets the text justification within the text box. If not set, text is justified towards the setTextAlign(TextAlign) anchor. Otherwise, use TextJustify options to justify the text within the text box. Note, justify is ignored for immediate rendering and also for TextPlacement.LINE.

      For more details see: setJustify() docs

      Parameters:
      justify - text justify option
    • withJustify

      public TextStyle withJustify(TextJustify justify)
      Parameters:
      justify - text justify option
      Returns:
      current instance
    • getTextBaseline

      public TextBaseline getTextBaseline()
      Returns:
      text baseline or null if not set
    • setTextBaseline

      public void setTextBaseline(TextBaseline textBaseline)
      Sets the text baseline. The default value is TextBaseline.MIDDLE.

      For more details see: setTextBaseline() docs

      Parameters:
      textBaseline - text baseline
    • withTextBaseline

      public TextStyle withTextBaseline(TextBaseline textBaseline)
      Parameters:
      textBaseline - text baseline
      Returns:
      current instance
    • getFill

      public Fill getFill()
      Returns:
      fill style or null if not set
    • setFill

      public void setFill(Fill fill)
      Sets fill object that describes which color should be used for filling text.

      For more details see: setFill() docs

      Parameters:
      fill - fill to set
    • withFill

      public TextStyle withFill(Fill fill)
      Parameters:
      fill - fill to set
      Returns:
      current instance
    • getStroke

      public Stroke getStroke()
      Returns:
      stroke style or null if not set
    • setStroke

      public void setStroke(Stroke stroke)
      Sets stroke style for text. It describes line styling: width, color, dash, etc.

      For more details see: setStroke() docs

      Parameters:
      stroke - stroke style
    • withStroke

      public TextStyle withStroke(Stroke stroke)
      Parameters:
      stroke - stroke style
      Returns:
      current instance
    • getBackgroundFill

      public Fill getBackgroundFill()
      Returns:
      background fill style or null if not set
    • setBackgroundFill

      public void setBackgroundFill(Fill backgroundFill)
      Sets fill object that describes color for text background when TextPlacement.POINT. Default is no fill.

      For more details see: setBackgroundFill() docs

      Parameters:
      backgroundFill - background fill style
    • withBackgroundFill

      public TextStyle withBackgroundFill(Fill backgroundFill)
      Parameters:
      backgroundFill - background fill style
      Returns:
      current instance
    • getBackgroundStroke

      public Stroke getBackgroundStroke()
      Returns:
      background stroke style null if not set
    • setBackgroundStroke

      public void setBackgroundStroke(Stroke backgroundStroke)
      Sets stroke object for text background when TextPlacement.POINT. Default is no stroke.

      For more details see: setBackgroundStroke() docs

      Parameters:
      backgroundStroke - background stroke style
    • withBackgroundStroke

      public TextStyle withBackgroundStroke(Stroke backgroundStroke)
      Parameters:
      backgroundStroke - background stroke style
      Returns:
      current instance
    • getPadding

      public Padding getPadding()
      Returns:
      padding or null if not set
    • setPadding

      public void setPadding(Padding padding)
      Sets the padding in pixels around the text for decluttering and background. The default value is [0, 0, 0, 0].

      For more details see: setPadding() docs

      Parameters:
      padding - padding to set
    • withPadding

      public TextStyle withPadding(Padding padding)
      Parameters:
      padding - padding to set
      Returns:
      current instance