import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.util.Iterator;
import java.util.LinkedList;

/*
 * BackgroundCanvas 
 * This code is included only for its educational content.
 * You should be able to compile your applet using only the class file
 * But, if you are curious how this works, by all means, poke around.
 */
public class BackgroundCanvas extends Canvas {
	
	Image image;
	LinkedList points = new LinkedList();
	
	
	BackgroundCanvas(Image i )
	{
		image = i;
	}
	
	public void paint(Graphics g)
	{
		Point p;
		super.paint(g);		
		g.drawImage(image, 0, 0, this);
		
		g.setColor(Color.RED);		
			
		Iterator i = points.iterator();
		
		while(i.hasNext() )
		{
			p = (Point)i.next();
			g.fillOval( p.x, p.y, 2, 2 );
		}		
	}	
	
	public void clear()
	{
		points.clear();
		repaint();
	}
	
	public void addPoint( int x, int y )
	{
		points.add(new Point(x, getHeight() - y));
		repaint();
	}

}
