com.jappit.imagefx
Class AnimatedImage

java.lang.Object
  extended by com.jappit.imagefx.AnimatedImage

public class AnimatedImage
extends java.lang.Object

AnimatedImage is the base class for representing animated images. Its usage is very similar to Image class, so few modifications are needed to switch from an Image to an AnimatedImage within a Java ME application. To create an AnimatedImage instance, it's sufficient to pass to its constructor an Image reference:


 Image baseImage = Image.createImage(...); //create an Image the standard way
 
 AnimatedImage animatedImage = new AnimatedImage(baseImage);
 
To animate the image, it's sufficient to pass an ImageFx instance to its setFx method:

 ImageFx fx = ... //create an ImageFx
 
 animatedImage.setFx(fx);
 
Painting it is very similar to Graphics drawImage() method:

 animatedImage.paint(g, 10, 10, Graphics.TOP | Graphics.LEFT);
 

Version:
0.1
Author:
Alessandro La Rosa

Constructor Summary
AnimatedImage(javax.microedition.lcdui.Image image)
          Creates an animated Image
AnimatedImage(javax.microedition.lcdui.Image image, ImageFx fx)
          Creates an animated Image with the specified FX
 
Method Summary
 boolean isEnded()
          Checks if FX is ended
 void paint(javax.microedition.lcdui.Graphics g, int x, int y, int constraints)
          Draws the AnimatedImage applying the current FX
 void setFx(ImageFx fx)
          Sets the FX
 void start(long duration)
          Starts the FX animation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimatedImage

public AnimatedImage(javax.microedition.lcdui.Image image)
Creates an animated Image

Parameters:
image - the Image object to be animated

AnimatedImage

public AnimatedImage(javax.microedition.lcdui.Image image,
                     ImageFx fx)
Creates an animated Image with the specified FX

Parameters:
image - the Image object to be animated
fx - an FX to be applied to the Image
Method Detail

setFx

public void setFx(ImageFx fx)
Sets the FX

Parameters:
fx - the FX to be applied to the Image

start

public void start(long duration)
Starts the FX animation

Parameters:
duration - the FX duration in milliseconds

isEnded

public boolean isEnded()
Checks if FX is ended

Returns:
true if FX is ended, false otherwise

paint

public void paint(javax.microedition.lcdui.Graphics g,
                  int x,
                  int y,
                  int constraints)
Draws the AnimatedImage applying the current FX

Parameters:
g - the Graphics object to be used for rendering the AnimatedImage
x - the x coordinate of the anchor point
y - the y coordinate of the anchor point
constraints - the anchor point for positioning the image