Package edu.hws.jcm.draw
Class Grid
java.lang.Object
edu.hws.jcm.draw.Drawable
edu.hws.jcm.draw.Grid
- All Implemented Interfaces:
Serializable
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).
- See Also:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draws the grid if an update is required.getColor()
Access method which returns the Color of the grid lines.double
getXSP()
Access method to return the x spacing used between grid lines.double
getYSP()
Access method to return the y spacing used between grid linesvoid
Method to set the Color used to draw grid lines.void
setXSP
(double x) Method to set the x spacing between grid lines.void
setYSP
(double y) Method to set the y spacing between grid lines.Methods inherited from class edu.hws.jcm.draw.Drawable
getVisible, needsRedraw, setOwnerData, setVisible
-
Constructor Details
-
Grid
public Grid()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) Create a Grid object with spacing specified.
-
-
Method Details
-
getColor
Access method which returns the Color of the grid lines. -
setColor
Method to set the Color used to draw grid lines. -
getXSP
public double getXSP()Access method to return the x spacing used between grid lines. -
getYSP
public double getYSP()Access method to return the y spacing used between grid lines -
setXSP
public void setXSP(double x) 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) 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. -
draw
Draws the grid if an update is required. This is not usually called directly.
-