|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--quicktime.app.time.Timer
This class provides timing services for either a subclass or a target object that implements the Ticklish interface. The Timer invokes the tickle method based on the rate that it is ticking and the scale and period of the timer itself. For instance
The Timer can be in one of three states.
Whenever the condition of the time base's time line changes the Timer notifies its subclass or Ticklish target through invoking the timeChanged method with the new time. The conditions under which this method is invoked are when the time value jumps or the effective rate changes from positive to negative or vice versa.
Whenever the tickle method is invoked the effective rate of the Timer's TimeBase is passes on, as is the time of the tickle method. In both cases this time value is specified in terms of the Ticklish.kScale value. If the timer is ticking (ie. its effective rate is not equal to zero) then the time when a timeChanged notification was sent will also be the time value that the next tickle method will receive.
If the tickle method returns true then the Timer will tickle again when the specified scale and period has elapsed. If the tickle method returns false then the Timer will not tickle again until the Timer's tickling has been reenabled.
It does not guarantee that the tickle method will be called by the specified interval. This is affected by two factors - latencies in Java threads or other activity in the runtime that does not allow the invocation of the timer's tickle, and the amount of time that the the tickle method itself takes to execute. In these cases (ie. the next tickle is late) it will be called at the earliest possible time. For example if you have a tickle interval of 100 msecs and the previous tickle took 150msecs to execute, then the next tickle will be given at the earlies possible return. A consequent tickle to that will be in the interval specified or ASAP if this consequent tickle takes longer than the specified time.
TimeBase
,
Ticklish
,
Timeable
Constructor Summary | |
Timer(int scale,
int period)
Create a Timer. |
|
Timer(int scale,
int period,
Ticklish target)
Create a Timer. |
|
Timer(int scale,
int period,
Ticklish target,
Movie mov)
Create a Timer. |
Method Summary | |
protected void |
finalize()
The finalize method deactivates the timer. |
int |
getPeriod()
Returns the current period (number of scale ticks) of the Timer's tickle notification. |
float |
getRate()
Returns the current rate of this Timer - this is the Timer's TimeBase rate. |
int |
getScale()
Returns the current scale of the Timer's tickle notification. |
Ticklish |
getTicklish()
Returns the current target of the Targetable object - this is the object that the Targetable will act upon. |
TimeBase |
getTimeBase()
Returns the current time base that provides the time foundation of this object. |
boolean |
isActive()
Returns the current active state of the Timer. |
boolean |
isTicking()
Returns true if the Timer's effective rate is currently non-zero |
boolean |
isTickling()
Returns true if the Timer, when active, will tickle or false if the Timer, when active, will not tickle. |
void |
rescheduleTickle(int scale,
int period)
This method will reschedule the Timer's callback mechanism to the new scale and period values. |
void |
setActive(boolean flag)
Sets the active state of the Timer; only an active Timer will tickle. |
void |
setRate(float rate)
Sets the Timeable's playback rate. |
void |
setTickling(boolean flag)
Sets the tickle state of the Timer. |
protected boolean |
tickle(float er,
int time)
When the time from zero (or a timeChanged time value, or the previous tickle time) that is specified by the scale and period of the Timer has elapsed the timer calls the tickle method. |
protected void |
timeChanged(int newTime)
This is called by the Timer itself when the time base of the Timer has changed, through being reset to a new time or through the effective rate of the Timer changing from positive to negative or vice versa |
java.lang.String |
toString()
Return a string representation of this class. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Timer(int scale, int period) throws QTException
scale
- the scale of the timer's tickle invocation periodperiod
- the number of scale size ticks that elapse between each invocation of the tickle methodpublic Timer(int scale, int period, Ticklish target) throws QTException
scale
- the scale of the timer's tickle invocation periodperiod
- the number of scale size ticks that elapse between each invocation of the tickle methodtarget
- the Ticklish target of the Timer - if this is not null then the target's tickle and
timeChanged method will be invoked by the Timer.public Timer(int scale, int period, Ticklish target, Movie mov) throws QTException
scale
- the scale of the timer's tickle invocation periodperiod
- the number of scale size ticks that elapse between each invocation of the tickle methodtarget
- the Ticklish target of the Timer - if this is not null then the target's tickle and
timeChanged method will be invoked by the Timer.mov
- the Movie from which the TimeBase of the timer will be derived.Method Detail |
public boolean isTicking()
public boolean isTickling()
public void setTickling(boolean flag) throws StdQTException
flag
- a booleanpublic Ticklish getTicklish()
public final TimeBase getTimeBase()
getTimeBase
in interface Timeable
public void rescheduleTickle(int scale, int period) throws QTException
scale
- the new scale of the Timer's tickle notificationperiod
- the number of scale ticks that will elapse between notifications.public int getScale()
public int getPeriod()
public float getRate()
getRate
in interface Timeable
public void setRate(float rate)
setRate
in interface Timeable
rate
- the new playback rate.public void setActive(boolean flag) throws QTException
flag
- fi true the Timer is active, if false it is inactivepublic boolean isActive()
public java.lang.String toString()
toString
in class java.lang.Object
protected void timeChanged(int newTime) throws QTException
newTime
- the new time of the Timer's time line expressed in the Ticklish.kScaleprotected boolean tickle(float er, int time) throws QTException
er
- the effective or actual rate that the timer is ticking at.time
- the current time of the time base expressed in the Ticklish.kScaleprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |