Class EDU.emporia.mathbeans.MathGrid
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class EDU.emporia.mathbeans.MathGrid

Object
   |
   +----Component
           |
           +----Container
                   |
                   +----JComponent
                           |
                           +----JPanel
                                   |
                                   +----EDU.emporia.mathbeans.MathGrid

public class MathGrid
extends JPanel

Variable Index

 o GRIDCOARSE
Static constant used for value of gridLines that correponds to a coarse grid.
 o GRIDFINE
Static constant used for value of gridLines that correponds to a fine grid.
 o GRIDNORMAL
Static constant used for value of gridLines that correponds to the default grid.
 o GRIDOFF
Static used for value of gridLines that correponds no gridlines.
 o SHOWPOINT
Static used for value of zoomMode that correponds to the show point mode.
 o ZOOMBOX
Static used for value of zoomMode that correponds to the zoom box mode.
 o ZOOMIN
Static used for value of zoomMode that correponds to the zoom in mode.
 o ZOOMOFF
Static used for value of zoomMode that correponds to the zoom off mode.
 o ZOOMOUT
Static used for value of zoomMode that correponds to the zoom out mode.
 o axesColor
axesColor will designate the color in which the axes will be drawn The default will be black.
 o dragging
This will be true when the mouse is dragging in zoomBox mode
 o fm
FontMetrics object for the current font
 o fontHeight
fontHeight will contain the height of the font.
 o gridBorder
gridBorder will provide a border for the Coordinate Grid It will be a TitledBorder so that it can contain a title.
 o gridColor
gridColor will designate the color in which the grid lines will be drawn.
 o gridInsets
gridInsets will tell the amount of inset on each side for the border.
 o gridLines
gridLines will designate the approximate number of gridLines that will be drawn in each direction.
 o height
height will contain the height of the coordinate system in pixels.
 o innerBorder
The inner border that will be used to display the upper title
 o justZoomed
This will be true immediately after a zoom
 o message
This will be the message that will be displayed at the top of the graph
 o outerBorder
The outer border that will be used to display the lower title
 o theFont
The current font used for drawing.
 o title
title will provide a title for the graph
 o width
width will contain the width of the coordinate system in pixels.
 o xBorder
xBorder will contain the number of pixels to be designated for the border in the x direction that will be added, when necessary, to leave room for the labels.
 o xFontWidth
xFontWidth contains the width of the largest string to be displayed along the x axis.
 o xHashMark
xHashMark will contain the mathematical distance between the hash marks on the x axis
 o xHashMarkPixel
xHashMarkPixel will contain the pixel distance between the hash marks on the x axis
 o xLabel
xLabel will contain the label to be displayed for the x-axis
 o xMark
xMark will be the mathematical distance between gridlines on the x-axis.
 o xMarkPixel
xMarkPixel is be the pixel version of xMark
 o xMax
xMax will contain the default numerical value of the largest x-coordinate displayed
 o xMaxCurrent
This will hold the current parameter for the grid that will be used for drawing.
 o xMaxPixel
The pixel version of xMaxCurrent
 o xMin
xMin will contain the default numerical value of the smallest x-coordinate displayed
 o xMinCurrent
This will hold the current parameter for the grid that will be used for drawing.
 o xMinPixel
The pixel version of xMinCurrent
 o xRange
xRange will contain the mathematical width of the coordinate system.
 o xValue1
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode
 o xValue2
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode
 o xZeroMath
xZeroMath is the math version of the x-coordinate of the "origin".
 o xZeroPixel
xZeroPixel is the pixel version of the x-coordinate of the "origin".
 o yBorder
yBorder will contain the number of pixels to be designated for the border in the y direction that will be added, when necessary, to leave room for the labels.
 o yFontWidth
yFontWidth contains the width of the largest string to be displayed along the y axis.
 o yHashMark
yHashMarks will contain the mathematical distance between the hash marks on the y axis
 o yHashMarkPixel
yHashMarkPixel will contain the pixel distance between the hash marks on the y axis
 o yLabel
