public final class ReplaceableImage

  1. Object
  2. Image
  3. EncodedImage
  4. ReplaceableImage

ImplementsActionSource

Allows the image data to be replaced at runtime when a different image is available. The only limitation is that the image width/height must be identical and opacity status can’t change (an opaque image can’t be made translucent and visa versa).

Methods

public static ReplaceableImage create(EncodedImage placeholder)Creates an encoded image that can later be replaced with a different image
public byte[] getImageData()Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.
public void replace(EncodedImage newImage)Replaces the current image with the new image which must match the dimensions etc. of the previous image.
public boolean animate()Advances this image’s animation state, if it is animated.
public boolean isAnimation()Returns true if this is an animated image
public boolean isOpaque()Indicates whether this image is opaque or not

Inherited methods

Method details

create

public static ReplaceableImage create(EncodedImage placeholder)
Creates an encoded image that can later be replaced with a different image

Parameters

placeholder EncodedImage
a temporary image

Returns

image that will be replaceable later on

getImageData

public byte[] getImageData()
Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.

Returns

byte array used to create the image, e.g. encoded PNG, JPEG etc.

replace

public void replace(EncodedImage newImage)
Replaces the current image with the new image which must match the dimensions etc. of the previous image.

Parameters

newImage EncodedImage
the image to apply

animate

public boolean animate()
Advances this image’s animation state, if it is animated.

Returns

true if the animation state changed.

isAnimation

public boolean isAnimation()
Returns true if this is an animated image

Returns

true if this image represents an animation

isOpaque

public boolean isOpaque()
Indicates whether this image is opaque or not

Returns

true if the image is completely opqaque which allows for some heavy optimizations