guicomponents

## Class GTimer

- java.lang.Object
- - guicomponents.GTimer

-     public class GTimer
      extends Object

  This class is used to trigger events at user defined intervals. The event will call a user defined method/function. The only restriction is that the method used has no parameters and returns void eg

       void fireBall(){ ... }

  It has no visible GUI representation so will not appear in the GUI.
  Author:
    Peter Lager

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GTimer(PApplet theApplet, Object obj, String methodName, int delay)` Create the GTimer object with this ctor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getInitialDelay()` Get the initial delay time (milliseconds).
    `int` | `getInterval()` Get the interval time (milliseconds) between events.
    `boolean` | `isRunning()` Is the timer running?
    `boolean` | `isValid()` See if the GTimer object has been created successfully
    `void` | `setDelay(int delay)` Sets the initial delay and the interval between events.
    `void` | `setInitialDelay(int initDelay)` Set the delay before the first event is triggered
    `void` | `setInterval(int interval)` Set the interval between events
    `void` | `start()` Start the timer (call the method forever)
    `void` | `start(int nrepeats)` Start the timer and call the method for the number of times indicated by nrepeats If nrepeats is <=0 then repeat forever
    `void` | `stop()` Stop the timer (can be restarted with start() method)

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GTimer

          public GTimer(PApplet theApplet,
                Object obj,
                String methodName,
                int delay)

      Create the GTimer object with this ctor. 'methodName' is the method/function to be called every 'interval' milliseconds. 'obj' is the object that contains the method/function 'methodName' For most users 'methodName' will be in their main sketch so this parameter has the same value as 'theApplet'
      Parameters:
        `theApplet` - a reference to the PApplet object (invariably this)
        `obj` - the object that has the method to be executed (likely to be this)
        `methodName` - the name of the method to be called by the timer
        `delay` - the initial delay and the time (in millisecs) between function calls

  - ### Method Detail

    - #### start

          public void start()

      Start the timer (call the method forever)

    - #### start

          public void start(int nrepeats)

      Start the timer and call the method for the number of times indicated by nrepeats If nrepeats is <=0 then repeat forever
      Parameters:
        `nrepeats` -

    - #### stop

          public void stop()

      Stop the timer (can be restarted with start() method)

    - #### isRunning

          public boolean isRunning()

      Is the timer running?
      Returns:
        true if running

    - #### setInterval

          public void setInterval(int interval)

      Set the interval between events
      Parameters:
        `interval` - delay between events in milliseconds

    - #### setInitialDelay

          public void setInitialDelay(int initDelay)

      Set the delay before the first event is triggered
      Parameters:
        `initDelay` - initial delay in milliseconds

    - #### setDelay

          public void setDelay(int delay)

      Sets the initial delay and the interval between events.
      This is equivalent to calling both -

           setInterval(delay);
           setInitialDelay(delay);

      Parameters:
        `delay` - initial delay and interval in milliseconds

    - #### getInterval

          public int getInterval()

      Get the interval time (milliseconds) between events.
      Returns:
        interval in millsecs or -1 if the timer failed to be created.

    - #### getInitialDelay

          public int getInitialDelay()

      Get the initial delay time (milliseconds).
      Returns:
        initial delay in millsecs or -1 if the timer failed to be created.

    - #### isValid

          public boolean isValid()

      See if the GTimer object has been created successfully
      Returns:
        true if successful

Processing library guicomponents by Peter Lager. (C) 2012