import java.awt.*;


/**
 * Organizes all animation.
 * Animation related methods are here:
 * start(), stop(), setDelay(), getDelay()
 *
 * @author Selim Mimaroglu
 * @version 1.0
 */

public class Animator implements Runnable {

    public Animator(Component com) {
	this.comp = com;
    }

    /**
     * Set delay for animation
     * @param delay amount of delay
     *
     */
    final public void setDelay(int delay) {
	this.delay = delay;
    }

    /**
     * Return delay.
     * @return the delay
     */
    final public int getDelay() {
	return delay;
    }


    /**
     * Start a new thread. Paint the Marble Ground
     *
     */
    public void start() {
	animationThread = new Thread(this);
	animationThread.start();
	comp.repaint();
    }

    /**
     * set thread to null
     */
    public void stop() {
	animationThread = null;
    }

    /*****************************************************
     * run() doesn't have to do anything at all
     * A series of events drive the Marble Game
     * not the run!. It's possible to wait for ever
     * if the user doesn't do anything, program waits
     *
     * run() method may be thing as an objection to 
     * this property. It's good for self driven animations
     ******************************************************/
    public void run() {
	
    }
    
    /**
     * Animated component
     */
    protected Component comp;

    /**
     * Delay between repaints
     */
    protected int delay = 100;

    /**
     * Thread that will run this animation
     */
    protected Thread animationThread;
}











