All Implemented Interfaces:
Serializable

public class IconStyle extends ImageStyle
Icon style for vector features.

For more details see: Icon docs

See Also:
  • Field Details

    • anchor

      protected Anchor anchor
    • anchorOrigin

      protected IconOrigin anchorOrigin
    • anchorXUnits

      protected IconAnchorUnits anchorXUnits
    • anchorYUnits

      protected IconAnchorUnits anchorYUnits
    • color

      protected String color
    • crossOrigin

      protected String crossOrigin
    • resource

      protected com.vaadin.flow.server.StreamResource resource
    • width

      protected Integer width
    • height

      protected Integer height
    • offset

      protected Offset offset
    • offsetOrigin

      protected IconOrigin offsetOrigin
    • size

      protected Size size
    • src

      protected String src
  • Constructor Details

    • IconStyle

      public IconStyle()
  • Method Details

    • getType

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

      public Anchor getAnchor()
      Returns:
      anchor value or null if not set
    • setAnchor

      public void setAnchor(Anchor anchor)
      Sets the icon anchor. The default value is the icon center ([0.5, 0,5]).

      For more details see: setAnchor() docs

      Parameters:
      anchor - anchor value
    • withAnchor

      public IconStyle withAnchor(Anchor anchor)
      Parameters:
      anchor - anchor value
      Returns:
      current instance
    • getAnchorOrigin

      public IconOrigin getAnchorOrigin()
    • setAnchorOrigin

      public void setAnchorOrigin(IconOrigin anchorOrigin)
      Sets the origin of the anchor.

      Note, anchor origin attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      anchorOrigin - origin of the anchor
    • withAnchorOrigin

      public IconStyle withAnchorOrigin(IconOrigin anchorOrigin)
      Parameters:
      anchorOrigin - origin of the anchor
      Returns:
      current instance
    • getAnchorXUnits

      public IconAnchorUnits getAnchorXUnits()
      Returns:
      units or null if not set
    • setAnchorXUnits

      public void setAnchorXUnits(IconAnchorUnits anchorXUnits)
      Sets units in which the anchor X value is specified. A value of IconAnchorUnits.FRACTION indicates the X value is a fraction of the icon. A value of IconAnchorUnits.PIXELS indicates the X value in pixels. The default value is IconAnchorUnits.FRACTION.

      Note, anchor X units attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      anchorXUnits - units to set
    • withAnchorXUnits

      public IconStyle withAnchorXUnits(IconAnchorUnits anchorXUnits)
      Parameters:
      anchorXUnits - units to set
      Returns:
      current instance
    • getAnchorYUnits

      public IconAnchorUnits getAnchorYUnits()
      Returns:
      units or null if not set
    • setAnchorYUnits

      public void setAnchorYUnits(IconAnchorUnits anchorYUnits)
      Sets units in which the anchor Y value is specified. A value of IconAnchorUnits.FRACTION indicates the Y value is a fraction of the icon. A value of IconAnchorUnits.PIXELS indicates the Y value in pixels. The default value is IconAnchorUnits.FRACTION.

      Note, anchor Y units attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      anchorYUnits - units to set
    • withAnchorYUnits

      public IconStyle withAnchorYUnits(IconAnchorUnits anchorYUnits)
      Parameters:
      anchorYUnits - units to set
      Returns:
      current instance
    • getColor

      public String getColor()
      Returns:
      color of the icon or null if not set
    • setColor

      public void setColor(String color)
      Sets the color to tint the icon. If not specified, the icon will be left as is.

      Note, color attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      color - color to set
    • withColor

      public IconStyle withColor(String color)
      Parameters:
      color - color to set
      Returns:
      current instance
    • getCrossOrigin

      public String getCrossOrigin()
      Returns:
      cross-origin value or null if not set
    • setCrossOrigin

      public void setCrossOrigin(String crossOrigin)
      Sets the cross-origin attribute for loaded images.

      Note, cross-origin attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      crossOrigin - cross-origin value
    • withCrossOrigin

      public IconStyle withCrossOrigin(String crossOrigin)
      Parameters:
      crossOrigin - cross-origin value
      Returns:
      current instance
    • getResource

      public com.vaadin.flow.server.StreamResource getResource()
      Returns:
      stream resource or null if not set
    • setResource

      public void setResource(com.vaadin.flow.server.StreamResource resource)
      Sets stream resource. It takes precedence over the setSrc(String).

      Note, resource attribute is set only at creation time and cannot be changed at runtime.

      Parameters:
      resource - stream resource
    • withResource

      public IconStyle withResource(com.vaadin.flow.server.StreamResource resource)
      Parameters:
      resource - stream resource
      Returns:
      current instance
    • getWidth

      public Integer getWidth()
      Returns:
      width value in pixels or null if not set
    • setWidth

      public void setWidth(Integer width)
      Sets the width of the icon in pixels. Width can't be used together with setScale(Double) or setScaleSize(Size).

      Note, width attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      width - width of the icon
    • withWidth

      public IconStyle withWidth(Integer width)
      Parameters:
      width - width of the icon
      Returns:
      current instance
    • getHeight

      public Integer getHeight()
      Returns:
      height value in pixels or null if not set
    • setHeight

      public void setHeight(Integer height)
      Sets the height of the icon in pixels. Height can't be used together with setScale(Double) or setScaleSize(Size).

      Note, height attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      height - height of the icon
    • withHeight

      public IconStyle withHeight(Integer height)
      Parameters:
      height - height of the icon
      Returns:
      current instance
    • getOffset

      public Offset getOffset()
      Returns:
      offset value or null if not set
    • setOffset

      public void setOffset(Offset offset)
      Sets offset which, together with setSize(Size) and setOffsetOrigin(IconOrigin), defines the sub-rectangle to use from the original (sprite) image. The default value is [0, 0].

      Note, offset attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      offset - offset value
    • withOffset

      public IconStyle withOffset(Offset offset)
      Parameters:
      offset - offset value
      Returns:
      current instance
    • getOffsetOrigin

      public IconOrigin getOffsetOrigin()
      Returns:
      origin of the offset or null if not set
    • setOffsetOrigin

      public void setOffsetOrigin(IconOrigin offsetOrigin)
      Sets the origin of the offset. The default value is IconOrigin.TOP_LEFT.

      Note, offset origin attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      offsetOrigin - origin of the offset
    • withOffsetOrigin

      public IconStyle withOffsetOrigin(IconOrigin offsetOrigin)
      Parameters:
      offsetOrigin - origin of the offset
      Returns:
      current instance
    • getSize

      public Size getSize()
      Returns:
      icon size in pixels or null if not set
    • setSize

      public void setSize(Size size)
      Sets the icon size in pixels. Used together with setOffset(Offset) to define the sub-rectangle to use from the original (sprite) image.

      Note, size attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      size - icon size in pixels
    • withSize

      public IconStyle withSize(Size size)
      Parameters:
      size - icon size in pixels
      Returns:
      current instance
    • getSrc

      public String getSrc()
      Returns:
      source URI or null if not set
    • setSrc

      public void setSrc(String src)
      Sets the image source URI. Note, if setResource(StreamResource) is defined, it will take precedence over src attribute.

      Note, src attribute is set only at creation time and cannot be changed at runtime.

      For more details see: Icon docs

      Parameters:
      src - source URI
    • withSrc

      public IconStyle withSrc(String src)
      Parameters:
      src - source URI
      Returns:
      current instance
    • getOpacity

      public Double getOpacity()
      Overrides:
      getOpacity in class ImageStyle
      Returns:
      opacity or null if not set
    • setOpacity

      public void setOpacity(Double opacity)
      Sets the opacity.

      For more details see: setOpacity() docs

      Overrides:
      setOpacity in class ImageStyle
      Parameters:
      opacity - opacity to set
    • withOpacity

      public IconStyle withOpacity(Double opacity)
      Parameters:
      opacity - opacity to set
      Returns:
      current instance
    • getRotateWithView

      public Boolean getRotateWithView()
      Overrides:
      getRotateWithView in class ImageStyle
      Returns:
      whether the image should get rotated with the map view or null if not set
    • setRotateWithView

      public void setRotateWithView(Boolean rotateWithView)
      Sets whether the styled image should be rotated with the map view rotation.

      For more details see: setRotateWithView() docs

      Default value is false. For more details see: setRotateWithView() docs

      Overrides:
      setRotateWithView in class ImageStyle
      Parameters:
      rotateWithView - whether the styled image should be rotated
    • withRotateWithView

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

      public Double getRotation()
      Overrides:
      getRotation in class ImageStyle
      Returns:
      rotation value or null if not set
    • setRotation

      public void setRotation(Double rotation)
      Sets the rotation value.

      For more details see: setRotation() docs

      The default value is 0.

      For more details see: setRotateWithView() docs

      Overrides:
      setRotation in class ImageStyle
      Parameters:
      rotation - rotation value
    • withRotation

      public IconStyle withRotation(Double rotation)
      Parameters:
      rotation - rotation value
      Returns:
      current instance
    • getScale

      public Double getScale()
      Overrides:
      getScale in class ImageStyle
      Returns:
      scale value or null if not set
    • setScale

      public void setScale(Double scale)
      Sets the scale. Note, if setScaleSize(Size) is set, it will take precedence over the scale. The default value is 1.

      For more details see: setScale() docs

      Overrides:
      setScale in class ImageStyle
      Parameters:
      scale - scale value
    • withScale

      public IconStyle withScale(Double scale)
      Parameters:
      scale - scale value
      Returns:
      current instance
    • getScaleSize

      public Size getScaleSize()
      Overrides:
      getScaleSize in class ImageStyle
      Returns:
      scale size or null if not set
    • setScaleSize

      public void setScaleSize(Size scaleSize)
      Sets the scale size. Note, it takes precedence over the ImageStyle.setScale(Double).

      For more details see: setScale() docs

      Overrides:
      setScaleSize in class ImageStyle
      Parameters:
      scaleSize - scale size
    • withScaleSize

      public IconStyle withScaleSize(Size scaleSize)
      Parameters:
      scaleSize - scale size
      Returns:
      current instance
    • getDisplacement

      public Displacement getDisplacement()
      Overrides:
      getDisplacement in class ImageStyle
      Returns:
      displacement value or null if not set
    • setDisplacement

      public void setDisplacement(Displacement displacement)
      Sets the displacement of the icon in pixels. Positive values will shift the icon right and up. The default value is [0, 0].

      For more details see: setDisplacement() docs

      Overrides:
      setDisplacement in class ImageStyle
      Parameters:
      displacement - displacement value
    • withDisplacement

      public IconStyle withDisplacement(Displacement displacement)
      Parameters:
      displacement - displacement value
      Returns:
      current instance
    • getDeclutterMode

      public DeclutterMode getDeclutterMode()
      Overrides:
      getDeclutterMode in class ImageStyle
      Returns:
      declutter mode or null if not set
    • setDeclutterMode

      public void setDeclutterMode(DeclutterMode declutterMode)
      Sets declutter mode.

      Note, declutter mode attribute is set only at creation time and cannot be changed at runtime.

      For more details see: ImageStyle docs

      Overrides:
      setDeclutterMode in class ImageStyle
      Parameters:
      declutterMode - declutter mode value
    • withDeclutterMode

      public IconStyle withDeclutterMode(DeclutterMode declutterMode)
      Parameters:
      declutterMode - declutter mode value
      Returns:
      current instance