com.jappit.imagefx
Class ImageFx

java.lang.Object
  extended by com.jappit.imagefx.ImageFx
Direct Known Subclasses:
BlindsFx, ExplodeFx, PuzzleFx, ShakeFx, SlideFx, SpiralFx, WaveFx, WipeFx

public abstract class ImageFx
extends java.lang.Object

ImageFx is the base class for effects applicable to AnimatedImage instances. Extending subclasses must implement paintFx() method, that have to implement the FX rendering logic. Common properties to all ImageFx subclasses include:

Usage and applicability of each property is different for each subclass, and each of them can define its subset of allowed values. With using the assert methods to check if specified values are allowed for the FX itself.

Fx Type

Fx Type define the type of the FX (where applicable), and valid values are:

Fx Direction

Fx Direction defines the direction of the FX itself (where applicable). Valid values are:

Fx Orientation

Fx Orientation defines the orientation of the FX (where applicable), and valid values are:

Version:
0.1
Author:
Alessandro La Rosa

Field Summary
static int ORIENTATION_HORIZONTAL
          Constant for FXs with horizontal orientation
static int ORIENTATION_NONE
          Constant for FXs with no orientation
static int ORIENTATION_VERTICAL
          Constant for FXs with vertical orientation
static int TYPE_IN
          Constant for inner-going FXs
static int TYPE_NONE
          Constant for FXs with no defined type
static int TYPE_OUT
          Constant for outer-going FXs
 
Constructor Summary
ImageFx()
           
 
Method Summary
protected  void assertFxType(int value)
          Asserts that FX type is equal to specified value
protected  void assertNotFxType(int value)
          Asserts that FX type is not equal to specified value
protected  void assertNotOrientation(int value)
          Asserts that FX orientation is not equal to specified value
protected  void assertOrientation(int value)
          Asserts that FX orientation is equal to specified value
 int getDirection()
          Returns the FX direction
 int getFxType()
          Returns the FX type
 int getOrientation()
          Returns the FX orientation
protected  int getPercentage(long timeDiff)
          Returns the percentage of time passed from FX start
 boolean isEnded()
          Checks if FX is ended
 boolean isLooping()
          Checks if FX is looping
 boolean isRunning()
          Checks if FX is running
 void paint(javax.microedition.lcdui.Graphics g, javax.microedition.lcdui.Image image)
          Draws the given Image, applying the FX
protected abstract  void paintFx(javax.microedition.lcdui.Graphics g, javax.microedition.lcdui.Image image, long timeDiff)
          Renders the given Image applying the FX
 void setDirection(int direction)
          Sets the FX direction
 void setFxType(int fxType)
          Sets the FX type
 void setLooping(boolean looping)
          Define if FX must loop (false by default)
 void setOrientation(int orientation)
          Sets the FX orientation
 void start(long millisecs)
          Starts the FX animation
 void stop()
          Stops the FX animation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_NONE

public static final int TYPE_NONE
Constant for FXs with no defined type

See Also:
Constant Field Values

TYPE_IN

public static final int TYPE_IN
Constant for inner-going FXs

See Also:
Constant Field Values

TYPE_OUT

public static final int TYPE_OUT
Constant for outer-going FXs

See Also:
Constant Field Values

ORIENTATION_NONE

public static final int ORIENTATION_NONE
Constant for FXs with no orientation

See Also:
Constant Field Values

ORIENTATION_VERTICAL

public static final int ORIENTATION_VERTICAL
Constant for FXs with vertical orientation

See Also:
Constant Field Values

ORIENTATION_HORIZONTAL

public static final int ORIENTATION_HORIZONTAL
Constant for FXs with horizontal orientation

See Also:
Constant Field Values
Constructor Detail

ImageFx

public ImageFx()
Method Detail

start

public void start(long millisecs)
Starts the FX animation

Parameters:
millisecs - the FX duration, in milliseconds

setOrientation

public void setOrientation(int orientation)
Sets the FX orientation

Parameters:
orientation - the FX orientation

setFxType

public void setFxType(int fxType)
Sets the FX type

Parameters:
fxType - the FX type

setDirection

public void setDirection(int direction)
Sets the FX direction

Parameters:
direction - the FX direction

assertNotFxType

protected void assertNotFxType(int value)
Asserts that FX type is not equal to specified value

Parameters:
value - the value to be checked

assertFxType

protected void assertFxType(int value)
Asserts that FX type is equal to specified value

Parameters:
value - the value to be checked

assertNotOrientation

protected void assertNotOrientation(int value)
Asserts that FX orientation is not equal to specified value

Parameters:
value - the value to be checked

assertOrientation

protected void assertOrientation(int value)
Asserts that FX orientation is equal to specified value

Parameters:
value - the value to be checked

getOrientation

public int getOrientation()
Returns the FX orientation

Returns:
the FX orientation

getDirection

public int getDirection()
Returns the FX direction

Returns:
the FX direction

getFxType

public int getFxType()
Returns the FX type

Returns:
the FX type

stop

public void stop()
Stops the FX animation


paint

public void paint(javax.microedition.lcdui.Graphics g,
                  javax.microedition.lcdui.Image image)
Draws the given Image, applying the FX

Parameters:
g - the Graphics object to be used for rendering the FX
image - an Image to be drawn

getPercentage

protected int getPercentage(long timeDiff)
Returns the percentage of time passed from FX start

Parameters:
timeDiff - the time passed from FX start
Returns:
the percentage of time passed

isRunning

public boolean isRunning()
Checks if FX is running

Returns:
true if FX is running, false otherwise

isLooping

public boolean isLooping()
Checks if FX is looping

Returns:
true if FX is looping, false otherwise

setLooping

public void setLooping(boolean looping)
Define if FX must loop (false by default)

Parameters:
looping - true if FX must loop, false otherwise

isEnded

public boolean isEnded()
Checks if FX is ended

Returns:
true if FX is ended, false otherwise

paintFx

protected abstract void paintFx(javax.microedition.lcdui.Graphics g,
                                javax.microedition.lcdui.Image image,
                                long timeDiff)
Renders the given Image applying the FX

Parameters:
g - the Graphics object to be used for rendering the FX
image - the Image object to be drawn
timeDiff - the current time difference from FX start