import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.util.*; import java.awt.event.*; import java.io.*; /* Name of Lab: Terrain- GridGIS Class Your Name: Jennette Shepard Your Class: Comp Sci 210 Date: 4/3/08 This class rends the grid with the information that it takes from the Grid class which read the file. *I would also like to credit Professor Laura Toma because much of the *code I used was looked at from the class BoggleGUI */ public class GridGIS extends JFrame{ //gives dimensions of window private static final int WINDOW_WIDTH = 0; private static final int WINDOW_HEIGHT = 0; //declares graphics private Graphics g; //creates instance of Grid and gets the array that //the Grid class created from the file public static String GRIDFILENAME = "set1.asc.txt"; private Grid grid = new Grid(GRIDFILENAME); private Integer[][] elevationsFromFile = Grid.numsFromFile; //initializes the window, calls paint public GridGIS(){ //sets name, size, color, and //default close operation for window super("Drawing Window"); setSize(Grid.numCols, Grid.numRows); elevationsFromFile = Grid.numsFromFile; setBackground(Color.WHITE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); //calls paint repaint(); } //paints grid public void paint (Graphics g){ //cycles through array for(int j = 0; j< (Grid.numRows); j++){ for(int i = 0; i< (Grid.numCols); i++){ //draws a point ("line") for //each cell in array g.drawLine(i, j, i, j); //colors cell based on value if(Grid.numsFromFile[j][i]== Grid.noDataValue){ g.setColor(Color.BLACK); }else{ g.setColor(new Color(Grid.numsFromFile[j][i]%255*(int)(Grid.numsFromFile[j][i]/1300),Grid.numsFromFile[j][i]%255,Grid.numsFromFile[j][i]%255*(int)(Grid.numsFromFile[j][i]/1000))); } } } } public static void main(String[]args){ GridGIS gridGIS = new GridGIS(); } }//end