Class MapImage
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.styleelement.MapImage
-
-
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 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 Image
img
ImageIcon can change while the image is loading.private static int
MAX_SIZE
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(String name, StyleSource source)
Creates a newMapImage
MapImage(String name, StyleSource source, boolean autoRescale)
Creates a newMapImage
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(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 Image
getDisabled()
int
getHeight()
Gets the image heightprivate Image
getImage()
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 CompletableFuture<Void>
load(Consumer<? super ImageResource> action)
private CompletableFuture<Void>
loadImage()
Loads image resource and actual rescaled image.private CompletableFuture<Void>
loadImageResource()
Loads image resource only.private boolean
mustRescale(Image image)
String
toString()
-
-
-
Field Detail
-
MAX_SIZE
private static final int MAX_SIZE
- See Also:
- Constant Field Values
-
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 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 BufferedImage disabledImgCache
A cache that holds a disabled (gray) version of this image
-
-
Constructor Detail
-
MapImage
public MapImage(String name, StyleSource source)
Creates a newMapImage
- Parameters:
name
- The image namesource
- The style source that requests this image
-
MapImage
public MapImage(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 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 Image getDisabled()
-
load
private CompletableFuture<Void> load(Consumer<? super ImageResource> action)
-
loadImage
private CompletableFuture<Void> loadImage()
Loads image resource and actual rescaled image.- Returns:
- the future of the requested image
- See Also:
loadImageResource()
-
loadImageResource
private CompletableFuture<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(Image image)
-
-