de.enough.polish.ui
Class Transition

java.lang.Object
  extended by de.enough.polish.ui.Transition
All Implemented Interfaces:
Animatable, UiElement
Direct Known Subclasses:
HorizontalTransition, RgbFilterTransition

public abstract class Transition
extends Object
implements UiElement, Animatable

Realizes a graphical transition from something 'old' to something 'new'.

Copyright Enough Software 2008

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
protected  boolean isFinished
           
protected  RgbImage newState
           
protected  RgbImage newStateRgbImage
          RGB image containing RGB data of the new state, this is initialized by the Transition base class when useNewStateRgb is set to true
protected  int newX
           
protected  int newY
           
protected  RgbImage oldState
           
protected  RgbImage oldStateRgbImage
          RGB image containing RGB data of the old state, this is initialized by the Transition base class when useOldStateRgb is set to true
protected  int oldX
           
protected  int oldY
           
protected  UiElement parent
           
protected  Style style
           
protected  boolean useNewStateRgb
          set to true in subclasses for populating newStateRgbImage
protected  boolean useOldStateRgb
          set to true in subclasses for populating oldStateRgbImage
 
Constructor Summary
Transition()
          Creates a new transition
 
Method Summary
 void addRelativeToContentRegion(ClippingRegion repaintRegion, int x, int y, int width, int height)
          Adds a region relative to this item's content x/y start position.
 void addRepaintArea(ClippingRegion repaintArea)
          Adds a repaint request for this user interface component's space.
abstract  boolean animate()
          Animates this transition
 void animate(long currentTime, ClippingRegion repaintRegion)
          Animates this element.
 Style getStyle()
          Retrieves the currently used style
 void initTransition(RgbImage oldStateRgbImage, RgbImage newStateRgbImage, UiElement transitionParent)
          Initializes this transition shortly before it is shown.
 boolean isFinished()
          Determines whether this transition is finished.
abstract  void paint(int x, int y, Graphics g)
          Paints the transition
 void setStyle(Style style)
          Sets the style of this user interface element.
 void setStyle(Style style, boolean resetStyle)
          Sets the style with animatable CSS attributes of this user interface element.
abstract  void start(boolean isForward)
           
abstract  void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

oldState

protected RgbImage oldState

newState

protected RgbImage newState

useOldStateRgb

protected boolean useOldStateRgb
set to true in subclasses for populating oldStateRgbImage


oldStateRgbImage

protected RgbImage oldStateRgbImage
RGB image containing RGB data of the old state, this is initialized by the Transition base class when useOldStateRgb is set to true


useNewStateRgb

protected boolean useNewStateRgb
set to true in subclasses for populating newStateRgbImage


newStateRgbImage

protected RgbImage newStateRgbImage
RGB image containing RGB data of the new state, this is initialized by the Transition base class when useNewStateRgb is set to true


oldX

protected int oldX

oldY

protected int oldY

newX

protected int newX

newY

protected int newY

style

protected Style style

parent

protected UiElement parent

isFinished

protected boolean isFinished
Constructor Detail

Transition

public Transition()
Creates a new transition

Method Detail

initTransition

public void initTransition(RgbImage oldStateRgbImage,
                           RgbImage newStateRgbImage,
                           UiElement transitionParent)
Initializes this transition shortly before it is shown.

Parameters:
oldStateRgbImage - the old state of the parent
newStateRgbImage - the new state of the parent
transitionParent - the parent

addRepaintArea

public void addRepaintArea(ClippingRegion repaintArea)
Description copied from interface: UiElement
Adds a repaint request for this user interface component's space.

Specified by:
addRepaintArea in interface UiElement
Parameters:
repaintArea - the clipping rectangle to which the repaint area should be added

addRelativeToContentRegion

public void addRelativeToContentRegion(ClippingRegion repaintRegion,
                                       int x,
                                       int y,
                                       int width,
                                       int height)
Description copied from interface: UiElement
Adds a region relative to this item's content x/y start position.

Specified by:
addRelativeToContentRegion in interface UiElement
Parameters:
repaintRegion - the clipping region
x - horizontal start relative to this item's content position
y - vertical start relative to this item's content position
width - width
height - height

getStyle

public Style getStyle()
Description copied from interface: UiElement
Retrieves the currently used style

Specified by:
getStyle in interface UiElement
Returns:
the style of this UI element

setStyle

public void setStyle(Style style)
Description copied from interface: UiElement
Sets the style of this user interface element. Typically control is forwarded to setStyle( Style, true ).

Specified by:
setStyle in interface UiElement
Parameters:
style - the new style for this element.

setStyle

public void setStyle(Style style,
                     boolean resetStyle)
Description copied from interface: UiElement
Sets the style with animatable CSS attributes of this user interface element.

Specified by:
setStyle in interface UiElement
Parameters:
style - the new style for this element.
resetStyle - true when style settings should be resetted. This is not the case when styles are animated, for example.

paint

public abstract void paint(int x,
                           int y,
                           Graphics g)
Paints the transition

Parameters:
x - horizontal start position
y - vertical start position
g - Graphics context

animate

public abstract boolean animate()
Animates this transition

Returns:
true when the animation continues, false otherwise

start

public abstract void start(boolean isForward)

stop

public abstract void stop()

animate

public void animate(long currentTime,
                    ClippingRegion repaintRegion)
Description copied from interface: Animatable
Animates this element. Subclasses can override this method to create animations. The default implementation animates the background and the item view if present.

Specified by:
animate in interface Animatable
Parameters:
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated
See Also:
Item.addRelativeToContentRegion(ClippingRegion, int, int, int, int)

isFinished

public boolean isFinished()
Determines whether this transition is finished.

Returns:
true when this animation is stopped