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

Class EDU.emporia.mathbeans.MathGrapher

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

public class MathGrapher
extends MathGrid
MathGrapher is capable of displaying graphs of curves and of discrete points

Version:
1.3
Author:
Joe Yanik
Since:
6/30/00

Variable Index

 o defaultPointColor
The default color to be used when no color is specified for a given point
 o discretePoints
The array of discrete points to be graphed on the MathGrapher
 o f
Parameter used to add a graph to the MathGrapher
 o g
Parameter used to add a graph to the MathGrapher
 o graph
The graph array will contain the graphs to be graphed
 o graphColor
An array of colors to be used to draw the graphs in different colors
 o graphCounter
The number of graphs currently being displayed
 o graphPoints
The graphPoints arrays will contain the points to be used to plot the graphs
 o maxNumberOfGraphs
The maximum number of graphs that can be displayed at one time
 o point
point is will reference the Point2D object used by plotPoints to be displayed.
 o pointColors
An array of Color objects that will determine the color to be used to display each point.
 o pointPlotted
pointPlotted is a boolean used to keep track of the first time that pointPlot is called.
 o pointRadius
The radius (in pixels) used to draw the discrete points.
 o tDelta
The tMin array keeps track of the current value of tMin for each curve.
 o tMax
The tMin array keeps track of the current value of tMin for each curve.
 o tMin
The tMin array keeps track of the current value of tMin for each curve.
 o tTraceHome
The "home point" for the trace
 o traceEnabled
Keeps track of whether or not the trace feature is enabled
 o traceGraph
This will correspond to the index of the graph to be traced at the moment
 o traceMultiplier
This will be incremented or decremented as the graph is traced.
 o xPixelWidth
The mathematical width of one pixel on the coordinate system
 o xTraceMath
xTraceMath is the mathematical x-coordinate of the current point displayed in the trace
 o yTraceMath
xTraceMath is the mathematical x-coordinate of the current point displayed in the trace

Constructor Index

 o EDU.emporia.mathbeans.MathGrapher()

Method Index

 o addGraph(Graphable)
addGraph adds a new Graph to the MathGrapher
 o addGraph(Graphable, Color)
Another version of addGraph that allows you to specify the color of the graph.
 o addPoint(Point2D.Double)
Adds a new point to be displayed using the default color.
 o addPoint(Point2D.Double, Color)
A version of the addPoint method that allows you to specify the color used to display the point.
 o addPoint(double, double)
Another version of the addPoint method that accepts the coordinates of the point as parameters
 o addPoint(double, double, Color)
Still another version of the addPoint method that specifies the color.
 o addPoints(Point2D.Double[])
Adds all the points to the graph
 o getF()
Gets the parameter f
 o getG()
Gets the value of the parameter g
 o getPointRadius()
Returns the radius (in pixels) that will be used to plot the discrete points.
 o isTraceEnabled()
Determines whether or not the trace feature is enabled
 o main(String[])
 o paintComponent(Graphics)
Paints the Grid
 o plotPoint(double, double)
Plots the point with indicated coordinates.
 o removeAllPoints()
Removes all points from the graph
 o removeGraph()
removeGraph will remove the most recently displayed graph
 o removeGraph(int)
Removes the graph at the indicated index
 o removeGraph(Graphable)
Removes the specified graph
 o removePoint(Point2D.Double)
Removes the point from the graph.
 o setF(Graphable)
Sets the values of the Graphable object f which would then be added to the MathGrapher
 o setG(Graphable)
Sets the parameter g
 o setPointRadius(int)
Sets the radius (in pixels) of the discrete points to be plotted on the graph.
 o setTraceEnabled(boolean)
Sets whether or not the trace feature is enabled
 o updateGraph()
updateGraph should be called whenever a new graph has been added or when one of the graphs that has already been added has changed
 o updateParameters()
updateParameters readjusts all the parameters of the graph.
 o updateTrace()
updateTrace adjusts the parameters to display the new trace point

Variables

 o defaultPointColor
protected java.awt.Color defaultPointColor
The default color to be used when no color is specified for a given point

 o discretePoints
protected java.util.Vector discretePoints
The array of discrete points to be graphed on the MathGrapher

 o f
protected EDU.emporia.mathtools.Graphable f
Parameter used to add a graph to the MathGrapher

 o g
protected EDU.emporia.mathtools.Graphable g
Parameter used to add a graph to the MathGrapher

 o graph
protected EDU.emporia.mathtools.Graphable[] graph
The graph array will contain the graphs to be graphed

 o graphColor
protected java.awt.Color[] graphColor
An array of colors to be used to draw the graphs in different colors

 o graphCounter
protected int graphCounter
The number of graphs currently being displayed

 o graphPoints
protected EDU.emporia.mathtools.Point2D[][] graphPoints
The graphPoints arrays will contain the points to be used to plot the graphs

 o maxNumberOfGraphs
protected int maxNumberOfGraphs
The maximum number of graphs that can be displayed at one time

 o point
protected EDU.emporia.mathtools.Point2D.Double point
point is will reference the Point2D object used by plotPoints to be displayed.

 o pointColors
protected java.util.Vector pointColors
An array of Color objects that will determine the color to be used to display each point.

 o pointPlotted
protected boolean pointPlotted
pointPlotted is a boolean used to keep track of the first time that pointPlot is called.

 o pointRadius
protected int pointRadius
The radius (in pixels) used to draw the discrete points. Must be at least 2.

 o tDelta
