Class MapImage


  • public class MapImage
    extends java.lang.Object
    An image that will be displayed on the map.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int alpha
      The alpha (opacity) value of the image.
      boolean autoRescale
      A flag indicating that the image should automatically be scaled to the right size.
      private java.awt.image.BufferedImage disabledImgCache
      A cache that holds a disabled (gray) version of this image
      int height
      The height of the image, as set by MapCSS
      private ImageResource imageResource  
      private java.awt.Image img
      ImageIcon can change while the image is loading.
      private static int MAX_SIZE  
      java.lang.String name
      The name of the image that should be displayed.
      int offsetX
      The x offset of the anchor of this image
      int offsetY
      The y offset of the anchor of this image
      StyleSource source
      The StyleSource that registered the image
      private boolean temporary  
      int width
      The width of the image, as set by MapCSS
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      float getAlphaFloat()
      Gets the alpha value the image should be multiplied with
      BoxTextElement.BoxProvider getBoxProvider()
      Gets a box provider that provides a box that covers the size of this image
      private java.awt.Image getDisabled()  
      int getHeight()
      Gets the image height
      private java.awt.Image getImage()  
      java.awt.Image getImage​(boolean disabled)
      Get the image associated with this MapImage object.
      ImageResource getImageResource()
      Get the image resource associated with this MapImage object.
      int getWidth()
      Gets the image width
      int hashCode()  
      boolean isTemporary()
      Determines if image is not completely loaded and getImage() returns a temporary image.
      private java.util.concurrent.CompletableFuture<java.lang.Void> load​(java.util.function.Consumer<? super ImageResource> action)  
      private java.util.concurrent.CompletableFuture<java.lang.Void> loadImage()
      Loads image resource and actual rescaled image.
      private java.util.concurrent.CompletableFuture<java.lang.Void> loadImageResource()
      Loads image resource only.
      private boolean mustRescale​(java.awt.Image image)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • img

        private java.awt.Image img
        ImageIcon can change while the image is loading.
      • alpha

        public int alpha
        The alpha (opacity) value of the image. It is multiplied to the image alpha channel. Range: 0...255
      • name

        public java.lang.String name
        The name of the image that should be displayed. It is given to the ImageProvider
      • autoRescale

        public boolean autoRescale
        A flag indicating that the image should automatically be scaled to the right size.
      • width

        public int width
        The width of the image, as set by MapCSS
      • height

        public int height
        The height of the image, as set by MapCSS
      • offsetX

        public int offsetX
        The x offset of the anchor of this image
      • offsetY

        public int offsetY
        The y offset of the anchor of this image
      • disabledImgCache

        private java.awt.image.BufferedImage disabledImgCache
        A cache that holds a disabled (gray) version of this image
    • Constructor Detail

      • MapImage

        public MapImage​(java.lang.String name,
                        StyleSource source)
        Creates a new MapImage
        Parameters:
        name - The image name
        source - The style source that requests this image
      • MapImage

        public MapImage​(java.lang.String name,
                        StyleSource source,
                        boolean autoRescale)
        Creates a new MapImage
        Parameters:
        name - The image name
        source - The style source that requests this image
        autoRescale - A flag indicating to automatically adjust the width/height of the image
    • Method Detail

      • getImage

        public java.awt.Image getImage​(boolean disabled)
        Get the image associated with this MapImage object.
        Parameters:
        disabled - true to request disabled version, false for the standard version
        Returns:
        the image
      • getImageResource

        public ImageResource getImageResource()
        Get the image resource associated with this MapImage object. This method blocks until the image resource has been loaded.
        Returns:
        the image resource
      • getImage

        private java.awt.Image getImage()
      • load

        private java.util.concurrent.CompletableFuture<java.lang.Void> load​(java.util.function.Consumer<? super ImageResource> action)
      • loadImage

        private java.util.concurrent.CompletableFuture<java.lang.Void> loadImage()
        Loads image resource and actual rescaled image.
        Returns:
        the future of the requested image
        See Also:
        loadImageResource()
      • loadImageResource

        private java.util.concurrent.CompletableFuture<java.lang.Void> loadImageResource()
        Loads image resource only.
        Returns:
        the future of the requested image resource
        See Also:
        loadImage()
      • getWidth

        public int getWidth()
        Gets the image width
        Returns:
        The real image width
      • getHeight

        public int getHeight()
        Gets the image height
        Returns:
        The real image height
      • getAlphaFloat

        public float getAlphaFloat()
        Gets the alpha value the image should be multiplied with
        Returns:
        The value in range 0..1
      • isTemporary

        public boolean isTemporary()
        Determines if image is not completely loaded and getImage() returns a temporary image.
        Returns:
        true if image is not completely loaded and getImage() returns a temporary image
      • mustRescale

        private boolean mustRescale​(java.awt.Image image)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object