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 classMapImage.MapImageBoxProvider
-
Field Summary
Fields Modifier and Type Field Description intalphaThe alpha (opacity) value of the image.booleanautoRescaleA flag indicating that the image should automatically be scaled to the right size.private java.awt.image.BufferedImagedisabledImgCacheA cache that holds a disabled (gray) version of this imageintheightThe height of the image, as set by MapCSSprivate ImageResourceimageResourceprivate java.awt.ImageimgImageIcon can change while the image is loading.private static intMAX_SIZEjava.lang.StringnameThe name of the image that should be displayed.intoffsetXThe x offset of the anchor of this imageintoffsetYThe y offset of the anchor of this imageStyleSourcesourceThe StyleSource that registered the imageprivate booleantemporaryintwidthThe width of the image, as set by MapCSS
-
Constructor Summary
Constructors Constructor Description MapImage(java.lang.String name, StyleSource source)Creates a newMapImageMapImage(java.lang.String name, StyleSource source, boolean autoRescale)Creates a newMapImage
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)floatgetAlphaFloat()Gets the alpha value the image should be multiplied withBoxTextElement.BoxProvidergetBoxProvider()Gets a box provider that provides a box that covers the size of this imageprivate java.awt.ImagegetDisabled()intgetHeight()Gets the image heightprivate java.awt.ImagegetImage()java.awt.ImagegetImage(boolean disabled)Get the image associated with this MapImage object.ImageResourcegetImageResource()Get the image resource associated with this MapImage object.intgetWidth()Gets the image widthinthashCode()booleanisTemporary()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 booleanmustRescale(java.awt.Image image)java.lang.StringtoString()
-
-
-
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,falsefor 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:
trueif 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-