/** * ====================================================================== * SimpleScreen.java. Create simple GUI with panel ... * * Written By : Mark Austin October 2011 * ====================================================================== */ import java.lang.Math.*; import java.applet.*; import java.util.*; import java.io.*; import java.text.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; import java.awt.Color; import java.awt.font.*; import java.awt.image.*; import java.awt.geom.*; // Needed for affine transformation.... import java.net.URL; public class SimpleScreen extends JPanel { GraphicsGrid grid; GraphicsOperation grop; private Dimension size; private Graphics gs; int width, height; boolean DEBUG = true; // Constructor for simple screen .... SimpleScreen () { grid = new GraphicsGrid(); grop = new GraphicsOperation(); } public void paint() { Graphics g = getGraphics(); super.paintComponent(g); paintComponent(g); } public void update(Graphics g) {} public void paintComponent(Graphics g) { super.paintComponent(g); Dimension d = getSize(); size = getSize(); height = getSize().height; width = getSize().width; // Draw grid ..... if ( grop.getGrid() == true ) { gs = getGraphics(); grid.drawGrid( gs, getWidth(), getHeight() ); } } // Get graphics and fill in background .... public void clearScreen () { gs = getGraphics(); Graphics2D g2D = (Graphics2D) gs; g2D.setColor( Color.white ); g2D.fillRect( 0, 0, size.width-1, size.height-1 ); } // Draw grid on graphics screen .... void drawGrid() { grop.setGrid(true); gs = getGraphics(); grid.drawGrid( gs, getWidth(), getHeight() ); } }