G4P (GUI for Processing) 4.3.11
A set of GUI controls for your Processing sketch.
|
Public Member Functions | |
int | getInitialDelay () |
int | getInterval () |
int | getNbrRepeats () |
GTimer (PApplet theApplet, Object obj, String methodName, int delay) | |
GTimer (PApplet theApplet, Object obj, String methodName, int delay, int initDelay) | |
boolean | isRunning () |
boolean | isValid () |
void | setDelay (int delay) |
void | setInitialDelay (int initDelay) |
void | setInterval (int interval) |
void | setNbrRepeats (int nbrRepeats) |
void | start () |
void | start (int nrepeats) |
void | stop () |
Protected Member Functions | |
void | createEventHandler (Object handlerObj, String methodName) |
void | fireEvent () |
Protected Attributes | |
final PApplet | app |
Method | eventHandlerMethod = null |
String | eventHandlerMethodName |
Object | eventHandlerObject = null |
int | nbrRepeats = -1 |
Timer | timer = null |
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 a single parameter of type GTimer and returns void eg
void fireBall(GTimer timer){ ... }
Each timer object must have its own handler
It has no visible GUI representation so will not appear in the GUI.
g4p_controls.GTimer.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'
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 |
g4p_controls.GTimer.GTimer | ( | PApplet | theApplet, |
Object | obj, | ||
String | methodName, | ||
int | delay, | ||
int | initDelay | ||
) |
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'
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 time (in millisecs) between function calls |
initDelay | the initial delay (in millisecs) before calling method |
|
protected |
See if 'obj' has a method called 'methodName' that has a single parameter of type GTimer and if so keep a reference to it.
obj | |
methodName |
|
protected |
Attempt to fire an event for this timer. This will call the method/function defined in the ctor.
int g4p_controls.GTimer.getInitialDelay | ( | ) |
Get the initial delay time (milliseconds).
int g4p_controls.GTimer.getInterval | ( | ) |
Get the interval time (milliseconds) between events.
int g4p_controls.GTimer.getNbrRepeats | ( | ) |
The number of times an event is to be fired.
boolean g4p_controls.GTimer.isRunning | ( | ) |
Is the timer running?
boolean g4p_controls.GTimer.isValid | ( | ) |
See if the GTimer object has been created successfully
void g4p_controls.GTimer.setDelay | ( | int | delay | ) |
Sets the initial delay and the interval between events.
This is equivalent to calling both -
setInterval(delay); setInitialDelay(delay);
delay | initial delay and interval in milliseconds |
void g4p_controls.GTimer.setInitialDelay | ( | int | initDelay | ) |
Set the delay before the first event is triggered
initDelay | initial delay in milliseconds |
void g4p_controls.GTimer.setInterval | ( | int | interval | ) |
Set the interval between events
interval | delay between events in milliseconds |
void g4p_controls.GTimer.setNbrRepeats | ( | int | nbrRepeats | ) |
The number of times an event is to be fired.
nbrRepeats | ≥ 0 keep running until stopped by user |
void g4p_controls.GTimer.start | ( | ) |
Start the timer (call the method forever)
void g4p_controls.GTimer.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
nrepeats | the number of times to repeat the action |
void g4p_controls.GTimer.stop | ( | ) |
Stop the timer (can be restarted with start() method)