All Packages Class Hierarchy This Package Previous Next Index
Class graphing.GraphWindow
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----graphing.GraphWindow
- public class GraphWindow
- extends Canvas
- implements Runnable
A GraphWindow is a Canvas for drawing the graphs of mathematical functions. A set of
axes is described by the ranges xMin, xMax and yMin, yMax (with tickmarks
spaced at intervals of xScale and yScale respectively on the x and y axes).
Functions are added to the window with the addFunction() method and removed by deleteFunction
-
functionList
- List of all the functions on the graph.
-
gridColor
- Color of the optional grid
-
maxFunctions
- The number of functions allowed in this window.
-
showGrid
- Show a background grid if set
-
UNLIMITED
- Constant value to allow any number of functions.
-
xAxisLabel
- Label the axes with numbers if set
-
xMax
- Right-hand endpoint of the graph
-
xMin
- Left-hand endpoint of the graph
-
xScale
- Spacing of the tickmarks on the x-axis
-
yAxisLabel
- Label the axes with numbers if set
-
yMax
- Top endpoint of the graph
-
yMin
- Bottom endpoint of the graph
-
yScale
- Spacing of the tickmarks on the y-axis
-
GraphWindow()
- Make a GraphWindow with the default graphing range of -5...5 and -5...5
-
GraphWindow(double, double, double, double)
- Constructs a GraphWindow with the specified ranges of x and y axes.
-
GraphWindow(double, double, double, double, double, double)
- Constructs a GraphWindow with the specifies ranges of x and y axes.
-
addFunction(Function)
- Add a new Function to the list of functions being drawn, and draw it in the appropriate default color.
-
addFunction(Function, Color)
- Add a new Function to the list of functions being drawn, and draw it in the given Color.
-
deleteAll()
- Empty the list of functions being drawn.
-
deleteFunction(Function)
- Remove the function from the list of functions being drawn.
-
deleteLastFunction()
- Delate the last function to have been added from the list of functions being drawn.
-
drawGraph()
- This method should be called whenever the graph needs to be redrawn from scratch (rather than simply refreshed).
-
drawGraph(double, double, double, double)
- Change the axes, set the scale to zero (ie no tickmarks), and redraw from scratch.
-
drawGraph(double, double, double, double, double, double)
- Change the axes and scales and redraw the graph from scratch.
-
paint(Graphics)
-
-
run()
- The thread that actually draws the graph
-
x(double)
- Convert x-values to pixels.
-
x(int)
- Convert pixels to an x-value.
-
xMax()
- Returns the value of xMax
-
xMin()
- Returns the value of xMin
-
xScale()
- Returns the value of xScale
-
y(double)
- Convert y-values to pixels.
-
y(int)
- Convert pixels to y-values.
-
yMax()
- Returns the value of yMax
-
yMin()
- Returns the value of yMin
-
yScale()
- Returns the value of yScale
xMin
protected double xMin
- Left-hand endpoint of the graph
xMax
protected double xMax
- Right-hand endpoint of the graph
xScale
protected double xScale
- Spacing of the tickmarks on the x-axis
yMin
protected double yMin
- Bottom endpoint of the graph
yMax
protected double yMax
- Top endpoint of the graph
yScale
protected double yScale
- Spacing of the tickmarks on the y-axis
gridColor
protected Color gridColor
- Color of the optional grid
xAxisLabel
protected boolean xAxisLabel
- Label the axes with numbers if set
yAxisLabel
protected boolean yAxisLabel
- Label the axes with numbers if set
showGrid
protected boolean showGrid
- Show a background grid if set
functionList
protected Vector functionList
- List of all the functions on the graph.
UNLIMITED
public final static int UNLIMITED
- Constant value to allow any number of functions.
maxFunctions
public int maxFunctions
- The number of functions allowed in this window.
GraphWindow
public GraphWindow(double xMin,
double xMax,
double yMin,
double yMax)
- Constructs a GraphWindow with the specified ranges of x and y axes. The axes show no tickmarks.
GraphWindow
public GraphWindow(double xMin,
double xMax,
double xScale,
double yMin,
double yMax,
double yScale)
- Constructs a GraphWindow with the specifies ranges of x and y axes.
The axes show tickmarks marked out at intervals of xScale and yScale.
GraphWindow
public GraphWindow()
- Make a GraphWindow with the default graphing range of -5...5 and -5...5
drawGraph
public void drawGraph()
- This method should be called whenever the graph needs to be redrawn from scratch (rather than simply refreshed).
drawGraph
public void drawGraph(double xMin,
double xMax,
double xScale,
double yMin,
double yMax,
double yScale)
- Change the axes and scales and redraw the graph from scratch.
drawGraph
public void drawGraph(double xMin,
double xMax,
double yMin,
double yMax)
- Change the axes, set the scale to zero (ie no tickmarks), and redraw from scratch.
addFunction
public void addFunction(Function f,
Color c)
- Add a new Function to the list of functions being drawn, and draw it in the given Color.
addFunction
public void addFunction(Function f)
- Add a new Function to the list of functions being drawn, and draw it in the appropriate default color.
deleteFunction
public void deleteFunction(Function f)
- Remove the function from the list of functions being drawn.
deleteLastFunction
public void deleteLastFunction()
- Delate the last function to have been added from the list of functions being drawn.
deleteAll
public void deleteAll()
- Empty the list of functions being drawn.
xMin
public double xMin()
- Returns the value of xMin
xMax
public double xMax()
- Returns the value of xMax
xScale
public double xScale()
- Returns the value of xScale
yMin
public double yMin()
- Returns the value of yMin
yMax
public double yMax()
- Returns the value of yMax
yScale
public double yScale()
- Returns the value of yScale
x
public int x(double xValue)
- Convert x-values to pixels.
Convert a double (presumed in the range xMin to xMax) to the corresponding x coordinate
in the current graphics context.
x
public double x(int xCoord)
- Convert pixels to an x-value.
Convert an integer x coordinate (in the current graphics context) to the corresponding double
in the range xMin to xMax.
y
public int y(double yValue)
- Convert y-values to pixels.
Convert a double (presumed in the range yMin to yMax) to the corresponding y coordinate
in the current graphics context.
y
public double y(int yCoord)
- Convert pixels to y-values.
Convert an integer y coordinate (in the current graphics context) to the corresponding double
in the range yMin to yMax.
paint
public void paint(Graphics g)
- Overrides:
- paint in class Canvas
run
public void run()
- The thread that actually draws the graph
All Packages Class Hierarchy This Package Previous Next Index