Computer Science 120
Introduction to Programming
Spring 2012, Siena College
GraphGrid Demo
A working demo of GraphGrid will appear below. Click inside the applet to interact with it.
GraphGrid BlueJ Project
Click here to download a BlueJ project for GraphGrid.
GraphGrid Source Code
The Java source code for GraphGrid is below. Click on a file name to download it.
import objectdraw.*; import java.awt.*; /** * Write a description of class GraphGrid here. * * @author Dr. Sharon G Small * @version version 1.0 */ public class GraphGrid extends WindowController { private Line horizontalLine; private Line verticalLine; private static final int LINE_SPACE = 10; /* * CREATES A GRAPH ON THE CANVAS WITH HORIZONTAL AND VERTICAL LINES AT INCREMENTS * OF LINE_SPACE */ public void begin(){ int yPoint = LINE_SPACE; int xPoint = LINE_SPACE; //CREATES HORIZONTAL LINES while (yPoint < canvas.getHeight()){ horizontalLine = new Line(0,yPoint, canvas.getWidth(),yPoint,canvas); yPoint = yPoint + LINE_SPACE; } //CREATES VERTICAL LINES while (xPoint < canvas.getWidth()){ verticalLine = new Line(xPoint,0, xPoint,canvas.getHeight(),canvas); xPoint = xPoint + LINE_SPACE; } } }