yLabel will contain the label to be displayed for the y-axis
 o yMark
yMark will be the mathematical distance between gridlines on the y-axis.
 o yMarkPixel
yMarkPixel is be the pixel version of yMark
 o yMax
yMax will contain the default numerical value of the largest y-coordinate displayed
 o yMaxCurrent
This will hold the current parameter for the grid that will be used for drawing.
 o yMaxPixel
The pixel version of yMaxCurrent
 o yMin
yMin will contain the default numerical value of the smallest y-coordinate displayed
 o yMinCurrent
This will hold the current parameter for the grid that will be used for drawing.
 o yMinPixel
The pixel version of yMinCurrent
 o yRange
yRange will contain the mathematical height of the coordinate system.
 o yValue1
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode
 o yValue2
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode
 o yZeroMath
yZeroMath is the math version of the y-coordinate of the "origin".
 o yZeroPixel
yZeroPixel is the pixel version of the y-coordinate of the "origin".
 o zoomFactor
This will determine the factor by which you zoom in or out
 o zoomMode
the value of zoomMode will determine how the Grid will respond to a mouse-click.

Constructor Index

 o EDU.emporia.mathbeans.MathGrid()

Method Index

 o adjustBorders()
This method will adjust the borders to make sure that there is room to display the labels
 o getAxesColor()
Gets the color that will be used to draw the axes.
 o getGridColor()
Gets the color to be used for the gridlines
 o getGridLines()
Gets the approximate number of gridlines to be drawn.
 o getMessage()
Gets the message that will appear at the top of the grid.
 o getTitle()
Gets the title that is displayed at the bottom of the grid.
 o getXLabel()
Gets the label that will be used for the x-axis.
 o getXMax()
Gets the value of xMax
 o getXMin()
Gets the value of xMin
 o getYLabel()
Gets the Label to be used for the y-axis
 o getYMax()
Gets the value of yMax
 o getYMin()
Gets the value of YMin
 o getZoomFactor()
Gets the factor that will be used in Zoom In or Zoom Out mode.
 o getZoomMode()
Gets the value of zoomMode
 o main(String[])
 o paintComponent(Graphics)
Paints the Grid
 o reshape(int, int, int, int)
This method has been deprecated and should be removed when possible.
 o resize(int, int)
This method has been deprecated and should be removed when possible.
 o setAxesColor(Color)
Sets the color that will be used to draw the axes.
 o setBounds(int, int, int, int)
overrides the setBounds method so that it will update the parameters before redrawing.
 o setBounds(Rectangle)
overrides the setBounds method so that it will update the parameters before redrawing.
 o setGridColor(Color)
Sets the color to be used for the gridlines.
 o setGridLines(int)
Sets the approximate number of gridlines to be drawn.
 o setMessage(String)
Sets the message that will be displayed at the top of the grid.
 o setSize(Dimension)
Overrides the setSize method so that it will update the parmeters before redrawing.
 o setSize(int, int)
Overrides the setSize method so that it will update the parameters before redrawing.
 o setTitle(String)
Sets the title that will be displayed at the bottom of the graph.
 o setXLabel(String)
Sets the label to be used for the x-axis.
 o setXMax(double)
Sets the value of xMax
 o setXMin(double)
Sets the value of xMin
 o setYLabel(String)
Sets the label to be used for the y-axis.
 o setYMax(double)
Sets the value of yMax
 o setYMin(double)
Sets the value of yMin
 o setZoomFactor(int)
Sets the factor that will be used for zooming in Zoom In, or Zoom Out mode.
 o setZoomMode(int)
This sets the zoom mode by assigning a value to the parameter zoomMode.
 o toString()
Gives a String description of the coordinate system
 o updateParameters()
This method will update the parameters to reflect any changes made in xMin, xMax, yMin, yMax, or the overall size of the MathGrid.
 o xMathToPixel(double)
Converts a math x coordinate into its corresponding coordinate in pixels.
 o xPixelToMath(int)
