Class Timeline
- All Implemented Interfaces:
Animation, ActionSource, Painter
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an animation object to show using this timelinebooleananimate()static TimelinecreateTimeline(int duration, AnimationObject[] animations, Dimension size) Create a new timeline animationprotected voidCallback invoked internally by Codename One to draw the image/frame onto the display.protected voidCallback invoked internally by Codename One to draw the image/frame onto the display.getAnimation(int i) Returns the animation object in the given offsetgetAnimationAt(int x, int y) Returns the animation object at the given X/Y coordinate in the timeline for the current frame.intReturns the number of animation objects in this timelineintInidicates the minimal delay between animation frames allowing the CPU to rest.intReturns the duration of the entire timeline in millisecondsintReturns the height of the imageint[]getRGB()Returns the content of this image as a newly created ARGB array.int[]Returns the content of this image as a newly created ARGB array or a cached instance if possible.getSize()Returns the pixel based unscaled dimentions of this timelineintgetTime()Returns the time of the timelineintgetWidth()Returns the width of the imagebooleanReturns true if this is an animated imagebooleanisLoop()Indicates if the image should loopbooleanisPause()Returns true when the timeline is pausedvoidlock()This callback indicates that a component pointing at this image is initialized, this allows an image to make performance sensitive considerations e.g.voidDraws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.voidDraws inside the given rectangle clipping area.booleanNew label optimizations don't invoke drawImage and instead just pass the native image directly to the underlying renderer.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.voidsetAnimationDelay(int animationDelay) Inidicates the minimal delay between animation frames allowing the CPU to rest.voidsetLoop(boolean loop) Indicates if the image should loopvoidsetPause(boolean pause) Indicate that the application is pausedvoidsetTime(int time) Set the time of the timelinevoidunlock()This callback indicates that a component pointing at this image is now deinitilized This method may be invoked multiple times.Methods inherited from class Image
addActionListener, applyMask, applyMask, applyMaskAutoScale, asyncLock, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, dispose, exifRotation, exifRotation, exifRotation, fill, fireChangedEvent, flipHorizontally, flipVertically, getExifOrientationTag, getExifOrientationTag, getGraphics, getImage, getImageName, getRGB, getSVGDocument, isAlphaMutableImageSupported, isJPEG, isLocked, isOpaque, isPNG, isSVG, isSVGSupported, mirror, modifyAlpha, modifyAlpha, modifyAlphaWithTranslucency, removeActionListener, rotate, rotate180Degrees, rotate270Degrees, rotate90Degrees, scale, scaledHeight, scaledLargerRatio, scaledSmallerRatio, scaledWidth, setImageName, subImage, toRGB
-
Method Details
-
createTimeline
Create a new timeline animation
Parameters
-
duration: the duration of the animation in milliseconds -
animations: the animation objects that are part of this timeline -
size: @param size size of the animation in virtual pixels, if the size differs the animation would be scaled on the fly
Returns
the new timeline instance
-
-
lock
-
unlock
-
getRGB
-
getRGBCached
public int[] getRGBCached()Returns the content of this image as a newly created ARGB array or a cached instance if possible. Note that cached instances may be garbage collected.
Returns
array instance containing the ARGB data within this image
- Overrides:
getRGBCachedin classImage
-
addAnimation
Adds an animation object to show using this timeline
Parameters
o: animation object featured in this timeline
-
getTime
public int getTime()Returns the time of the timeline
Returns
the time of the timeline in ms starting from 0
-
setTime
public void setTime(int time) Set the time of the timeline
Parameters
time: the time of the timeline in ms starting from 0
-
isAnimation
public boolean isAnimation()Returns true if this is an animated image
Returns
true if this image represents an animation
- Overrides:
isAnimationin classImage
-
animate
-
paint
-
paint
-
getAnimationDelay
public int getAnimationDelay()Inidicates the minimal delay between animation frames allowing the CPU to rest. Increase this number to increase general device performance, decrease it to speed the animation.
Returns
the animationDelay
-
setAnimationDelay
public void setAnimationDelay(int animationDelay) Inidicates the minimal delay between animation frames allowing the CPU to rest. Increase this number to increase general device performance, decrease it to speed the animation.
Parameters
animationDelay: the animationDelay to set
-
drawImage
Callback invoked internally by Codename One to draw the image/frame onto the display. Image subclasses can override this method to perform drawing of custom image types.
Parameters
-
g: the graphics object -
nativeGraphics: the underlying native graphics which might be essential for some image types -
x: the x coordinate -
y: the y coordinate
-
-
drawImage
Callback invoked internally by Codename One to draw the image/frame onto the display. Image subclasses can override this method to perform drawing of custom image types.
Parameters
-
g: the graphics object -
nativeGraphics: the underlying native graphics which might be essential for some image types -
x: the x coordinate -
y: the y coordinate -
w: the width to occupy -
h: the height to occupy
-
-
getWidth
-
getHeight
-
scaled
Returns a scaled version of this image image using the given width and height, this is a fast algorithm that preserves translucent information. The method accepts -1 to preserve aspect ratio in the given axis.
Parameters
-
width: width for the scaling -
height: height of the scaled image
Returns
new image instance scaled to the given height and width
-
-
isPause
public boolean isPause()Returns true when the timeline is paused
Returns
the pause state
-
setPause
public void setPause(boolean pause) Indicate that the application is paused
Parameters
pause: true to pause the application
-
getDuration
public int getDuration()Returns the duration of the entire timeline in milliseconds
Returns
the duration
-
getSize
Returns the pixel based unscaled dimentions of this timeline
Returns
the size
-
getAnimationCount
public int getAnimationCount()Returns the number of animation objects in this timeline
Returns
the number of animations
-
getAnimation
Returns the animation object in the given offset
Parameters
i: the offset of the animation
Returns
the animation object
-
getAnimationAt
Returns the animation object at the given X/Y coordinate in the timeline for the current frame. This allows functionality such as responding to pointer events on the resource editor. Notice that this method is not efficient since it tests the pixel opacity which is a pretty expensive operation...
Parameters
-
x: the x location in the timeline -
y: the y location in the timeline
Returns
an animation object or null if no animation object is at that position.
-
-
isLoop
public boolean isLoop()Indicates if the image should loop
Returns
the loop
-
setLoop
public void setLoop(boolean loop) Indicates if the image should loop
Parameters
loop: the loop to set
-
requiresDrawImage
public boolean requiresDrawImage()New label optimizations don't invoke drawImage and instead just pass the native image directly to the underlying renderer. This is problematic for some image types specifically timeline & FontImage and this method allows these classes to indicate that they need that legacy behavior of calling drawImage.
Returns
true if a drawImage call is a required
- Overrides:
requiresDrawImagein classImage
-