protected double[] tDelta
The tMin array keeps track of the current value of tMin for each curve. For functions it will be xMinCurrent

 o tMax
protected double[] tMax
The tMin array keeps track of the current value of tMin for each curve. For functions it will be xMinCurrent

 o tMin
protected double[] tMin
The tMin array keeps track of the current value of tMin for each curve. For functions it will be xMinCurrent

 o tTraceHome
protected double tTraceHome
The "home point" for the trace

 o traceEnabled
protected boolean traceEnabled
Keeps track of whether or not the trace feature is enabled

 o traceGraph
protected int traceGraph
This will correspond to the index of the graph to be traced at the moment

 o traceMultiplier
protected double traceMultiplier
This will be incremented or decremented as the graph is traced.

 o xPixelWidth
protected double xPixelWidth
The mathematical width of one pixel on the coordinate system

 o xTraceMath
protected double xTraceMath
xTraceMath is the mathematical x-coordinate of the current point displayed in the trace

 o yTraceMath
protected double yTraceMath
xTraceMath is the mathematical x-coordinate of the current point displayed in the trace

Constructors

 o MathGrapher
public MathGrapher()

Methods

 o addGraph
public void addGraph(Graphable h)
addGraph adds a new Graph to the MathGrapher

Parameters:
h - h is a Graphable object. It could either represent a function or a parameteric curve
 o addGraph
public void addGraph(Graphable h,
                     Color c)
Another version of addGraph that allows you to specify the color of the graph.

Parameters:
h - The Graphable object to be graphed
c - The color that it will be graphed in.
 o addPoint
public void addPoint(EDU.emporia.mathtools.Point2D.Double p)
Adds a new point to be displayed using the default color. Repeated invocation of addPoint will result in additional points being displayed

Parameters:
p - The point to be displayed
 o addPoint
public void addPoint(EDU.emporia.mathtools.Point2D.Double p,
                     Color c)
A version of the addPoint method that allows you to specify the color used to display the point.

Parameters:
p - The point to be displayed
c - The color used to display it
 o addPoint
public void addPoint(double x,
                     double y)
Another version of the addPoint method that accepts the coordinates of the point as parameters

Parameters:
x - The x-coordinate of the point
y - The y-coordinate of the point
 o addPoint
public void addPoint(double x,
                     double y,
                     Color c)
Still another version of the addPoint method that specifies the color.

Parameters:
x - The mathematical x-coordinate of the point to be added
y - The mathematical y-coordinate of the point to be added.
c - The color used to draw the point
 o addPoints
public void addPoints(EDU.emporia.mathtools.Point2D.Double[] pointArray)
Adds all the points to the graph

Parameters:
pointArray - The array of points to be added to the graph
 o getF
public EDU.emporia.mathtools.Graphable getF()
Gets the parameter f

Returns:
The Graphable object f which is displayed on the Graph
 o getG
public EDU.emporia.mathtools.Graphable getG()
Gets the value of the parameter g

Returns:
The graphable object g
 o getPointRadius
public int getPointRadius()
Returns the radius (in pixels) that will be used to plot the discrete points.

 o isTraceEnabled
public boolean isTraceEnabled()
Determines whether or not the trace feature is enabled

Returns:
True if enabled, false otherwise
 o main
public static void main(String[] argv)
 o paintComponent
public void paintComponent(Graphics a)
Paints the Grid

Overrides:
paintComponent in class MathGrid
 o plotPoint
public void plotPoint(double x,
                      double y)
Plots the point with indicated coordinates. Repeated calls of plotPoint will only result in the latest point being plotted.

Parameters:
x - The x-coordinate of the point to be plotted
y - The y-coordinate of the point to be plotted
 o removeAllPoints
public void removeAllPoints()
Removes all points from the graph

 o removeGraph
public void removeGraph()
removeGraph will remove the most recently displayed graph

 o removeGraph
public void removeGraph(int index)
Removes the graph at the indicated index

Parameters:
index - The index of the graph to be removed
 o removeGraph
public void removeGraph(Graphable h)
Removes the specified graph

Parameters:
h - The Graphable object to be removed
 o removePoint
public void removePoint(EDU.emporia.mathtools.Point2D.Double p)
Removes the point from the graph. It will remove the last occurrence of a point whose coordinates equal the coordinates of the point that is passed

Parameters:
p - The point to be removed from the graph
 o setF
public void setF(Graphable f)
Sets the values of the Graphable object f which would then be added to the MathGrapher

Parameters:
f - The Graphable object representing the curve to be graphed
 o setG
public void setG(Graphable g)
Sets the parameter g

Parameters:
g - The Graphable object g
 o setPointRadius
public void setPointRadius(int radius)
Sets the radius (in pixels) of the discrete points to be plotted on the graph. Since 2 is the smallest radius that can be displayed any value less than 2 will result in a radius of 2

Parameters:
radius - The radius (in pixels) of the discrete points to be plotted
 o setTraceEnabled
public void setTraceEnabled(boolean traceEnabled)
Sets whether or not the trace feature is enabled

Parameters:
traceEnabled - When true trace will be enabled
 o updateGraph
public void updateGraph()
updateGraph should be called whenever a new graph has been added or when one of the graphs that has already been added has changed

 o updateParameters
protected void updateParameters()
updateParameters readjusts all the parameters of the graph. It will be called whenever the xRange or yRange have changed

Overrides:
updateParameters in class MathGrid
 o updateTrace
protected void updateTrace()
updateTrace adjusts the parameters to display the new trace point


All Packages  Class Hierarchy  This Package  Previous  Next  Index