Converts the pixel version of an x-coordinate into its corresponding math coordinate
 o yMathToPixel(double)
Converts a math y coordinate into its corresponding coordinate in pixels.
 o yPixelToMath(int)
Converts the pixel version of the y-coordinate into the mathematical one

Variables

 o GRIDCOARSE
public static final int GRIDCOARSE
Static constant used for value of gridLines that correponds to a coarse grid.

 o GRIDFINE
public static final int GRIDFINE
Static constant used for value of gridLines that correponds to a fine grid.

 o GRIDNORMAL
public static final int GRIDNORMAL
Static constant used for value of gridLines that correponds to the default grid.

 o GRIDOFF
public static final int GRIDOFF
Static used for value of gridLines that correponds no gridlines.

 o SHOWPOINT
public static final int SHOWPOINT
Static used for value of zoomMode that correponds to the show point mode.

 o ZOOMBOX
public static final int ZOOMBOX
Static used for value of zoomMode that correponds to the zoom box mode.

 o ZOOMIN
public static final int ZOOMIN
Static used for value of zoomMode that correponds to the zoom in mode.

 o ZOOMOFF
public static final int ZOOMOFF
Static used for value of zoomMode that correponds to the zoom off mode.

 o ZOOMOUT
public static final int ZOOMOUT
Static used for value of zoomMode that correponds to the zoom out mode.

 o axesColor
protected java.awt.Color axesColor
axesColor will designate the color in which the axes will be drawn The default will be black.

 o dragging
protected boolean dragging
This will be true when the mouse is dragging in zoomBox mode

 o fm
protected java.awt.FontMetrics fm
FontMetrics object for the current font

 o fontHeight
protected int fontHeight
fontHeight will contain the height of the font. This will be used to adjust the bottom border so that there is room to display the labels.

 o gridBorder
protected javax.swing.border.TitledBorder gridBorder
gridBorder will provide a border for the Coordinate Grid It will be a TitledBorder so that it can contain a title.

 o gridColor
protected java.awt.Color gridColor
gridColor will designate the color in which the grid lines will be drawn. The default will be white.

 o gridInsets
protected java.awt.Insets gridInsets
gridInsets will tell the amount of inset on each side for the border.

 o gridLines
protected int gridLines
gridLines will designate the approximate number of gridLines that will be drawn in each direction. It may not be precise due to rounding.

 o height
protected int height
height will contain the height of the coordinate system in pixels.

 o innerBorder
protected javax.swing.border.TitledBorder innerBorder
The inner border that will be used to display the upper title

 o justZoomed
protected boolean justZoomed
This will be true immediately after a zoom

 o message
protected java.lang.String message
This will be the message that will be displayed at the top of the graph

 o outerBorder
protected javax.swing.border.TitledBorder outerBorder
The outer border that will be used to display the lower title

 o theFont
protected java.awt.Font theFont
The current font used for drawing.

 o title
protected java.lang.String title
title will provide a title for the graph

 o width
protected int width
width will contain the width of the coordinate system in pixels.

 o xBorder
protected int xBorder
xBorder will contain the number of pixels to be designated for the border in the x direction that will be added, when necessary, to leave room for the labels.

 o xFontWidth
protected int xFontWidth
xFontWidth contains the width of the largest string to be displayed along the x axis.

 o xHashMark
protected double xHashMark
xHashMark will contain the mathematical distance between the hash marks on the x axis

 o xHashMarkPixel
protected int xHashMarkPixel
xHashMarkPixel will contain the pixel distance between the hash marks on the x axis

 o xLabel
protected java.lang.String xLabel
xLabel will contain the label to be displayed for the x-axis

 o xMark
protected double xMark
xMark will be the mathematical distance between gridlines on the x-axis.

 o xMarkPixel
protected int xMarkPixel
xMarkPixel is be the pixel version of xMark

 o xMax
protected double xMax
xMax will contain the default numerical value of the largest x-coordinate displayed

 o xMaxCurrent
