public final class Timeline
ImplementsActionSource, Animation, Painter
Methods
public static Timeline createTimeline(int duration, AnimationObject[] animations, Dimension size) | Create a new timeline animation |
public void lock() | This callback indicates that a component pointing at this image is initialized, this allows an image to make performance sensitive considerations e.g. an encoded image might choose to cache itself in RAM. |
public void unlock() | This callback indicates that a component pointing at this image is now deinitilized This method may be invoked multiple times. |
public int[] getRGB() | Returns the content of this image as a newly created ARGB array. |
public int[] getRGBCached() | Returns the content of this image as a newly created ARGB array or a cached instance if possible. |
public void addAnimation(AnimationObject o) | Adds an animation object to show using this timeline |
public int getTime() | Returns the time of the timeline |
public void setTime(int time) | Set the time of the timeline |
public boolean isAnimation() | Returns true if this is an animated image |
public boolean animate() | Advances this image’s animation state, if it is animated. |
public void paint(Graphics g) | Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature. |
public void paint(Graphics g, Rectangle rect) | Draws inside the given rectangle clipping area. |
public int getAnimationDelay() | Inidicates the minimal delay between animation frames allowing the CPU to rest. |
public void setAnimationDelay(int animationDelay) | Inidicates the minimal delay between animation frames allowing the CPU to rest. |
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y) | Callback invoked internally by Codename One to draw the image/frame onto the display. |
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y, int w, int h) | Callback invoked internally by Codename One to draw the image/frame onto the display. |
public int getWidth() | Returns the width of the image |
public int getHeight() | Returns the height of the image |
public Image scaled(int width, int height) | Returns a scaled version of this image image using the given width and height, this is a fast algorithm that preserves translucent information. |
public boolean isPause() | Returns true when the timeline is paused |
public void setPause(boolean pause) | Indicate that the application is paused |
public int getDuration() | Returns the duration of the entire timeline in milliseconds |
public Dimension getSize() | Returns the pixel based unscaled dimentions of this timeline |
public int getAnimationCount() | Returns the number of animation objects in this timeline |
public AnimationObject getAnimation(int i) | Returns the animation object in the given offset |
public AnimationObject getAnimationAt(int x, int y) | Returns the animation object at the given X/Y coordinate in the timeline for the current frame. |
public boolean isLoop() | Indicates if the image should loop |
public void setLoop(boolean loop) | Indicates if the image should loop |
public boolean requiresDrawImage() | New label optimizations don’t invoke drawImage and instead just pass the native image directly to the underlying renderer. |
Inherited methods
From Image
isSimdOptimizationsEnabled, setSimdOptimizationsEnabled, resetSimdOptimizationsEnabled, isSVGSupported, createSVG, createIndexed, createImage, createImage, createImage, createImage, createImage, isAlphaMutableImageSupported, createImage, createImage, exifRotation, exifRotation, exifRotation, getExifOrientationTag, getExifOrientationTag, isJPEG, isPNG, asyncLock, isLocked, getSVGDocument, isSVG, createMask, applyMask, applyMask, applyMaskAutoScale, subImage, mirror, rotate, modifyAlpha, modifyAlphaWithTranslucency, modifyAlpha, getGraphics, toRGB, getRGB, scaledWidth, scaledHeight, scaledSmallerRatio, scaledLargerRatio, fill, getImage, scale, isOpaque, getImageName, setImageName, dispose, rotate90Degrees, rotate180Degrees, rotate270Degrees, flipHorizontally, flipVertically, addActionListener, removeActionListener, fireChangedEvent
Method details
createTimeline
public static Timeline createTimeline(int duration, AnimationObject[] animations, Dimension size)Parameters
durationint- the duration of the animation in milliseconds
animationsAnimationObject[]- the animation objects that are part of this timeline
sizeDimension- size of the animation in virtual pixels, if the size differs the animation would be scaled on the fly
Returns
lock
public void lock()unlock
public void unlock()getRGB
public int[] getRGB()Returns
getRGBCached
public int[] getRGBCached()Returns
addAnimation
public void addAnimation(AnimationObject o)Parameters
oAnimationObject- animation object featured in this timeline
getTime
public int getTime()Returns
setTime
public void setTime(int time)Parameters
timeint- the time of the timeline in ms starting from 0
isAnimation
public boolean isAnimation()Returns
animate
public boolean animate()Returns
true if the animation state changed.paint
public void paint(Graphics g)Parameters
gGraphics- graphics context
paint
public void paint(Graphics g, Rectangle rect)Parameters
gGraphics- the
Graphicsobject rectRectangle- the given rectangle cliping area
getAnimationDelay
public int getAnimationDelay()Returns
setAnimationDelay
public void setAnimationDelay(int animationDelay)Parameters
animationDelayint- the animationDelay to set
drawImage
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y)Parameters
gGraphics- the graphics object
nativeGraphicsObject- the underlying native graphics which might be essential for some image types
xint- the x coordinate
yint- the y coordinate
drawImage
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y, int w, int h)Parameters
gGraphics- the graphics object
nativeGraphicsObject- the underlying native graphics which might be essential for some image types
xint- the x coordinate
yint- the y coordinate
wint- the width to occupy
hint- the height to occupy
getWidth
public int getWidth()Returns
getHeight
public int getHeight()Returns
scaled
public Image scaled(int width, int height)Parameters
widthint- width for the scaling
heightint- height of the scaled image
Returns
isPause
public boolean isPause()Returns
setPause
public void setPause(boolean pause)Parameters
pauseboolean- true to pause the application
getDuration
public int getDuration()Returns
getSize
public Dimension getSize()Returns
getAnimationCount
public int getAnimationCount()Returns
getAnimation
public AnimationObject getAnimation(int i)Parameters
iint- the offset of the animation
Returns
getAnimationAt
public AnimationObject getAnimationAt(int x, int y)Parameters
xint- the x location in the timeline
yint- the y location in the timeline
Returns
isLoop
public boolean isLoop()Returns
setLoop
public void setLoop(boolean loop)Parameters
loopboolean- the loop to set
requiresDrawImage
public boolean requiresDrawImage()