org.apache.pivot.wtk.effects
Class Transition

java.lang.Object
  extended by org.apache.pivot.wtk.effects.Transition
Direct Known Subclasses:
CardPaneSkin.SelectionChangeTransition, FadeTransition, TerraAccordionSkin.SelectionChangeTransition, TerraExpanderSkin.ExpandTransition, TerraRollupSkin.ExpandTransition, TerraSheetSkin.OpenTransition, TerraTabPaneSkin.SelectionChangeTransition

public abstract class Transition
extends Object

Abstract base class for "transitions", which are animated application effects.


Constructor Summary
Transition(int duration, int rate)
          Creates a new non-repeating transition with the given duration, rate.
Transition(int duration, int rate, boolean repeating)
          Creates a new transition with the given duration, rate, and repeat.
Transition(int duration, int rate, boolean repeating, boolean reversed)
          Creates a new transition with the given duration, rate, and repeat.
 
Method Summary
 void end()
          "Fast-forwards" to the end of the transition and fires a TransitionListener.transitionCompleted(Transition) event.
 long getCurrentTime()
          Returns the last time the transition was updated.
 int getDuration()
          Returns the transition duration.
 int getElapsedTime()
          Returns the elapsed time since the transition started.
 int getInterval()
          Returns the transition interval, the number of milliseconds between updates.
 float getPercentComplete()
          Returns the percentage of the transition that has completed.
 int getRate()
          Returns the transition rate.
 long getStartTime()
          Returns the time at which the transition was started.
 boolean isRepeating()
           
 boolean isReversed()
          Tests whether the transition is reversed.
 boolean isRunning()
          Tells whether or not the transition is currently running.
 void reverse()
          Reverses the transition.
 void setDuration(int duration)
          Sets the transition duration, the length of time the transition is scheduled to run.
 void setRate(int rate)
          Sets the transition rate, the number of times the transition will be updated within the span of one second.
 void setReversed(boolean reversed)
          Sets the transition's reversed flag.
 void start()
          Starts the transition with no listener.
 void start(TransitionListener transitionListenerArgument)
          Starts the transition.
 void stop()
          Stops the transition.
protected abstract  void update()
          Called repeatedly while the transition is running to update the transition's state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transition

public Transition(int duration,
                  int rate)
Creates a new non-repeating transition with the given duration, rate.

Parameters:
duration - Transition duration, in milliseconds.
rate - Transition rate, in frames per second.

Transition

public Transition(int duration,
                  int rate,
                  boolean repeating)
Creates a new transition with the given duration, rate, and repeat.

Parameters:
duration - Transition duration, in milliseconds.
rate - Transition rate, in frames per second.
repeating - true if the transition should repeat; false, otherwise.

Transition

public Transition(int duration,
                  int rate,
                  boolean repeating,
                  boolean reversed)
Creates a new transition with the given duration, rate, and repeat.

Parameters:
duration - Transition duration, in milliseconds.
rate - Transition rate, in frames per second.
repeating - true if the transition should repeat; false, otherwise.
reversed - true if the transition should run in reverse; false otherwise.
Method Detail

getDuration

public int getDuration()
Returns the transition duration.

Returns:
The duration of the transition, in milliseconds.
See Also:
setDuration(int)

setDuration

public void setDuration(int duration)
Sets the transition duration, the length of time the transition is scheduled to run.

Parameters:
duration - The duration of the transition, in milliseconds.

getRate

public int getRate()
Returns the transition rate.

Returns:
The rate of the transition, in frames per second.
See Also:
setRate(int)

setRate

public void setRate(int rate)
Sets the transition rate, the number of times the transition will be updated within the span of one second.

Parameters:
rate - The transition rate, in frames per second.

getInterval

public int getInterval()
Returns the transition interval, the number of milliseconds between updates.

Returns:
The transition interval, in milliseconds.

getStartTime

public long getStartTime()
Returns the time at which the transition was started.

Returns:
The transition's start time.

getCurrentTime

public long getCurrentTime()
Returns the last time the transition was updated.

Returns:
The most recent update time.

getElapsedTime

public int getElapsedTime()
Returns the elapsed time since the transition started.

Returns:
Returns the amount of time that has passed since the transition was started. If the transition is reversed, this value reflects the amount of time remaining.

getPercentComplete

public float getPercentComplete()
Returns the percentage of the transition that has completed.

Returns:
A value between 0 and 1, inclusive, representing the transition's percent complete. If the transition is reversed, this value reflects the percent remaining.

isRunning

public boolean isRunning()
Tells whether or not the transition is currently running.

Returns:
true if the transition is currently running; false if it is not

start

public final void start()
Starts the transition with no listener.

See Also:
start(TransitionListener)

start

public void start(TransitionListener transitionListenerArgument)
Starts the transition. Calls update() to establish the initial state and starts a timer that will repeatedly call update() at the current rate. The specified TransitionListener will be notified when the transition completes.

Parameters:
transitionListenerArgument - The listener to get notified when the transition completes, or null if no notification is necessary

stop

public void stop()
Stops the transition. Does not fire a TransitionListener.transitionCompleted(Transition) event.


end

public void end()
"Fast-forwards" to the end of the transition and fires a TransitionListener.transitionCompleted(Transition) event.


update

protected abstract void update()
Called repeatedly while the transition is running to update the transition's state.


isRepeating

public boolean isRepeating()

isReversed

public boolean isReversed()
Tests whether the transition is reversed.

Returns:
true if the transition is reversed; false, otherwise.

setReversed

public void setReversed(boolean reversed)
Sets the transition's reversed flag.

Parameters:
reversed -

reverse

public void reverse()
Reverses the transition. If the transition is running, updates the start time so the reverse duration is the same as the current elapsed time.