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
-
GRIDCOARSE
- Static constant used for value of gridLines that correponds to a coarse grid.
-
GRIDFINE
- Static constant used for value of gridLines that correponds to a fine grid.
-
GRIDNORMAL
- Static constant used for value of gridLines that correponds to the default grid.
-
GRIDOFF
- Static used for value of gridLines that correponds no gridlines.
-
SHOWPOINT
- Static used for value of zoomMode that correponds to the show point mode.
-
ZOOMBOX
- Static used for value of zoomMode that correponds to the zoom box mode.
-
ZOOMIN
- Static used for value of zoomMode that correponds to the zoom in mode.
-
ZOOMOFF
- Static used for value of zoomMode that correponds to the zoom off mode.
-
ZOOMOUT
- Static used for value of zoomMode that correponds to the zoom out mode.
-
axesColor
- axesColor will designate the color in which the axes will be drawn
The default will be black.
-
dragging
- This will be true when the mouse is dragging in zoomBox mode
-
fm
- FontMetrics object for the current font
-
fontHeight
- fontHeight will contain the height of the font.
-
gridBorder
- gridBorder will provide a border for the Coordinate Grid
It will be a TitledBorder so that it can contain a title.
-
gridColor
- gridColor will designate the color in which the grid lines will be
drawn.
-
gridInsets
- gridInsets will tell the amount of inset on each side
for the border.
-
gridLines
- gridLines will designate the approximate number of gridLines that
will be drawn in each direction.
-
height
- height will contain the height of the coordinate
system in pixels.
-
innerBorder
- The inner border that will be used to display the upper title
-
justZoomed
- This will be true immediately after a zoom
-
message
- This will be the message that will be displayed at the top of the
graph
-
outerBorder
- The outer border that will be used to display the lower title
-
theFont
- The current font used for drawing.
-
title
- title will provide a title for the graph
-
width
- width will contain the width of the coordinate
system in pixels.
-
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.
-
xFontWidth
- xFontWidth contains the width of the largest
string to be displayed along the x axis.
-
xHashMark
- xHashMark will contain the mathematical distance between the hash marks
on the x axis
-
xHashMarkPixel
- xHashMarkPixel will contain the pixel distance between the hash marks
on the x axis
-
xLabel
- xLabel will contain the label to be displayed for the x-axis
-
xMark
- xMark will be the mathematical distance between gridlines on the x-axis.
-
xMarkPixel
- xMarkPixel is be the pixel version of xMark
-
xMax
- xMax will contain the default numerical value of the largest
x-coordinate displayed
-
xMaxCurrent
- This will hold the current parameter for the grid that will be
used for drawing.
-
xMaxPixel
- The pixel version of xMaxCurrent
-
xMin
- xMin will contain the default numerical value of the smallest
x-coordinate displayed
-
xMinCurrent
- This will hold the current parameter for the grid that will be
used for drawing.
-
xMinPixel
- The pixel version of xMinCurrent
-
xRange
- xRange will contain the mathematical width of the coordinate system.
-
xValue1
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
-
xValue2
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
-
xZeroMath
- xZeroMath is the math version of the x-coordinate of the "origin".
-
xZeroPixel
- xZeroPixel is the pixel version of the x-coordinate of the "origin".
-
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.
-
yFontWidth
- yFontWidth contains the width of the largest
string to be displayed along the y axis.
-
yHashMark
- yHashMarks will contain the mathematical distance between the hash marks
on the y axis
-
yHashMarkPixel
- yHashMarkPixel will contain the pixel distance between the hash marks
on the y axis
-
yLabel
- yLabel will contain the label to be displayed for the y-axis
-
yMark
- yMark will be the mathematical distance between gridlines on the y-axis.
-
yMarkPixel
- yMarkPixel is be the pixel version of yMark
-
yMax
- yMax will contain the default numerical value of the largest
y-coordinate displayed
-
yMaxCurrent
- This will hold the current parameter for the grid that will be
used for drawing.
-
yMaxPixel
- The pixel version of yMaxCurrent
-
yMin
- yMin will contain the default numerical value of the smallest
y-coordinate displayed
-
yMinCurrent
- This will hold the current parameter for the grid that will be
used for drawing.
-
yMinPixel
- The pixel version of yMinCurrent
-
yRange
- yRange will contain the mathematical height of the coordinate system.
-
yValue1
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
-
yValue2
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
-
yZeroMath
- yZeroMath is the math version of the y-coordinate of the "origin".
-
yZeroPixel
- yZeroPixel is the pixel version of the y-coordinate of the "origin".
-
zoomFactor
- This will determine the factor by which you zoom in or out
-
zoomMode
- the value of zoomMode will determine how the Grid will respond to
a mouse-click.
-
EDU.emporia.mathbeans.MathGrid()
-
-
adjustBorders()
- This method will adjust the borders to make sure that there is room
to display the labels
-
getAxesColor()
- Gets the color that will be used to draw the axes.
-
getGridColor()
- Gets the color to be used for the gridlines
-
getGridLines()
- Gets the approximate number of gridlines to be drawn.
-
getMessage()
- Gets the message that will appear at the top of
the grid.
-
getTitle()
- Gets the title that is displayed at the bottom
of the grid.
-
getXLabel()
- Gets the label that will be used for the x-axis.
-
getXMax()
- Gets the value of xMax
-
getXMin()
- Gets the value of xMin
-
getYLabel()
- Gets the Label to be used for the y-axis
-
getYMax()
- Gets the value of yMax
-
getYMin()
- Gets the value of YMin
-
getZoomFactor()
- Gets the factor that will be used in Zoom In or
Zoom Out mode.
-
getZoomMode()
- Gets the value of zoomMode
-
main(String[])
-
-
paintComponent(Graphics)
- Paints the Grid
-
reshape(int, int, int, int)
- This method has been deprecated and should be removed
when possible.
-
resize(int, int)
- This method has been deprecated and should be removed
when possible.
-
setAxesColor(Color)
- Sets the color that will be used to draw the axes.
-
setBounds(int, int, int, int)
- overrides the setBounds method so that it will
update the parameters before redrawing.
-
setBounds(Rectangle)
- overrides the setBounds method so that it will
update the parameters before redrawing.
-
setGridColor(Color)
- Sets the color to be used for the gridlines.
-
setGridLines(int)
- Sets the approximate number of gridlines to be drawn.
-
setMessage(String)
- Sets the message that will be displayed at the top
of the grid.
-
setSize(Dimension)
- Overrides the setSize method so that it will update
the parmeters before redrawing.
-
setSize(int, int)
- Overrides the setSize method so that it will
update the parameters before redrawing.
-
setTitle(String)
- Sets the title that will be displayed at the
bottom of the graph.
-
setXLabel(String)
- Sets the label to be used for the x-axis.
-
setXMax(double)
- Sets the value of xMax
-
setXMin(double)
- Sets the value of xMin
-
setYLabel(String)
- Sets the label to be used for the y-axis.
-
setYMax(double)
- Sets the value of yMax
-
setYMin(double)
- Sets the value of yMin
-
setZoomFactor(int)
- Sets the factor that will be used for zooming in
Zoom In, or Zoom Out mode.
-
setZoomMode(int)
- This sets the zoom mode by assigning a value
to the parameter zoomMode.
-
toString()
- Gives a String description of the coordinate system
-
updateParameters()
- This method will update the parameters to reflect any changes made in
xMin, xMax, yMin, yMax, or the overall size of the MathGrid.
-
xMathToPixel(double)
- Converts a math x coordinate into its corresponding
coordinate in pixels.
-
xPixelToMath(int)
- Converts the pixel version of an x-coordinate
into its corresponding math coordinate
-
yMathToPixel(double)
- Converts a math y coordinate into its corresponding
coordinate in pixels.
-
yPixelToMath(int)
- Converts the pixel version of the y-coordinate into
the mathematical one
GRIDCOARSE
public static final int GRIDCOARSE
- Static constant used for value of gridLines that correponds to a coarse grid.
GRIDFINE
public static final int GRIDFINE
- Static constant used for value of gridLines that correponds to a fine grid.
GRIDNORMAL
public static final int GRIDNORMAL
- Static constant used for value of gridLines that correponds to the default grid.
GRIDOFF
public static final int GRIDOFF
- Static used for value of gridLines that correponds no gridlines.
SHOWPOINT
public static final int SHOWPOINT
- Static used for value of zoomMode that correponds to the show point mode.
ZOOMBOX
public static final int ZOOMBOX
- Static used for value of zoomMode that correponds to the zoom box mode.
ZOOMIN
public static final int ZOOMIN
- Static used for value of zoomMode that correponds to the zoom in mode.
ZOOMOFF
public static final int ZOOMOFF
- Static used for value of zoomMode that correponds to the zoom off mode.
ZOOMOUT
public static final int ZOOMOUT
- Static used for value of zoomMode that correponds to the zoom out mode.
axesColor
protected java.awt.Color axesColor
- axesColor will designate the color in which the axes will be drawn
The default will be black.
dragging
protected boolean dragging
- This will be true when the mouse is dragging in zoomBox mode
fm
protected java.awt.FontMetrics fm
- FontMetrics object for the current font
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.
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.
gridColor
protected java.awt.Color gridColor
- gridColor will designate the color in which the grid lines will be
drawn. The default will be white.
gridInsets
protected java.awt.Insets gridInsets
- gridInsets will tell the amount of inset on each side
for the border.
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.
height
protected int height
- height will contain the height of the coordinate
system in pixels.
innerBorder
protected javax.swing.border.TitledBorder innerBorder
- The inner border that will be used to display the upper title
justZoomed
protected boolean justZoomed
- This will be true immediately after a zoom
message
protected java.lang.String message
- This will be the message that will be displayed at the top of the
graph
outerBorder
protected javax.swing.border.TitledBorder outerBorder
- The outer border that will be used to display the lower title
theFont
protected java.awt.Font theFont
- The current font used for drawing.
title
protected java.lang.String title
- title will provide a title for the graph
width
protected int width
- width will contain the width of the coordinate
system in pixels.
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.
xFontWidth
protected int xFontWidth
- xFontWidth contains the width of the largest
string to be displayed along the x axis.
xHashMark
protected double xHashMark
- xHashMark will contain the mathematical distance between the hash marks
on the x axis
xHashMarkPixel
protected int xHashMarkPixel
- xHashMarkPixel will contain the pixel distance between the hash marks
on the x axis
xLabel
protected java.lang.String xLabel
- xLabel will contain the label to be displayed for the x-axis
xMark
protected double xMark
- xMark will be the mathematical distance between gridlines on the x-axis.
xMarkPixel
protected int xMarkPixel
- xMarkPixel is be the pixel version of xMark
xMax
protected double xMax
- xMax will contain the default numerical value of the largest
x-coordinate displayed
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.
xMaxPixel
protected int xMaxPixel
- The pixel version of xMaxCurrent
xMin
protected double xMin
- xMin will contain the default numerical value of the smallest
x-coordinate displayed
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.
xMinPixel
protected int xMinPixel
- The pixel version of xMinCurrent
xRange
protected double xRange
- xRange will contain the mathematical width of the coordinate system.
(as opposed to the pixel width.)
xValue1
protected int xValue1
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
xValue2
protected int xValue2
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
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.
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.
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.
yFontWidth
protected int yFontWidth
- yFontWidth contains the width of the largest
string to be displayed along the y axis.
yHashMark
protected double yHashMark
- yHashMarks will contain the mathematical distance between the hash marks
on the y axis
yHashMarkPixel
protected int yHashMarkPixel
- yHashMarkPixel will contain the pixel distance between the hash marks
on the y axis
yLabel
protected java.lang.String yLabel
- yLabel will contain the label to be displayed for the y-axis
yMark
protected double yMark
- yMark will be the mathematical distance between gridlines on the y-axis.
yMarkPixel
protected int yMarkPixel
- yMarkPixel is be the pixel version of yMark
yMax
protected double yMax
- yMax will contain the default numerical value of the largest
y-coordinate displayed
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.
yMaxPixel
protected int yMaxPixel
- The pixel version of yMaxCurrent
yMin
protected double yMin
- yMin will contain the default numerical value of the smallest
y-coordinate displayed
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.
yMinPixel
protected int yMinPixel
- The pixel version of yMinCurrent
yRange
protected double yRange
- yRange will contain the mathematical height of the coordinate system.
(as opposed to the pixel height.)
yValue1
protected int yValue1
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
yValue2
protected int yValue2
- Used to hold the coordinates of the rectange used when dragging the
mouse in zoom box mode
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.
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.
zoomFactor
protected int zoomFactor
- This will determine the factor by which you zoom in or out
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.
MathGrid
public MathGrid()
adjustBorders
protected void adjustBorders()
- This method will adjust the borders to make sure that there is room
to display the labels
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
getGridColor
public java.awt.Color getGridColor()
- Gets the color to be used for the gridlines
- Returns:
- The color of the gridlines.
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.
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.
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.
getXLabel
public java.lang.String getXLabel()
- Gets the label that will be used for the x-axis.
- Returns:
- The label for the x-axis.
getXMax
public double getXMax()
- Gets the value of xMax
- Returns:
- The largest x-value on the x-axis.
getXMin
public double getXMin()
- Gets the value of xMin
- Returns:
- The smallest value on the x-axis
getYLabel
public java.lang.String getYLabel()
- Gets the Label to be used for the y-axis
- Returns:
- The label for the y-axis.
getYMax
public double getYMax()
- Gets the value of yMax
- Returns:
- The largest y-value on the y-axis
getYMin
public double getYMin()
- Gets the value of YMin
- Returns:
- The smallest y-value on the y-axis
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.
getZoomMode
public int getZoomMode()
- Gets the value of zoomMode
- Returns:
- The value of zoomMode which determines the
zoom mode for the MathGrid.
main
public static void main(String[] argv)
paintComponent
public void paintComponent(Graphics a)
- Paints the Grid
- Parameters:
- a - The Graphics context used to paint the grid
- Overrides:
- paintComponent in class JComponent
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
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
setAxesColor
public void setAxesColor(Color axesColor)
- Sets the color that will be used to draw the axes.
- Parameters:
- axesColor - The color for the axes.
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
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
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.
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)
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.
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
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
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.
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".
setXMax
public void setXMax(double xMax)
- Sets the value of xMax
- Parameters:
- xMax - The largest value on the x-axis
setXMin
public void setXMin(double xMin)
- Sets the value of xMin
- Parameters:
- xMin - The smallest value represented on the x-axis.
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".
setYMax
public void setYMax(double yMax)
- Sets the value of yMax
- Parameters:
- yMax - The largest y-value on the y-axis.
setYMin
public void setYMin(double yMin)
- Sets the value of yMin
- Parameters:
- yMin - The smallest value on the y-axis
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.
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
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
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.
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
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.
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
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