Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit
Class StaticAnimation

java.lang.Object
  extended by com.sun.dtv.lwuit.Image
      extended by com.sun.dtv.lwuit.StaticAnimation
All Implemented Interfaces:
Animation, Animated

public class StaticAnimation
extends Image
implements Animation, Animated

An Image capable of animation.


Field Summary
 
Fields inherited from interface com.sun.dtv.ui.Animated
ALTERNATING, LOOP, REPEATING
 
Method Summary
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
static StaticAnimation createAnimation(DataInputStream data)
          Creates an animation from the given stream, this method is used internally by Resources normally you should not create static animations manually.
 int getAnimationMode()
          Obtains the animation mode for this animation.
 int getDelay()
          Obtains the delay after every image for this animation when running.
 int getFrameCount()
          Returns the number of frames in the animation including the initial frame.
 int getFrameTime(int frame)
          The time in which the given frame should appear.
 int getPosition()
          Obtains the current position the animation is at the point of time of th method call.
 int getRepetitionMode()
          Returns the repetition mode of this animation in form of a number.
 int getTotalAnimationTime()
          Returns the duration for the entire animation used to determine when to loop.
 boolean isAnimation()
          Returns true if this is an animated image.
 boolean isLoop()
          Indicates whether the animation will run in a loop or run only once.
 boolean isRunning()
          Obtains the running mode of an animation.
 void jumpTo(int position)
          Forces an animation to jump to the position indicated by the parameter.
 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 restart()
          Restarts the animation.
 Image scaled(int width, int height)
          Returns a scaled version of this image using the given width and height, this is a fast algorithm that preserves translucent information.
 void setAnimationMode(int mode)
          Sets the animation mode for this animation.
 void setDelay(int n)
          Determines the delay after every image when running this animation.
 void setLoop(boolean loop)
          Indicates whether the animation will run in a loop or run only once.
 void setRepetitionMode(int n)
          Determines how often the animation is repeated once it has been started.
 void start()
          Starts an animation.
 void stop()
          Stops an animation.
 
Methods inherited from class com.sun.dtv.lwuit.Image
createImage, createImage, createImage, createImage, createImage, createImage, getAWTImage, getGraphics, getHeight, getRGB, getWidth, isOpaque, modifyAlpha, modifyAlpha, rotate, scaledHeight, scaledSmallerRatio, scaledWidth, subImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFrameCount

public int getFrameCount()
Returns the number of frames in the animation including the initial frame.

Returns:
the frame count

getFrameTime

public int getFrameTime(int frame)
The time in which the given frame should appear.

Parameters:
frame - must be a number bigger than -1 and smaller than getFrameCount()
Returns:
the time in milliseconds for the frame to appear

getTotalAnimationTime

public int getTotalAnimationTime()
Returns the duration for the entire animation used to determine when to loop.

Returns:
total animation time in milliseconds

createAnimation

public static StaticAnimation createAnimation(DataInputStream data)
                                       throws IOException
Creates an animation from the given stream, this method is used internally by Resources normally you should not create static animations manually.

Parameters:
data - input stream from which the animation is loaded
Returns:
An instance of a static animation
Throws:
IOException - if stream cannot be opened

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.

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

restart

public void restart()
Restarts the animation.


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

isLoop

public boolean isLoop()
Indicates whether the animation will run in a loop or run only once.

Returns:
true if animation runs in loop, false otherwise

setLoop

public void setLoop(boolean loop)
Indicates whether the animation will run in a loop or run only once.

Parameters:
loop - indicates whether animation should run in loop or not

scaled

public Image scaled(int width,
                    int height)
Returns a scaled version of this image using the given width and height, this is a fast algorithm that preserves translucent information.

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

isAnimation

public boolean isAnimation()
Returns true if this is an animated image.

Overrides:
isAnimation in class Image
Returns:
true if image is animation

start

public void start()
Starts an animation. Please consider that an animation is in the stopped mode per default, so it has to be started explicitly once it has been created. In case the animation is already running, a call to start() causes a restart of the animation.

Specified by:
start in interface Animated

stop

public void stop()
Stops an animation. In case the animation is already stopped, the call to stop() has no effect.

Specified by:
stop in interface Animated

isRunning

public boolean isRunning()
Obtains the running mode of an animation. Returns true if the animation is running, false otherwise.

Specified by:
isRunning in interface Animated
Returns:
true if the animation is running, false otherwise

jumpTo

public void jumpTo(int position)
Forces an animation to jump to the position indicated by the parameter. An animation can be considered as a row of images, the parameter of this method provides the index within this row. If the animation is stopped, a call to this method causes the animation to show the image at the indicated position, but not to start. If the animation is running, a call to this method causes the animation to jump to the image at the indicated position and continue running immediately.

Specified by:
jumpTo in interface Animated
Parameters:
position - the index in the row of images building the animation to which the animation is forced to jump

getPosition

public int getPosition()
Obtains the current position the animation is at the point of time of th method call. An animation can be considered as a row of images, this method provides the index within this row.

Specified by:
getPosition in interface Animated
Returns:
the current position of the image within the row of images building this animation

setRepetitionMode

public void setRepetitionMode(int n)
Determines how often the animation is repeated once it has been started.

Specified by:
setRepetitionMode in interface Animated
Parameters:
n - number of repetitions to be determined. This can be any number larger than zero or LOOP alternatively. LOOP means that the animation runs in an endless loop until the stop() method has been called.
See Also:
getRepetitionMode()

getRepetitionMode

public int getRepetitionMode()
Returns the repetition mode of this animation in form of a number. The number reads how many repetitions have been determined for this animation.

Specified by:
getRepetitionMode in interface Animated
Returns:
number of repetitions determined for this animation or LOOP which means the animation runs in an endless loop until the stop() method has been called.
See Also:
setRepetitionMode(int)

setDelay

public void setDelay(int n)
Determines the delay after every image when running this animation.

Specified by:
setDelay in interface Animated
Parameters:
n - delay in milliseconds
See Also:
getDelay()

getDelay

public int getDelay()
Obtains the delay after every image for this animation when running.

Specified by:
getDelay in interface Animated
Returns:
the delay in milliseconds
See Also:
setDelay(int)

setAnimationMode

public void setAnimationMode(int mode)
Sets the animation mode for this animation. The animation mode determines how the animation is running: always forwards, or forwards and backwards alternating.

Specified by:
setAnimationMode in interface Animated
Parameters:
mode - the animation mode. Possible values are: REPEATING and ALTERNATING.
See Also:
getAnimationMode()

getAnimationMode

public int getAnimationMode()
Obtains the animation mode for this animation. The animation mode determines how the animation is running: always forwards, or forwards and backwards alternating.

Specified by:
getAnimationMode in interface Animated
Returns:
the animation mode. Possible values are: REPEATING and ALTERNATING.
See Also:
setAnimationMode(int)

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.