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


Variable Index

 o functionList
List of all the functions on the graph.
 o gridColor
Color of the optional grid
 o maxFunctions
The number of functions allowed in this window.
 o showGrid
Show a background grid if set
 o UNLIMITED
Constant value to allow any number of functions.
 o xAxisLabel
Label the axes with numbers if set
 o xMax
Right-hand endpoint of the graph
 o xMin
Left-hand endpoint of the graph
 o xScale
Spacing of the tickmarks on the x-axis
 o yAxisLabel
Label the axes with numbers if set
 o yMax
Top endpoint of the graph
 o yMin
Bottom endpoint of the graph
 o yScale
Spacing of the tickmarks on the y-axis

Constructor Index

 o GraphWindow()
Make a GraphWindow with the default graphing range of -5...5 and -5...5
 o GraphWindow(double, double, double, double)
Constructs a GraphWindow with the specified ranges of x and y axes.
 o GraphWindow(double, double, double, double, double, double)
Constructs a GraphWindow with the specifies ranges of x and y axes.

Method Index

 o addFunction(Function)
Add a new Function to the list of functions being drawn, and draw it in the appropriate default color.
 o addFunction(Function, Color)
Add a new Function to the list of functions being drawn, and draw it in the given Color.
 o deleteAll()
Empty the list of functions being drawn.
 o deleteFunction(Function)
Remove the function from the list of functions being drawn.
 o deleteLastFunction()
Delate the last function to have been added from the list of functions being drawn.
 o drawGraph()
This method should be called whenever the graph needs to be redrawn from scratch (rather than simply refreshed).
 o drawGraph(double, double, double, double)
Change the axes, set the scale to zero (ie no tickmarks), and redraw from scratch.
 o drawGraph(double, double, double, double, double, double)
Change the axes and scales and redraw the graph from scratch.
 o paint(Graphics)
 o run()
The thread that actually draws the graph
 o x(double)
Convert x-values to pixels.
 o x(int)
Convert pixels to an x-value.
 o xMax()
Returns the value of xMax
 o xMin()
Returns the value of xMin
 o xScale()
Returns the value of xScale
 o y(double)
Convert y-values to pixels.
 o y(int)
Convert pixels to y-values.
 o yMax()
Returns the value of yMax
 o yMin()
Returns the value of yMin
 o yScale()
Returns the value of yScale

Variables

 o xMin
  protected double xMin
Left-hand endpoint of the graph

 o xMax
  protected double xMax
Right-hand endpoint of the graph

 o xScale
  protected double xScale
Spacing of the tickmarks on the x-axis

 o yMin
  protected double yMin
Bottom endpoint of the graph

 o yMax
  protected double yMax
Top endpoint of the graph

 o yScale
  protected double yScale
Spacing of the tickmarks on the y-axis

 o gridColor
  protected Color gridColor
Color of the optional grid

 o xAxisLabel
  protected boolean xAxisLabel
Label the axes with numbers if set

 o yAxisLabel
  protected boolean yAxisLabel
Label the axes with numbers if set

 o showGrid
  protected boolean showGrid
Show a background grid if set

 o functionList
  protected Vector functionList
List of all the functions on the graph.

 o UNLIMITED
  public final static int UNLIMITED
Constant value to allow any number of functions.

 o maxFunctions
  public int maxFunctions
The number of functions allowed in this window.

Constructors

 o 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.

 o 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.

 o GraphWindow
  public GraphWindow()
Make a GraphWindow with the default graphing range of -5...5 and -5...5

Methods

 o drawGraph
  public void drawGraph()
This method should be called whenever the graph needs to be redrawn from scratch (rather than simply refreshed).

 o 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.

 o 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.

 o 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.

 o 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.

 o deleteFunction
  public void deleteFunction(Function f)
Remove the function from the list of functions being drawn.

 o deleteLastFunction
  public void deleteLastFunction()
Delate the last function to have been added from the list of functions being drawn.

 o deleteAll
  public void deleteAll()
Empty the list of functions being drawn.

 o xMin
  public double xMin()
Returns the value of xMin

 o xMax
  public double xMax()
Returns the value of xMax

 o xScale
  public double xScale()
Returns the value of xScale

 o yMin
  public double yMin()
Returns the value of yMin

 o yMax
  public double yMax()
Returns the value of yMax

 o yScale
  public double yScale()
Returns the value of yScale

 o 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.

 o 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.

 o 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.

 o 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.

 o paint
  public void paint(Graphics g)
Overrides:
paint in class Canvas
 o run
  public void run()
The thread that actually draws the graph


All Packages  Class Hierarchy  This Package  Previous  Next  Index