Class Timer
All Packages Class Hierarchy This Package Previous Next Index
Class Timer
public class netscape.application.Timer
extends java.lang.Object
implements netscape.application.EventProcessor,
netscape.application.EventFilter
{
/* Constructors
*/
public Timer(EventLoop, Target, String, int);
public Timer(Target, String, int);
/* Methods
*/
public String command();
public Object data();
public int delay();
public boolean doesCoalesce();
public EventLoop eventLoop();
public Object filterEvents(Vector);
public int initialDelay();
public boolean isRunning();
public void processEvent(Event);
public boolean repeats();
public void setCoalesce(boolean);
public void setCommand(String);
public void setData(Object);
public void setDelay(int);
public void setInitialDelay(int);
public void setRepeats(boolean);
public void setTarget(Target);
public void start();
public void stop();
public Target target();
public long timeStamp();
public String toString();
}
Object subclass that causes an action to occur at a predefined rate. For
example, an animation object can use a Timer as the trigger for drawing its
next frame. Each Timer has a Target that receives a
performCommand() message; the command the Timer sends to its Target;
and a delay (the time between performCommand() calls). When
delay milliseconds have passed, a Timer sends the performCommand()
message to its Target, passing as parameters the command and the object set
using the Timer's setData() method. This cycle repeats until
stop() is called, or halts immediately if the Timer is configured
to send its message just once.
Using a Timer involves first creating it, then starting it using
the start() method.
- See Also:
- Target
Constructors
Timer
public Timer(EventLoop eventLoop,
Target target,
String command,
int delay)
- Constructs a Timer associated with the EventLoop eventLoop that
sends performCommand() to target every delay
milliseconds. You only call this constructor if you need to associate
a Timer with an EventLoop other than the application's EventLoop.
- See Also:
- Timer(Target, String, int)
Timer
public Timer(Target target,
String command,
int delay)
- Constructs a Timer associated with the application's EventLoop that
sends performCommand() to target every delay
milliseconds.
Methods
eventLoop
public EventLoop eventLoop()
- Returns the EventLoop associated with this Timer.
setTarget
public void setTarget(Target target)
- Sets the Target that will receive performCommand() messages
from the Timer.
target
public Target target()
- Returns the Target that will receive performCommand()
messages from the Timer.
- See Also:
- setTarget
setCommand
public void setCommand(String command)
- Sets the command the Timer sends to its target in the
performCommand() method.
- See Also:
- setTarget
command
public String command()
- Returns the command the Timer sends to its target in the
performCommand() message.
- See Also:
- setCommand
setData
public void setData(Object data)
- Sets the data sent with the command in the performCommand()
message to its target.
data
public Object data()
- Returns the data sent with the command in the performCommand()
message to its target.
- See Also:
- setData
setDelay
public void setDelay(int delay)
- Sets the Timer's delay, the number of milliseconds between successive
performCommand() messages to its Target.
- See Also:
- setTarget, setInitialDelay
delay
public int delay()
- Returns the Timer's delay.
- See Also:
- setDelay
setInitialDelay
public void setInitialDelay(int initialDelay)
- Sets the Timer's initial delay. This is the number of milliseconds
the Timer will wait before sending its first performCommand()
message to its Target. This setting has no effect if the Timer is
already running.
- See Also:
- setTarget, setDelay
initialDelay
public int initialDelay()
- Returns the Timer's initial delay.
- See Also:
- setDelay
setRepeats
public void setRepeats(boolean flag)
- If flag is false, instructs the Timer to send a
performCommand() message to its Target only once, and then stop.
repeats
public boolean repeats()
- Returns true if the Timer will send a performCommand()
message to its target multiple times.
- See Also:
- setRepeats
timeStamp
public long timeStamp()
- Returns the time stamp, in milliseconds, associated with the Timer's
most recent message to its Target.
setCoalesce
public void setCoalesce(boolean flag)
- Sets whether the Timer coalesces multiple pending
performCommand() messages. A busy application may not be able
to keep up with a Timer's message generation, causing multiple
performCommand() message sends to be queued. When processed,
the application sends these messages one after the other, causing the
Timer's Target to receive a sequence of performCommand()
messages with no delay between them. Coalescing avoids this situation
by reducing multiple pending messages to a single message send. Timers
coalesce their message sends by default.
doesCoalesce
public boolean doesCoalesce()
- Returns true if the Timer coalesces multiple pending
performCommand() messages.
- See Also:
- setCoalesce
start
public void start()
- Starts the Timer, causing it to send performCommand() messages
to its Target.
- See Also:
- stop
isRunning
public boolean isRunning()
- Returns true if the Timer is running.
- See Also:
- start
stop
public void stop()
- Stops a Timer, causing it to stop sending performCommand()
messages to its Target.
- See Also:
- start
filterEvents
public Object filterEvents(Vector events)
- EventFilter interface method, implemented to perform coalescing. You
never call this method.
- See Also:
- setCoalesce
processEvent
public void processEvent(Event event)
- EventProcessor interface method implemented to perform the Timer's
event processing behavior, which is to send the performCommand()
message to its Target. You never call this method.
- See Also:
- EventProcessor
toString
public String toString()
- Returns the Timer's string representation.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index