public class URLImage extends EncodedImage
By default an image is fetched lazily as it is asked for by the GUI unless the fetch() method is invoked in which case the IO code is executed immediately.
Modifier and Type | Class and Description |
---|---|
static interface |
URLImage.ImageAdapter
Allows applying resize logic to downloaded images you can use constant
resize behaviors defined in this class.
|
Modifier and Type | Field and Description |
---|---|
static URLImage.ImageAdapter |
RESIZE_FAIL
Will fail if the downloaded image has a different size from the placeholder image
|
static URLImage.ImageAdapter |
RESIZE_SCALE
Scales the image to match the size of the new image exactly
|
static URLImage.ImageAdapter |
RESIZE_SCALE_TO_FILL
Scales the image to match to fill the area while preserving aspect ratio
|
Modifier and Type | Method and Description |
---|---|
boolean |
animate() |
static URLImage |
createToFileSystem(EncodedImage placeholder,
String file,
String url,
URLImage.ImageAdapter adapter)
Creates an image the will be downloaded on the fly as necessary
|
static URLImage |
createToStorage(EncodedImage placeholder,
String storageFile,
String url,
URLImage.ImageAdapter adapter)
Creates an image the will be downloaded on the fly as necessary
|
void |
fetch()
Images are normally fetched from storage or network only as needed,
however if the download must start before the image is drawn this method
can be invoked.
|
byte[] |
getImageData()
Returns the byte array data backing the image allowing the image to be stored
and discarded completely from RAM.
|
protected Image |
getInternal()
Returns the actual image represented by the encoded image, this image will
be cached in a weak/soft reference internally.
|
boolean |
isAnimation()
Returns true if this is an animated image
|
asyncLock, create, create, create, create, create, createFromImage, createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight, getImage, getWidth, isLocked, isOpaque, lock, modifyAlpha, modifyAlpha, resetCache, rotate, scale, scaled, scaledEncoded, scaledHeight, scaledSmallerRatio, scaledWidth, subImage, toRGB, unlock
applyMask, applyMask, applyMaskAutoScale, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, dispose, flipHorizontally, flipVertically, getImageName, getRGB, getRGBCached, getSVGDocument, isAlphaMutableImageSupported, isSVG, isSVGSupported, mirror, modifyAlphaWithTranslucency, rotate180Degrees, rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName
public static final URLImage.ImageAdapter RESIZE_FAIL
public static final URLImage.ImageAdapter RESIZE_SCALE
public static final URLImage.ImageAdapter RESIZE_SCALE_TO_FILL
public void fetch()
protected Image getInternal()
EncodedImage
getInternal
in class EncodedImage
public byte[] getImageData()
EncodedImage
getImageData
in class EncodedImage
public boolean isAnimation()
Image
isAnimation
in class EncodedImage
public static URLImage createToStorage(EncodedImage placeholder, String storageFile, String url, URLImage.ImageAdapter adapter)
placeholder
- the image placeholder is shown as the image is loading/downloading
and serves as the guideline to the size of the downloaded image.storageFile
- the file in storage to which the image will be storedurl
- the url from which the image is fetchedadapter
- the adapter used to adapt the image into place, it should scale the image
if necessarypublic static URLImage createToFileSystem(EncodedImage placeholder, String file, String url, URLImage.ImageAdapter adapter)
placeholder
- the image placeholder is shown as the image is loading/downloading
and serves as the guideline to the size of the downloaded image.file
- the file in the file system to which the image will be storedurl
- the url from which the image is fetchedadapter
- the adapter used to adapt the image into place, it should scale the image
if necessary