protected double xMaxCurrent
This will hold the current parameter for the grid that will be used for drawing. When in zoomIn or zoomOut mode it may differ from xMax which will be used to preserve the default values.

 o xMaxPixel
protected int xMaxPixel
The pixel version of xMaxCurrent

 o xMin
protected double xMin
xMin will contain the default numerical value of the smallest x-coordinate displayed

 o xMinCurrent
protected double xMinCurrent
This will hold the current parameter for the grid that will be used for drawing. When in zoomIn or zoomOut mode it may differ from xMin which will be used to preserve the default values.

 o xMinPixel
protected int xMinPixel
The pixel version of xMinCurrent

 o xRange
protected double xRange
xRange will contain the mathematical width of the coordinate system. (as opposed to the pixel width.)

 o xValue1
protected int xValue1
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode

 o xValue2
protected int xValue2
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode

 o xZeroMath
protected double xZeroMath
xZeroMath is the math version of the x-coordinate of the "origin". This will correspond to x=0, if possible, but, in general, it will be where the axes cross.

 o xZeroPixel
protected int xZeroPixel
xZeroPixel is the pixel version of the x-coordinate of the "origin". This will correspond to x=0, if possible, but, in general, it will be where the axes cross.

 o yBorder
protected int yBorder
yBorder will contain the number of pixels to be designated for the border in the y direction that will be added, when necessary, to leave room for the labels.

 o yFontWidth
protected int yFontWidth
yFontWidth contains the width of the largest string to be displayed along the y axis.

 o yHashMark
protected double yHashMark
yHashMarks will contain the mathematical distance between the hash marks on the y axis

 o yHashMarkPixel
protected int yHashMarkPixel
yHashMarkPixel will contain the pixel distance between the hash marks on the y axis

 o yLabel
protected java.lang.String yLabel
yLabel will contain the label to be displayed for the y-axis

 o yMark
protected double yMark
yMark will be the mathematical distance between gridlines on the y-axis.

 o yMarkPixel
protected int yMarkPixel
yMarkPixel is be the pixel version of yMark

 o yMax
protected double yMax
yMax will contain the default numerical value of the largest y-coordinate displayed

 o yMaxCurrent
protected double yMaxCurrent
This will hold the current parameter for the grid that will be used for drawing. When in zoomIn or zoomOut mode it may differ from yMax which will be used to preserve the default values.

 o yMaxPixel
protected int yMaxPixel
The pixel version of yMaxCurrent

 o yMin
protected double yMin
yMin will contain the default numerical value of the smallest y-coordinate displayed

 o yMinCurrent
protected double yMinCurrent
This will hold the current parameter for the grid that will be used for drawing. When in zoomIn or zoomOut mode it may differ from yMin which will be used to preserve the default values.

 o yMinPixel
protected int yMinPixel
The pixel version of yMinCurrent

 o yRange
protected double yRange
yRange will contain the mathematical height of the coordinate system. (as opposed to the pixel height.)

 o yValue1
protected int yValue1
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode

 o yValue2
protected int yValue2
Used to hold the coordinates of the rectange used when dragging the mouse in zoom box mode

 o yZeroMath
protected double yZeroMath
yZeroMath is the math version of the y-coordinate of the "origin". This will correspond to y=0, if possible, but, in general, it will be where the axes cross.

 o yZeroPixel
protected int yZeroPixel
yZeroPixel is the pixel version of the y-coordinate of the "origin". This will correspond to y=0, if possible, but, in general, it will be where the axes cross.

 o zoomFactor
protected int zoomFactor
This will determine the factor by which you zoom in or out

 o zoomMode
protected int zoomMode
the value of zoomMode will determine how the Grid will respond to a mouse-click. It will either do nothing, zoom in, zoom out, zoom in on a box, or display the coordinates of the point depending on the mode.

Constructors

 o MathGrid
public MathGrid()

Methods

 o adjustBorders
protected void adjustBorders()
This method will adjust the borders to make sure that there is room to display the labels

 o getAxesColor
public java.awt.Color getAxesColor()
Gets the color that will be used to draw the axes. The default is black

