com.sun.lwuit.animations
Class Timeline

java.lang.Object
  extended by com.sun.lwuit.Image
      extended by com.sun.lwuit.animations.Timeline
All Implemented Interfaces:
Animation, Painter

public final class Timeline
extends Image
implements Animation, Painter

A timeline represents the motions of animation objects


Method Summary
 void addAnimation(AnimationObject o)
          Adds an animation object to show using this timeline
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
static Timeline createTimeline(int duration, AnimationObject[] animations, Dimension size)
          Create a new timeline animation
protected  void drawImage(Graphics g, java.lang.Object nativeGraphics, int x, int y)
          Callback invoked internally by LWUIT to draw the image/frame onto the display.
 AnimationObject getAnimation(int i)
          Returns the animation object in the given offset
 AnimationObject getAnimationAt(int x, int y)
          Returns the animation object at the given X/Y coordinate in the timeline for the current frame.
 int getAnimationCount()
          Returns the number of animation objects in this timeline
 int getAnimationDelay()
          Inidicates the minimal delay between animation frames allowing the CPU to rest.
 int getDuration()
          Returns the duration of the entire timeline in milliseconds
 int getHeight()
          Returns the height of the image
 int[] getRGB()
          Returns the content of this image as a newly created ARGB array.
 int[] getRGBCached()
          Returns the content of this image as a newly created ARGB array or a cached instance if possible.
 Dimension getSize()
          Returns the pixel based unscaled dimentions of this timeline
 int getTime()
          Returns the time of the timeline
 int getWidth()
          Returns the width of the image
 boolean isAnimation()
          Returns true if this is an animated image
 boolean isLoop()
          Indicates if the image should loop
 boolean isPause()
          Returns true when the timeline is paused
 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.
 void paint(Graphics g)
          Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.
 void paint(Graphics g, Rectangle rect)
          Draws inside the given rectangle clipping area.
 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.
 void setAnimationDelay(int animationDelay)
          Inidicates the minimal delay between animation frames allowing the CPU to rest.
 void setLoop(boolean loop)
          Indicates if the image should loop
 void setPause(boolean pause)
          Indicate that the application is paused
 void setTime(int time)
          Set the time of the timeline
 void unlock()
          This callback indicates that a component pointing at this image is now deinitilized This method may be invoked multiple times.
 
Methods inherited from class com.sun.lwuit.Image
applyMask, applyMask, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, drawImage, getGraphics, getImage, getSVGDocument, isAlphaMutableImageSupported, isOpaque, isSVG, isSVGSupported, modifyAlpha, modifyAlpha, modifyAlphaWithTranslucency, rotate, scale, scaledHeight, scaledSmallerRatio, scaledWidth, subImage, toRGB
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

lock

public void lock()
Description copied from class: Image
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. This method may be invoked multiple times.

Overrides:
lock in class Image

unlock

public void unlock()
Description copied from class: Image
This callback indicates that a component pointing at this image is now deinitilized This method may be invoked multiple times.

Overrides:
unlock in class Image

getRGB

public int[] getRGB()
Description copied from class: Image
Returns the content of this image as a newly created ARGB array.

Overrides:
getRGB in class Image
Returns:
new array instance containing the ARGB data within this image

getRGBCached

public int[] getRGBCached()
Description copied from class: Image
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.

Overrides:
getRGBCached in class Image
Returns:
array instance containing the ARGB data within this image

createTimeline

public static Timeline createTimeline(int duration,
                                      AnimationObject[] animations,
                                      Dimension size)
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 - size of the animation in virtual pixels, if the size differs the animation would be scaled on the fly
Returns:
the new timeline instance

addAnimation

public void addAnimation(AnimationObject o)
Adds an animation object to show using this timeline

Parameters:
o - animation object featured in this timeline

setTime

public void setTime(int time)
Set the time of the timeline

Parameters:
time - the time of the timeline in ms starting from 0

getTime

public int getTime()
Returns the time of the timeline

Returns:
the time of the timeline in ms starting from 0

isAnimation

public boolean isAnimation()
Description copied from class: Image
Returns true if this is an animated image

Overrides:
isAnimation in class Image
Returns:
true if this image represents an animation

animate

public boolean animate()
Description copied from interface: Animation
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the Display class.

Specified by:
animate in interface Animation
Overrides:
animate in class Image
Returns:
true if a repaint is desired or false if no repaint is necessary

paint

public void paint(Graphics g)
Description copied from interface: Animation
Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.

Specified by:
paint in interface Animation
Parameters:
g - graphics context

paint

public void paint(Graphics g,
                  Rectangle rect)
Description copied from interface: Painter
Draws inside the given rectangle clipping area.

Specified by:
paint in interface Painter
Parameters:
g - the Graphics object
rect - the given rectangle cliping area

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

protected void drawImage(Graphics g,
                         java.lang.Object nativeGraphics,
                         int x,
                         int y)
Description copied from class: Image
Callback invoked internally by LWUIT to draw the image/frame onto the display. Image subclasses can override this method to perform drawing of custom image types.

Overrides:
drawImage in class Image
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

getWidth

public int getWidth()
Description copied from class: Image
Returns the width of the image

Overrides:
getWidth in class Image
Returns:
the width of the image

getHeight

public int getHeight()
Description copied from class: Image
Returns the height of the image

Overrides:
getHeight in class Image
Returns:
the height of the image

scaled

public Image scaled(int width,
                    int height)
Description copied from class: Image
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.

Overrides:
scaled in class Image
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

public Dimension 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

public AnimationObject getAnimation(int i)
Returns the animation object in the given offset

Parameters:
i - the offset of the animation
Returns:
the animation object

getAnimationAt

public AnimationObject getAnimationAt(int x,
                                      int y)
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