All Implemented Interfaces:
Serializable

public class Icon extends ImageStyle
An icon or image that can be used to visually represent a Feature, by using it as the feature's Style.setImage(ImageStyle)
Since:
23.0
See Also:
  • Constructor Details

  • 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
    • getAnchor

      public Icon.Anchor getAnchor()
      The anchor position of the image. This defines how the image should be aligned from the getAnchorOrigin(). The anchor position is specified in relative units, based on the size of the image. Valid values range from 0 to 1, where 1 moves the image by its full width or height from the anchor origin. Default value is {x: 0.5, y: 0.5}, which centers the image.
      Returns:
      the current anchor
    • setAnchor

      public void setAnchor(Icon.Anchor anchor)
      Sets the anchor position of the icon's image
      Parameters:
      anchor - the new anchor
    • getAnchorOrigin

      public Icon.AnchorOrigin getAnchorOrigin()
      The origin of the getAnchor() position. Defaults to Icon.AnchorOrigin.TOP_LEFT.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the current anchor origin
    • getColor

      public String getColor()
      Color to tint the icon's image with. If not specified, the image will not be modified.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the current color tint
    • getCrossOrigin

      public String getCrossOrigin()
      The cross-origin attribute value for loaded images.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the cross-origin attribute value
    • getSrc

      public String getSrc()
      The source URL from which the icon's image should be loaded. Either this, or getImg() must be specified in the options for the icon, and only one of the two options must be provided.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the source URL for the icon's image
    • getImg

      @Deprecated(since="24.8") public com.vaadin.flow.server.StreamResource getImg()
      Deprecated.
      use getImg() instead
      The stream resource from which the icon's image should be loaded. Either this or getSrc() must be specified in the options for the icon, and only one of the two options must be provided.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the stream resource containing the icon's image
    • getImgHandler

      public com.vaadin.flow.server.streams.DownloadHandler getImgHandler()
      The stream resource from which the icon's image should be loaded. Either this or getSrc() must be specified in the options for the icon, and only one of the two options must be provided.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the stream resource containing the icon's image
      Since:
      24.8
    • getImgSize

      @Deprecated(since="25.4") public Icon.ImageSize getImgSize()
      Deprecated.
      this option has no effect on how the icon is rendered, use getWidth() and getHeight() to control the rendered size of the icon instead
      The size of the image in pixels.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the size of the image
    • getWidth

      public Integer getWidth()
      The width in pixels at which the icon's image is rendered. If only the width is specified, the height is adjusted to preserve the image's aspect ratio. If both width and height are specified, the image is stretched to exactly that size. If neither is specified, the image is rendered at its natural size.

      The scale is applied on top of this size, for example a width of 50 combined with a scale of 2 renders the icon 100 pixels wide.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the width in pixels, or null if not specified
      Since:
      25.4
    • getHeight

      public Integer getHeight()
      The height in pixels at which the icon's image is rendered. If only the height is specified, the width is adjusted to preserve the image's aspect ratio. If both width and height are specified, the image is stretched to exactly that size. If neither is specified, the image is rendered at its natural size.

      The scale is applied on top of this size, for example a height of 50 combined with a scale of 2 renders the icon 100 pixels high.

      This value can not be changed after constructing an instance, it can only be set initially by passing an options object to the constructor.

      Returns:
      the height in pixels, or null if not specified
      Since:
      25.4