/*
 *	
 *  Filename: DrawGrid.java
 *  Java Applet Demo
 *  Author: Achim E Karger
 *  Course: CSCI 111 Java I
 *  Assignment: Lab 5
 *  Date:   March 10, 2008
 *  compiler JCreator LE
 *  Client web application: lab5.html
 *  
 *  this Applet displays a grid w/ color squares in a 50x60 pixel graphics area 
 *  the program is inspired by Small Java How to Program 6th Ed., Deitel&Deitel
 *   Chapter 8 p. 357, Fig. 8.21 MyLine.java
 *
 *
 */
 
import java.awt.*;
import java.applet.*;

/**
 * The DrawGrid class displays a grid w/ color-filled squares on the computer screen.
 * The user can set the position of the grid(in pixels), the number of rows and columns and 
 * the size of the squares (pitch in pixels)
 * The colors of the first 13 squares, starting with the top left corner of the grid, 
 * show all 13 predefined colors in the Color class (f.ex. Color.magenta). The remaining 
 * squares are filled white.
 *
 * @author  Achim E Karger
 * @version 1.0 03/10/08
 * @see     java.lang.System
 */
public class DrawGrid extends Applet {
   //-----------------------------------------------------------------
   //  Draws a grid
   //-----------------------------------------------------------------
  	Grid myGrid;
	public void init() {
      myGrid = new Grid(10,10,4,4,30); // make a grid originating at (x,y)= (10,10) 4x4 squares, 30 pixels each
	}
    /**
     * Execution of the program involves use of this override paint method.
     *
     * @param  g The Graphics object is used to draw basic shapes (low-level GUI-functions)
     */
	public void paint(Graphics g) {

      setBackground (Color.cyan);   // drawing area background color 
      g.setColor (Color.blue);      // gridlines in blue
      myGrid.draw(g);               // draw the grid
      myGrid.fill(g);               // fill the squares w/ colors 
	}
}