Returns:
The color of the axes
 o getGridColor
public java.awt.Color getGridColor()
Gets the color to be used for the gridlines

Returns:
The color of the gridlines.
 o getGridLines
public int getGridLines()
Gets the approximate number of gridlines to be drawn.

Returns:
The value of gridLines, which is used to determine the approximate number of gridlines to be drawn.
 o getMessage
public java.lang.String getMessage()
Gets the message that will appear at the top of the grid.

Returns:
The message that will appear at the top of the grid.
 o getTitle
public java.lang.String getTitle()
Gets the title that is displayed at the bottom of the grid.

Returns:
The title that is displayed at the bottom of the grid.
 o getXLabel
public java.lang.String getXLabel()
Gets the label that will be used for the x-axis.

Returns:
The label for the x-axis.
 o getXMax
public double getXMax()
Gets the value of xMax

Returns:
The largest x-value on the x-axis.
 o getXMin
public double getXMin()
Gets the value of xMin

Returns:
The smallest value on the x-axis
 o getYLabel
public java.lang.String getYLabel()
Gets the Label to be used for the y-axis

Returns:
The label for the y-axis.
 o getYMax
public double getYMax()
Gets the value of yMax

Returns:
The largest y-value on the y-axis
 o getYMin
public double getYMin()
Gets the value of YMin

Returns:
The smallest y-value on the y-axis
 o getZoomFactor
public int getZoomFactor()
Gets the factor that will be used in Zoom In or Zoom Out mode.

Returns:
The factor that will be used in Zoom In or Zoom Out mode.
 o getZoomMode
public int getZoomMode()
Gets the value of zoomMode

Returns:
The value of zoomMode which determines the zoom mode for the MathGrid.
 o main
public static void main(String[] argv)
 o paintComponent
public void paintComponent(Graphics a)
Paints the Grid

Parameters:
a - The Graphics context used to paint the grid
Overrides:
paintComponent in class JComponent
 o reshape
public void reshape(int x,
                    int y,
                    int width,
                    int height)
This method has been deprecated and should be removed when possible. It was put in because the VC environment appeared to use it

Parameters:
x - x coordinate
y - y coordinate
width - Width
height - Height
Overrides:
reshape in class JComponent
 o resize
public void resize(int width,
                   int height)
This method has been deprecated and should be removed when possible. It was put in because the VC environment appeared to use it

Parameters:
width - The width of the region
height - The height of the region
Overrides:
resize in class Component
 o setAxesColor
public void setAxesColor(Color axesColor)
Sets the color that will be used to draw the axes.

Parameters:
axesColor - The color for the axes.
 o setBounds
public void setBounds(int x,
                      int y,
                      int width,
                      int height)
overrides the setBounds method so that it will update the parameters before redrawing.

Parameters:
x - The x-coordinate of the upper left hand corner of the MathGrid in its new location in the container.
y - The y-coordinate of the upper left hand corner of the MathGrid in its new location in its container.
width - The width in pixels.
height - The height in pixels
Overrides:
setBounds in class Component
 o setBounds
public void setBounds(Rectangle r)
overrides the setBounds method so that it will update the parameters before redrawing.

Parameters:
r - The rectangle correponding to the new bounds
Overrides:
setBounds in class Component
 o setGridColor
public void setGridColor(Color gridColor)
Sets the color to be used for the gridlines. The default is white.

Parameters:
gridColor - The color of the gridlines.
 o setGridLines
public void setGridLines(int gridLines)
Sets the approximate number of gridlines to be drawn. Static variables GRIDOFF, GRIDCOARSE, GRIDNORMAL, and GRIDFINE, correspond to approximately 0, 10, 20, and 30 lines, respectively.

Parameters:
gridLines - The approximate number of gridlines to be drawn. (It may be adjusted to make the gridlines appear at nicer numbers)
 o setMessage
public void setMessage(String message)
Sets the message that will be displayed at the top of the grid.

