| java.lang.Object edu.hws.jcm.draw.Drawable edu.hws.jcm.draw.Grid
Grid | public class Grid extends Drawable (Code) | | A Grid object draws a graph paper-like grid on a Canvas. The pixel width
and height between adjacent grid lines is specified as a parameter to the
constructer, or through the access methods "setXSP(double)" and
"setYSP(double)". Note that the spacing will be scaled to between PIX_MIN
and PIX_MAX (20 and 80, respectively, by default). The color of the grid
lines can be set, and defaults to (220, 220, 220).
This class was written by Gabriel Weinstock (with some modifications by David Eck).
|
Constructor Summary | |
public | Grid() Create a Grid object with x and y spacing 1.0. | public | Grid(double xspace, double yspace) Create a Grid object with spacing specified. |
Method Summary | |
public void | draw(Graphics g, boolean coordsch) Draws the grid if an update is required. | public Color | getColor() Access method which returns the Color of the grid lines. | public double | getXSP() Access method to return the x spacing used between grid lines. | public double | getYSP() | public void | setColor(Color c) Method to set the Color used to draw grid lines. | public void | setXSP(double x) Method to set the x spacing between grid lines. | public void | setYSP(double y) Method to set the y spacing between grid lines. |
Grid | public Grid()(Code) | | Create a Grid object with x and y spacing 1.0. This does not mean that
the actual spacing between grid lines will be 1. It will be some reasonable
fraction or multiply of 1, with the value chosen to give a reasonable
spacing between the grid lines.
|
Grid | public Grid(double xspace, double yspace)(Code) | | Create a Grid object with spacing specified.
|
draw | public void draw(Graphics g, boolean coordsch)(Code) | | Draws the grid if an update is required. This is not usually called directly.
Parameters: g - the Graphics context Parameters: coordsch - boolean describing whether coordinates have changed |
getColor | public Color getColor()(Code) | | Access method which returns the Color of the grid lines.
|
getXSP | public double getXSP()(Code) | | Access method to return the x spacing used between grid lines.
|
getYSP | public double getYSP()(Code) | | Access method to return the y spacing used between grid lines
|
setColor | public void setColor(Color c)(Code) | | Method to set the Color used to draw grid lines.
|
setXSP | public void setXSP(double x)(Code) | | Method to set the x spacing between grid lines. This does not mean that
the actual spacing between grid lines will be x. It will be some reasonable
fraction or multiply of s, with the value chosen to give a reasonable
spacing between the grid lines.
|
setYSP | public void setYSP(double y)(Code) | | Method to set the y spacing between grid lines. This does not mean that
the actual spacing between grid lines will be y. It will be some reasonable
fraction or multiply of s, with the value chosen to give a reasonable
spacing between the grid lines.
|
|
|