All Packages Class Hierarchy This Package Previous Next Index
Class quicktime.app.actions.PeriodicAction
java.lang.Object
|
+----quicktime.app.actions.PeriodicAction
- public abstract class PeriodicAction
- extends Object
- implements Ticklish
This class is the base class for all periodically recurring time based actions.
The Actionable object (if defined) will
be an object that has its trigger method called when the PeriodicAction sub-class
action is executed or when a constraining condition of the action is reached.
The action is tickled periodically and whether it will do its action is dependant
upon the time interval as specified by the scale and period and the time and
effective rate of the tickle call.
- scale == 10, period = 1 => action executed 10 times a second at er == 1
- scale == 2, period = 1 => action is executed 2 times a second at er == 1
- scale == 1, scale = 2 => action is executed once every 2 seconds at er == 1
Every time the action is executed the time is kept and consequent calls to tickle
result in a comparison between the new time, the rate and the last time the action
was executed. Whether the action is executed is calculated by:
if (currentTime <= period / scale * 1000 / effectiveRate + lastTime) at rate > 0.
The tickle method is not called with an effectiveRate of 0.
Whether the doAction method is called can also be affected by a flag that controls
whether an action is triggered depending on rate settings.
-
actor
- The actionable actor object that can be invoked by an action if a constraining
condition is reached
-
reschedule
- If true then the tickle method returns true and the action is considered to
be still active by its owner and will be invoked on consequent tickles.
-
PeriodicAction(int, int)
- Create a PeriodicAction.
-
constraintReached()
- If after the doAction method has exeucted this method returns true then
if the Action has an Actionable object this actionable is triggered.
-
doAction(float, int)
- This method is called by the tickle method when an action becomes active.
-
equals(Object)
- Returns true if the objects are equal or false otherwise.
-
getActionable()
- This method retreives the current actor that is attached to the action
-
getPeriod()
- Returns the current period of the action
-
getScale()
- Return the current scale of the action.
-
getTriggerCondition()
- Returns the trigger condition of the action - an action can trigger
either when rate is positive, rate is negative or either.
-
setActionable(Actionable)
-
This method sets the actionable object of the action.
-
setPeriod(int)
- Sets the current period of the action - how many scale ticks will elapse
before the action is executed.
-
setScale(int)
- Sets the scale of the action - this is the resolution of a second at rate == 1,
thus a scale of 10 is 100msecs at rate == 1, 50msecs at rate == 2 etc.
-
setTriggerCondition(int)
- Sets the trigger condition of the action - an action can trigger
either when rate is positive, rate is negative or either.
-
tickle(float, int)
- This method can be called as often as you like, though effective rate
cannot be zero.
-
timeChanged(int)
- This method should be called by the actions owner whenver a time condition
of the owner's time line has changed, as this can effect the trigger
conditions of the action.
-
toString()
- Return a String representation of this object.
actor
protected Actionable actor
- The actionable actor object that can be invoked by an action if a constraining
condition is reached
reschedule
protected boolean reschedule
- If true then the tickle method returns true and the action is considered to
be still active by its owner and will be invoked on consequent tickles.
PeriodicAction
protected PeriodicAction(int scale,
int period)
- Create a PeriodicAction. Subclasses are responsible for defining the action
that occurs whenever the action is invoked.
- Parameters:
- scale - the amount with which a second is divided into at a rate of one
- period - the number of scale ticks that elapse between invocations of the action.
timeChanged
public void timeChanged(int newTime) throws QTException
- This method should be called by the actions owner whenver a time condition
of the owner's time line has changed, as this can effect the trigger
conditions of the action.
- Parameters:
- the - new time expressed in Ticklish.kScale ticks
- See Also:
- Ticklish
tickle
public boolean tickle(float effectiveRate,
int currentTime) throws QTException
- This method can be called as often as you like, though effective rate
cannot be zero.
The provided time and rate values are used to calculate whether an action
should be executed. If an action should be executed this method calls
the doAction method which should perform the action.
- Parameters:
- er - the actual rate at which the action has been triggered
- t - the time in Ticklish.kScale that the action has been triggered
- Returns:
- true if the action is still interested in being tickled.
doAction
protected abstract void doAction(float er,
int t) throws QTException
- This method is called by the tickle method when an action becomes active.
Subclasses should do their desired actions
when this method is called.
- Parameters:
- er - the actual rate at which the action has been triggered
- t - the time in Ticklish.kScale that the action has been triggered
constraintReached
protected abstract boolean constraintReached()
- If after the doAction method has exeucted this method returns true then
if the Action has an Actionable object this actionable is triggered. If
constraintReached returns false no further action is taken.
- Returns:
- true if the actionable object (if set) should be triggered
setActionable
public void setActionable(Actionable actor)
- This method sets the actionable object of the action.
getActionable
public Actionable getActionable()
- This method retreives the current actor that is attached to the action
setPeriod
public void setPeriod(int period)
- Sets the current period of the action - how many scale ticks will elapse
before the action is executed. If the period is zero the doAction method
is called whenever the PeriodicAction is tickled.
- Parameters:
- period - the new period
getPeriod
public int getPeriod()
- Returns the current period of the action
- Returns:
- the period
setScale
public void setScale(int s)
- Sets the scale of the action - this is the resolution of a second at rate == 1,
thus a scale of 10 is 100msecs at rate == 1, 50msecs at rate == 2 etc. This value
must be greater than zero.
- Parameters:
- s - the new scale or resolution of the action
getScale
public int getScale()
- Return the current scale of the action.
- Returns:
- the current scale
getTriggerCondition
public int getTriggerCondition()
- Returns the trigger condition of the action - an action can trigger
either when rate is positive, rate is negative or either.
- Returns:
- the current trigger condition
- See Also:
- triggerTimeFwd, triggerTimeBwd, triggerTimeEither
setTriggerCondition
public void setTriggerCondition(int cond)
- Sets the trigger condition of the action - an action can trigger
either when rate is positive, rate is negative or either.
- Parameters:
- cond - the current trigger condition
- See Also:
- triggerTimeFwd, triggerTimeBwd, triggerTimeEither
toString
public String toString()
- Return a String representation of this object.
- Returns:
- a String
- Overrides:
- toString in class Object
equals
public boolean equals(Object obj)
- Returns true if the objects are equal or false otherwise.
- Parameters:
- obj - the object to test
- Returns:
- a boolean
- Overrides:
- equals in class Object
All Packages Class Hierarchy This Package Previous Next Index