AnimatedImage
Class AnimatedImage

java.lang.Object
  |
  +--AnimatedImage.AnimatedImage

public class AnimatedImage
extends Object

This class provide a method to animate images with memory image source. We can manipulate the animated image with an array of pixels.

Version:
1.0
Author:
Sebastien Baehni

Field Summary
protected  int height
          This represents the height of the memory image source
protected  Image image
          This represents the image of our memory image source.
protected  MemoryImageSource memoryImageSource
          This represents our memory image source.
protected  int[] pixels
          This represents the pixels of the memory image source.
protected  int width
          This represents the width of the memory image source
 
Constructor Summary
AnimatedImage(int width, int height, Color backgroundColor)
          The constructor.
 
Method Summary
 int height()
          Method which return the height of the animatedImage.
 Image image()
          Method which returns the image created via the animatedImage.
 void init(Color color)
          This method initialize our animatedImage with the white color.
 int[] pixels()
          Method which return the array of pixels of our animatedImage.
 void pixels(int index, int value)
          Method which replace one pixel of the animatedImage'pixels array with the indicated value.
 void updateAnimatedImage()
          Method which send the whole buffer of pixels to the memory image source in order to update it and to do the animation.
 void updateAnimatedImage(int xOrigin, int yOrigin, int width, int height)
          Method which tells the memory image source to update only one part of his buffer.
 int width()
          Method which return the width of the animatedImage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

image

protected Image image
This represents the image of our memory image source.

memoryImageSource

protected MemoryImageSource memoryImageSource
This represents our memory image source.

pixels

protected int[] pixels
This represents the pixels of the memory image source.

width

protected int width
This represents the width of the memory image source

height

protected int height
This represents the height of the memory image source
Constructor Detail

AnimatedImage

public AnimatedImage(int width,
                     int height,
                     Color backgroundColor)
The constructor. It creates an animatedImage with only the width, the height and the background color.
Parameters:
width - The width of our animatedImage.
height - The height of our animatedImage.
backgroundColor - The background color of our animatedImage.
Method Detail

init

public void init(Color color)
This method initialize our animatedImage with the white color.

updateAnimatedImage

public void updateAnimatedImage()
Method which send the whole buffer of pixels to the memory image source in order to update it and to do the animation.

updateAnimatedImage

public void updateAnimatedImage(int xOrigin,
                                int yOrigin,
                                int width,
                                int height)
Method which tells the memory image source to update only one part of his buffer.
Parameters:
xOrigin - The x origin of the buffer.
yOrigin - The y origin of the buffer.
width - The width of the buffer.
height - The height of the buffer.

image

public Image image()
Method which returns the image created via the animatedImage.
Returns:
The image created via the animatedImage.

pixels

public int[] pixels()
Method which return the array of pixels of our animatedImage.
Returns:
The array of pixels of the animatedImage.

pixels

public void pixels(int index,
                   int value)
            throws AnimatedImageError
Method which replace one pixel of the animatedImage'pixels array with the indicated value.
Parameters:
index - The pixel we want to change.
value - The new value of the pixel.
Throws:
AnimatedImageError -  

width

public int width()
Method which return the width of the animatedImage.
Returns:
The width of the animatedImage.

height

public int height()
Method which return the height of the animatedImage.
Returns:
The height of the animatedImage.