Package org.apache.pivot.wtk.effects
Class Transition
- java.lang.Object
-
- 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 java.lang.ObjectAbstract base class for "transitions", which are animated application effects.
-
-
Constructor Summary
Constructors Constructor Description Transition(int durationValue, int rateValue)Creates a new non-repeating transition with the given duration, and rate.Transition(int durationValue, int rateValue, boolean repeat)Creates a new transition with the given duration, rate, and repeat.Transition(int durationValue, int rateValue, boolean repeat, boolean reverse)Creates a new transition with the given duration, rate, and repeat.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidend()"Fast-forward" to the end of the transition, runupdate()the last time, and fire aTransitionListener.transitionCompleted(Transition)event.longgetCurrentTime()Returns the last time the transition was updated.intgetDuration()Returns the transition duration.intgetElapsedTime()Returns the elapsed time since the transition started.intgetInterval()Returns the transition interval, the number of milliseconds between updates.floatgetPercentComplete()Returns the percentage of the transition that has completed.intgetRate()Returns the transition rate.longgetStartTime()Returns the time at which the transition was started.booleanisRepeating()Is the transition a repeating one?booleanisReversed()Tests whether the transition is reversed.booleanisRunning()Tells whether or not the transition is currently running.voidreverse()Reverses the transition.voidsetDuration(int durationValue)Sets the transition duration, the length of time the transition is scheduled to run.voidsetRate(int rateValue)Sets the transition rate, the number of times the transition will be updated within the span of one second.voidsetReversed(boolean reverse)Sets the transition's reversed flag.voidstart()Starts the transition.voidstart(TransitionListener listener)Starts the transition.voidstop()Stops the transition running with no final update, and does not fire aTransitionListener.transitionCompleted(Transition)event.protected booleanthemeHasTransitionEnabled()Tell if the theme has transitions enabled.
Usually this means that (if false) any effect/transition will not be drawn.protected abstract voidupdate()Called repeatedly while the transition is running to update the transition's state.
-
-
-
Constructor Detail
-
Transition
public Transition(int durationValue, int rateValue)Creates a new non-repeating transition with the given duration, and rate.- Parameters:
durationValue- Transition duration, in milliseconds.rateValue- Transition rate, in frames per second.
-
Transition
public Transition(int durationValue, int rateValue, boolean repeat)Creates a new transition with the given duration, rate, and repeat.- Parameters:
durationValue- Transition duration, in milliseconds.rateValue- Transition rate, in frames per second.repeat-trueif the transition should repeat;false, otherwise.
-
Transition
public Transition(int durationValue, int rateValue, boolean repeat, boolean reverse)Creates a new transition with the given duration, rate, and repeat. Note that if the current Theme has transitions not enabled, the duration and rate will both be set to zero, so that the final update is called once, in a minimum amount of time after the start.- Parameters:
durationValue- Transition duration, in milliseconds.rateValue- Transition rate, in frames per second.repeat-trueif the transition should repeat;false, otherwise.reverse-trueif the transition should run in reverse;falseotherwise.
-
-
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 durationValue)
Sets the transition duration, the length of time the transition is scheduled to run.- Parameters:
durationValue- 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 rateValue)
Sets the transition rate, the number of times the transition will be updated within the span of one second.- Parameters:
rateValue- 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, or a default minimum value if transitions have been disabled.
-
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:
- 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 final boolean isRunning()
Tells whether or not the transition is currently running.- Returns:
trueif the transition is currently running;falseif it is not
-
start
public final void start()
Starts the transition. Callsupdate()to establish the initial state and starts a time that will repeatedly callupdate()at the current rate. NoTransitionListenerwill be notified.- See Also:
start(TransitionListener)
-
start
public void start(TransitionListener listener)
Starts the transition. Callsupdate()to establish the initial state and starts a timer that will repeatedly callupdate()at the current rate. The specifiedTransitionListenerwill be notified when the transition completes.- Parameters:
listener- The listener to get notified when the transition completes, ornullif no notification is necessary.
-
stop
public void stop()
Stops the transition running with no final update, and does not fire aTransitionListener.transitionCompleted(Transition)event.
-
end
public void end()
"Fast-forward" to the end of the transition, runupdate()the last time, and fire aTransitionListener.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()
Is the transition a repeating one?- Returns:
trueif the transition should repeat;falseif not.
-
isReversed
public boolean isReversed()
Tests whether the transition is reversed.- Returns:
trueif the transition is reversed;falseotherwise.
-
setReversed
public void setReversed(boolean reverse)
Sets the transition's reversed flag.- Parameters:
reverse- Whether the transition should be 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.
-
themeHasTransitionEnabled
protected boolean themeHasTransitionEnabled()
Tell if the theme has transitions enabled.
Usually this means that (if false) any effect/transition will not be drawn.- Returns:
trueif enabled (default),falseotherwise.- See Also:
Theme.isTransitionEnabled()
-
-