Class MapImage
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.styleelement.MapImage
-
public class MapImage extends java.lang.Object
An image that will be displayed on the map.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
MapImage.MapImageBoxProvider
-
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 imageint
height
The height of the image, as set by MapCSSprivate 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 imageint
offsetY
The y offset of the anchor of this imageStyleSource
source
The StyleSource that registered the imageprivate boolean
temporary
int
width
The width of the image, as set by MapCSS
-
Constructor Summary
Constructors Constructor Description MapImage(java.lang.String name, StyleSource source)
Creates a newMapImage
MapImage(java.lang.String name, StyleSource source, boolean autoRescale)
Creates a newMapImage
-
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 withBoxTextElement.BoxProvider
getBoxProvider()
Gets a box provider that provides a box that covers the size of this imageprivate java.awt.Image
getDisabled()
int
getHeight()
Gets the image heightprivate 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 widthint
hashCode()
boolean
isTemporary()
Determines if image is not completely loaded andgetImage()
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()
-
-
-
Field Detail
-
MAX_SIZE
private static final int MAX_SIZE
- See Also:
- Constant Field Values
-
img
private java.awt.Image img
ImageIcon can change while the image is loading.
-
imageResource
private ImageResource imageResource
-
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 theImageProvider
-
source
public StyleSource source
The StyleSource that registered the image
-
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
-
temporary
private boolean temporary
-
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 newMapImage
- Parameters:
name
- The image namesource
- The style source that requests this image
-
MapImage
public MapImage(java.lang.String name, StyleSource source, boolean autoRescale)
Creates a newMapImage
- Parameters:
name
- The image namesource
- The style source that requests this imageautoRescale
- 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
-
getDisabled
private java.awt.Image getDisabled()
-
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 andgetImage()
returns a temporary image.- Returns:
true
if image is not completely loaded and getImage() returns a temporary image
-
getBoxProvider
public BoxTextElement.BoxProvider getBoxProvider()
Gets a box provider that provides a box that covers the size of this image- Returns:
- The box provider
-
mustRescale
private boolean mustRescale(java.awt.Image image)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-