Parameters:
message - Gets the message that is displayed at the bottom of the grid.
 o setSize
public void setSize(Dimension d)
Overrides the setSize method so that it will update the parmeters before redrawing.

Parameters:
d - The dimension object that determines the new size.
Overrides:
setSize in class Component
 o setSize
public void setSize(int w,
                    int h)
Overrides the setSize method so that it will update the parameters before redrawing.

Parameters:
w - The width in pixels of the new size.
h - The height in pixels of the new size
Overrides:
setSize in class Component
 o setTitle
public void setTitle(String title)
Sets the title that will be displayed at the bottom of the graph.

Parameters:
title - The title that will be displayed at the bottom of the grid.
 o setXLabel
public void setXLabel(String xLabel)
Sets the label to be used for the x-axis.

Parameters:
xLabel - The label for the x-axis. The default is "x".
 o setXMax
public void setXMax(double xMax)
Sets the value of xMax

Parameters:
xMax - The largest value on the x-axis
 o setXMin
public void setXMin(double xMin)
Sets the value of xMin

Parameters:
xMin - The smallest value represented on the x-axis.
 o setYLabel
public void setYLabel(String yLabel)
Sets the label to be used for the y-axis.

Parameters:
yLabel - The label for the y-axis. The default is "y".
 o setYMax
public void setYMax(double yMax)
Sets the value of yMax

Parameters:
yMax - The largest y-value on the y-axis.
 o setYMin
public void setYMin(double yMin)
Sets the value of yMin

Parameters:
yMin - The smallest value on the y-axis
 o setZoomFactor
public void setZoomFactor(int zoomFactor)
Sets the factor that will be used for zooming in Zoom In, or Zoom Out mode. In Zoom In mode it will divide by this factor and in Zoom Out mode it will multiply by it to determine the new range of x and y values.

Parameters:
zoomFactor - The factor that will be used in zooming. Any number smaller than one will be ignored.
 o setZoomMode
public void setZoomMode(int zoomMode)
This sets the zoom mode by assigning a value to the parameter zoomMode. Depending on the value of zoomMode the MathGrid will zoom in, zoom out show the coordinates of a point, redraw in the coordinates of a box drawn by clicking and dragging, or disable zooming.

Parameters:
zoomMode - The integer that will determine the zoom mode. Static constants ZOOMIN, ZOOMOUT, ZOOMBOX, SHOWPOINT, ZOOMOFF are provided.
See Also:
ZOOMOUT, ZOOMIN, ZOOMBOX, SHOWPOINT, ZOOMOFF
 o toString
public java.lang.String toString()
Gives a String description of the coordinate system

Returns:
A string description of the coordinate system.
Overrides:
toString in class Component
 o updateParameters
protected void updateParameters()
This method will update the parameters to reflect any changes made in xMin, xMax, yMin, yMax, or the overall size of the MathGrid.

 o xMathToPixel
public int xMathToPixel(double x)
Converts a math x coordinate into its corresponding coordinate in pixels.

Parameters:
x - The x-coordinate to be converted.
Returns:
The distance in pixels from the left side of the MathGrid of the point with this x-coordinate
 o xPixelToMath
public double xPixelToMath(int p)
Converts the pixel version of an x-coordinate into its corresponding math coordinate

Parameters:
p - The distance in pixels from the left hand side of the MathGrid
Returns:
The double precsion floating point value that corresponds to this x-coordinate of this in the plane.
 o yMathToPixel
public int yMathToPixel(double y)
Converts a math y coordinate into its corresponding coordinate in pixels.

Parameters:
y - The y-coordinate to be converted.
Returns:
The distance in pixels from the top of the MathGrid of the point with this y-coordinate
 o yPixelToMath
public double yPixelToMath(int p)
Converts the pixel version of the y-coordinate into the mathematical one

Parameters:
p - The distance in pixels from the top of the MathGrid of a point.
Returns:
The double-precision floating point number that gives the y-coordinate in the plane of a point at that location.

All Packages  Class Hierarchy  This Package  Previous  Next  Index