Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## quicktime.app.actions
Class PeriodicAction

    java.lang.Object
      |
      +--quicktime.app.actions.PeriodicAction

All Implemented Interfaces:
  Ticklish

Direct Known Subclasses:
  MatrixAction, SequencerAction

public abstract class PeriodicAction
extends java.lang.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.

Field Summary
`protected Actionable` | `actor` The actionable actor object that can be invoked by an action if a constraining condition is reached
`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.

Fields inherited from interface quicktime.app.time.Ticklish
`kScale`

Constructor Summary
`protected` | `PeriodicAction(int scale, int period)` Create a PeriodicAction.

Method Summary
`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.
`protected abstract void` | `doAction(float er, int t)` This method is called by the tickle method when an action becomes active.
`boolean` | `equals(java.lang.Object obj)` Returns true if the objects are equal or false otherwise.
`Actionable` | `getActionable()` This method retreives the current actor that is attached to the action
`int` | `getPeriod()` Returns the current period of the action
`int` | `getScale()` Return the current scale of the action.
`int` | `getTriggerCondition()` Returns the trigger condition of the action - an action can trigger either when rate is positive, rate is negative or either.
`void` | `setActionable(Actionable actor)` This method sets the actionable object of the action.
`void` | `setPeriod(int period)` Sets the current period of the action - how many scale ticks will elapse before the action is executed.
`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.
`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.
`boolean` | `tickle(float effectiveRate, int currentTime)` This method can be called as often as you like, though effective rate cannot be zero.
`void` | `timeChanged(int newTime)` 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.
`java.lang.String` | `toString()` Return a String representation of this object.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### 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.

Constructor Detail

### 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.

Method Detail

### 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.
  Specified by:
    `timeChanged` in interface `Ticklish`
  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.
  Specified by:
    `tickle` in interface `Ticklish`
  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:
    `quicktime.std.StdConstants.triggerTimeFwd`, `quicktime.std.StdConstants.triggerTimeBwd`, `quicktime.std.StdConstants.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:
    `quicktime.std.StdConstants.triggerTimeFwd`, `quicktime.std.StdConstants.triggerTimeBwd`, `quicktime.std.StdConstants.triggerTimeEither`

### toString

    public java.lang.String toString()

  Return a String representation of this object.
  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a String

### equals

    public boolean equals(java.lang.Object obj)

  Returns true if the objects are equal or false otherwise.
  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `obj` - the object to test
  Returns:
    a boolean

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD