public final class StorageImageAsync

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

ImplementsActionSource

Asynchronous storage image that loads in the background and not during the paint cycle effectively not blocking the EDT drawing speed.

Methods

public static StorageImageAsync create(String fileName, Image placeholder)Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed.
protected void resetCache()A subclass might choose to load asynchroniously and reset the cache when the image is ready.
protected Image getInternal()Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally.
public byte[] getImageData()Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.
public boolean animate()Advances this image’s animation state, if it is animated.
public boolean isAnimation()Returns true if this is an animated image

Inherited methods

Method details

create

public static StorageImageAsync create(String fileName, Image placeholder)
Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed. This only works reasonably well for very small files.

Parameters

fileName String
the name of the storage file
placeholder Image
an image that must be of the same size as the EncodedImage

Returns

image that will load the file seamlessly

resetCache

protected void resetCache()
A subclass might choose to load asynchroniously and reset the cache when the image is ready.

getInternal

protected Image getInternal()
Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally. This method is useful to detect when the system actually created an image instance. You shouldn’t invoke this method manually!

Returns

drawable image instance

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.

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