import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 * Draws some colored graphs.  Redraws some colored graphs if one clicks on the
 * applet.
 *
 * @version 1.1    February 20, 2002
 * @author Franck van Breugel
 */
public class GraphDrawer extends Applet implements MouseListener
{
    public static final int WIDTH = 400;   // width of the graph
    public static final int HEIGHT = 200;  // height of the graph

    public static final int GRAPHS = 10;   // number of graphs

    /**
     * Initializes the applet.
     */
    public void init()
    {
        addMouseListener(this);
        setBackground(Color.black);
        setSize(WIDTH, HEIGHT);
    }

    /**
     * Draws some graphs.
     *
     * @param page the component on which is drawn.
     */
    public void paint(Graphics page)
    {
        for (int i = 0; i < GRAPHS; i++)
	{
            Graph graph = new Graph(WIDTH, HEIGHT);
            graph.draw(page);
	}
    }

    /**
     * Draws some graph when the mouse is pressed.
     *
     * @param event mouse event.
     */
    public void mousePressed(MouseEvent event) 
    {
        repaint();
    }

    /**
     * Nothing happens when the mouse is clicked.
     *
     * @param event mouse event.
     */
    public void mouseClicked(MouseEvent event) {}

    /**
     * Nothing happens when the mouse is released.
     *
     * @param event mouse event.
     */
    public void mouseReleased(MouseEvent event) {}

    /**
     * Nothing happens when the mouse enters the applet.
     *
     * @param event mouse event.
     */
    public void mouseEntered(MouseEvent event) {}

    /**
     * Nothing happens when the mouse exits the applet.
     *
     * @param event mouse event.
     */
    public void mouseExited(MouseEvent event) {}

}
