Class ReplaceableImage
java.lang.Object
com.codename1.ui.Image
com.codename1.ui.EncodedImage
com.codename1.components.ReplaceableImage
- All Implemented Interfaces:
ActionSource
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).
-
Method Summary
Modifier and TypeMethodDescriptionbooleananimate()static ReplaceableImagecreate(EncodedImage placeholder) Creates an encoded image that can later be replaced with a different imagebyte[]Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.booleanReturns true if this is an animated imagebooleanisOpaque()Indicates whether this image is opaque or notvoidreplace(EncodedImage newImage) Replaces the current image with the new image which must match the dimensions etc.Methods inherited from class EncodedImage
asyncLock, create, create, create, create, create, createFromImage, createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight, getImage, getInternal, getWidth, isLocked, lock, modifyAlpha, modifyAlpha, resetCache, rotate, scale, scaled, scaledEncoded, scaledHeight, scaledSmallerRatio, scaledWidth, subImage, toRGB, unlockMethods inherited from class Image
addActionListener, applyMask, applyMask, applyMaskAutoScale, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, dispose, exifRotation, exifRotation, exifRotation, fill, fireChangedEvent, flipHorizontally, flipVertically, getExifOrientationTag, getExifOrientationTag, getImageName, getRGB, getRGB, getRGBCached, getSVGDocument, isAlphaMutableImageSupported, isJPEG, isPNG, isSVG, isSVGSupported, mirror, modifyAlphaWithTranslucency, removeActionListener, requiresDrawImage, rotate180Degrees, rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName
-
Method Details
-
create
Creates an encoded image that can later be replaced with a different image
Parameters
placeholder: 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.
- Overrides:
getImageDatain classEncodedImage
-
replace
Replaces the current image with the new image which must match the dimensions etc. of the previous image.
Parameters
newImage: the image to apply
-
animate
-
isAnimation
public boolean isAnimation()Returns true if this is an animated image
Returns
true if this image represents an animation
- Overrides:
isAnimationin classEncodedImage
-
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
- Overrides:
isOpaquein classEncodedImage
-