|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.robokind.api.common.playable.AbstractPlayable
public abstract class AbstractPlayable
A basic implementation of Playable. Useful as a base class.
| Field Summary | |
|---|---|
protected Long |
myElapsedPauseTime
The total elapsed time while paused. |
protected Long |
myPauseTime
The time given when last being paused. |
protected List<PlayableListener> |
myPlayableListeners
Listeners for PlayState changes |
protected PlayState |
myPlayState
The current PlayState. |
protected Long |
myResumeTime
The time given when last being resumed. |
protected Long |
myStartTime
The time given when starting. |
protected Long |
myStopTime
The time given when last being stopped. |
| Constructor Summary | |
|---|---|
AbstractPlayable()
Creates a new Playable in a pending state. |
|
| Method Summary | |
|---|---|
void |
addPlayableListener(PlayableListener listener)
Adds a PlayableListener to be notified when the PlayState changes. |
protected void |
afterComplete(long time)
Called after the Playable is marked Completed. |
boolean |
complete(long time)
Stops the Playable, marking it complete. |
protected void |
firePlayStateChanged(PlayState prev,
PlayState state,
long time)
Notifies listeners of a change in PlayState. |
Long |
getElapsedPauseTime(long time)
Returns the elapsed time between the last pause time and the given time. |
Long |
getElapsedPlayTime(long time)
Returns the elapsed time between the start time and the given time. |
Long |
getPauseTime()
Returns the time given when the Playable was last paused. |
PlayState |
getPlayState()
Return the current PlayState of the Playable. |
Long |
getResumeTime()
Returns the time given when the Playable was last resumed. |
Long |
getStartTime()
Returns the time given when the Playable was started. |
Long |
getStopTime()
Returns the time given when the Playable was last stopped. |
protected abstract boolean |
onComplete(long time)
Called when the Playable is completed |
protected abstract boolean |
onPause(long time)
Called when the Playable is paused |
protected abstract boolean |
onResume(long time)
Called when the Playable is resumed |
protected abstract boolean |
onStart(long time)
Called when the Playable is started. |
protected abstract boolean |
onStop(long time)
Called when the Playable is stopped |
boolean |
pause(long time)
Pauses the Playable in its current state. |
void |
removePlayableListener(PlayableListener listener)
Removes a PlayableListener from being notified |
boolean |
resume(long time)
Resumes a paused Playable. |
boolean |
start(long time)
Starts the Playable from its initial state. |
boolean |
stop(long time)
Stops a Playable, returning to the initial state. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected PlayState myPlayState
protected Long myStartTime
protected Long myPauseTime
protected Long myResumeTime
protected Long myStopTime
protected List<PlayableListener> myPlayableListeners
protected Long myElapsedPauseTime
| Constructor Detail |
|---|
public AbstractPlayable()
| Method Detail |
|---|
public void addPlayableListener(PlayableListener listener)
Playable
addPlayableListener in interface Playablelistener - PlayableListener to be addedpublic void removePlayableListener(PlayableListener listener)
Playable
removePlayableListener in interface Playablelistener - PlayableListener to removepublic PlayState getPlayState()
Playable
getPlayState in interface Playableprotected abstract boolean onStart(long time)
time - time the Playable is started, usually current system time UTC
protected abstract boolean onPause(long time)
time - time the Playable is paused, usually current system time UTC
protected abstract boolean onResume(long time)
time - time the Playable is resumed, usually current system time UTC
protected abstract boolean onStop(long time)
time - time the Playable is stopped, usually current system time UTC
protected abstract boolean onComplete(long time)
time - time the Playable is completed, usually current system time
UTC
public boolean start(long time)
Playable
start in interface Playabletime - when the Playable is started (used to synchronize actions)
the time is usually the current system time UTC.
public boolean pause(long time)
Playable
pause in interface Playabletime - when the Playable is paused (used to synchronize actions)
public boolean complete(long time)
Playable
complete in interface Playabletime - when the Playable is complete (used to synchronize actions)
protected void afterComplete(long time)
time - time of completionpublic boolean resume(long time)
Playable
resume in interface Playabletime - when the Playable is resumed (used to synchronize actions)
public boolean stop(long time)
Playable
stop in interface Playabletime - when the Playable is stopped (used to synchronize actions)
public Long getStartTime()
Playable
getStartTime in interface Playablepublic Long getPauseTime()
Playable
getPauseTime in interface Playablepublic Long getResumeTime()
Playable
getResumeTime in interface Playablepublic Long getStopTime()
Playable
getStopTime in interface Playablepublic Long getElapsedPlayTime(long time)
Playable
getElapsedPlayTime in interface Playabletime - the time to check
public Long getElapsedPauseTime(long time)
Playable
getElapsedPauseTime in interface Playabletime - the time to check
protected void firePlayStateChanged(PlayState prev,
PlayState state,
long time)
prev - previous PlayStatestate - new PlayStatetime - PlayState change time
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||