|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.umd.cs.jazz.animation.ZAnimationScheduler
ZAnimationScheduler schedules the frames of ZAnimations. It uses a timer firing from the event dispatch thread, each time the timer fires it animates one frame from all animations that have been scheduled and are ready to animate at that time.
Normally you will not need to use this class directly, unless you are creating your own custom subclass of ZAnimation. This class is a singleton, only one instance should ever exist at the same time. This instance is accessed through the instance
method.
Constructor Summary | |
protected |
ZAnimationScheduler() Construct a new ZAnimationScheduler. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e) This method is called when the timer fires. |
protected java.util.Iterator |
getAnimationsToProcessForCurrentFrame() Return an iterator for all animations that should be animated for the current frame. |
long |
getCurrentFrame() Return the current frame this the animation scheduler is or will soon be drawing. |
long |
getCurrentTime() Return the current time for the animation scheduler. |
int |
getFrameDelay() Return the delay between each frame that gets animated. |
protected javax.swing.Timer |
getTimer() Return the animation schedulers timer. |
static ZAnimationScheduler |
instance() Return a reference to the singleton animation scheduler. |
boolean |
isAnimationSchedulerRunning() Return true if the animation scheduler's timer is running. |
void |
processAnimations(long aTime) This method first sets the current time (returned by getCurrentTime ) to the aTime parameter. |
void |
scheduleAnimation(ZAnimation aAnimation, ZNextFrameCondition aCondition) Schedule an animation together with its frame condition. |
void |
setFrameDelay(int aDelay) Set the delay between each frame that gets animated. |
void |
setFrameEndedRunnable(java.lang.Runnable aRunnable) Set a runnable that will be run when all the animations for one frame have finished. |
protected void |
startAnimationScheduler() Start the timer that drives this animation scheduler. |
protected void |
stopAnimationScheduler() Start the timer that drives this animation scheduler. |
void |
stopPendingAnimations() Forces all animations that are in the queue's to be stopped. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected ZAnimationScheduler()
instance
should be used instead.
Method Detail |
public static ZAnimationScheduler instance()
public long getCurrentTime()
public long getCurrentFrame()
public int getFrameDelay()
public void setFrameDelay(int aDelay)
public void scheduleAnimation(ZAnimation aAnimation, ZNextFrameCondition aCondition)
public void processAnimations(long aTime)
getCurrentTime
) to the aTime parameter. Next it gets all animations that are ready to animate at that time or for the current frame and animates one frame for each one. Last of all it increments the current frame.
protected java.util.Iterator getAnimationsToProcessForCurrentFrame()
getCurrentFrame
and getCurrentTime
are used to determine if an animation is ready to be animated for the current frame. Since all animations use these common values animates that are scheduled to start at the same time will always start animating in the same frame.
public boolean isAnimationSchedulerRunning()
public void stopPendingAnimations()
protected void startAnimationScheduler()
protected void stopAnimationScheduler()
public void actionPerformed(java.awt.event.ActionEvent e)
processAnimations
with the current time.
actionPerformed
in interface java.awt.event.ActionListener
protected javax.swing.Timer getTimer()
public void setFrameEndedRunnable(java.lang.Runnable aRunnable)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |