Class cs005.app.Animator

Class cs005.app.Animator

java.lang.Object
   |
   +----java.awt.Event
           |
           +----cs005.app.Animator

public class Animator
extends Event
implements Runnable
Package: cs005.app
Class: Animator
Send Complaints to: sco
Last Modified Sun, Jun 8, 1997 7:20pm

This is the cs5 Animator. It is intended to provide multithreaded animation without actually having to worry about all those nasty Thread synchronization issues. That's why it's a class of Event rather than Thread. It will cause an App to call the Animator's action method every time interval.

How To Use it:

subclass off of it.
put the code that you want to happen every interval in the action() method.
call the start() method, when you want the animation to start
call the stop() method when you want it to stop
repeat as necessary.

Constructor Index

 o Animator(App)
Constructor: Animator

This creates an animator with the default interval of 100 miliseconds.

 o Animator(App, long)
Constructor: Animator

This creates an Animator with the specified interval.

Method Index

 o action()
Method: action

This is the Abstract method for YOU to fill in!
The App calls this method every time it receives an Animator event, which happens roughly every interval.

 o getInterval()
Method: getInterval

 o run()
Method: run

This method is called by the animateThread constantly.

 o setInterval(long)
Method: setInterval

This method sets the Interval to the specified number of milliseconds.

 o start()
Method: start

This method starts the Animation.

 o stop()
Method: stop

This method stops the Animation.

Constructors

 o Animator
  public Animator(App app)
Constructor: Animator

This creates an animator with the default interval of 100 miliseconds.

Parameters:
app - the App to animate
 o Animator
  public Animator(App app,
                  long interval)
Constructor: Animator

This creates an Animator with the specified interval. All Animators are created in the stopped state.

Parameters:
app - The App to Animate
interval - The number of miliseconds between each call to action

Methods

 o run
  public void run()
Method: run

This method is called by the animateThread constantly. It delivers itself as an event to the applet and then puts the Thread to sleep for a certain number of miliseconds.

 o start
  public void start()
Method: start

This method starts the Animation. You must call this method before the Animator does anything. The Animation starts by starting the Thread.

 o stop
  public void stop()
Method: stop

This method stops the Animation. All Animators are "stopped" when they are created.

 o setInterval
  public synchronized void setInterval(long milliseconds)
Method: setInterval

This method sets the Interval to the specified number of milliseconds.

Parameters:
milliseconds - the interval in miliseconds
 o getInterval
  public long getInterval()
Method: getInterval

Returns:
The interval
 o action
  public abstract void action()
Method: action

This is the Abstract method for YOU to fill in!
The App calls this method every time it receives an Animator event, which happens roughly every interval. You should fill in this method with the code that you want to happen continuously.


All Packages  Class Hierarchy  This Package  Previous  Next  Index