pivot.wtk.effects
Class Transition

java.lang.Object
  extended by pivot.wtk.effects.Transition
Direct Known Subclasses:
CardPaneSkin.SelectionChangeTransition, FadeTransition, FlipTransition, SlideTransition, TerraAccordionSkin.SelectionChangeTransition, TerraExpanderSkin.ExpandTransition, TerraTabPaneSkin.SelectionChangeTransition

public abstract class Transition
extends Object

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

Author:
gbrown, tvolkert

Field Summary
static int DEFAULT_DURATION
           
static int DEFAULT_RATE
           
 
Constructor Summary
Transition()
          Creates a new, non-repeating transition with the default duration and rate.
Transition(int duration, int rate, boolean repeat)
          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 isRunning()
          Tells whether or not the transition is currently running.
 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 start()
          Starts the transition.
 void start(TransitionListener transitionListener)
          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
 

Field Detail

DEFAULT_DURATION

public static final int DEFAULT_DURATION
See Also:
Constant Field Values

DEFAULT_RATE

public static final int DEFAULT_RATE
See Also:
Constant Field Values
Constructor Detail

Transition

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


Transition

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

Parameters:
duration - Transition duration, in milliseconds.
rate - Transition rate, in frames per second.
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.

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.

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. Calls update() to establish the initial state and starts a timer that will repeatedly call update() at the current rate.


start

public void start(TransitionListener transitionListener)
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:
transitionListener - 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.