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

Class EDU.emporia.mathbeans.SlopeField

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

public class SlopeField
extends MathGrapher
This is a class that will construct a slope field corresponding to a first order differential equation. It is also capable of graphing an approximation to a solution using Euler's method.

Version:
1.0
Author:
Joe Yanik
Since:
6/1/2001

Variable Index

 o dataPoints
This is a Vector of points.
 o eulerDelta
This is the delta that is used in Euler's approximation to get the next point.
 o eulerGraphColor
This determines the color that will be used to draw the graph that approximates the solution.
 o eulerMouseEnabled
When this is true the user will be able to add a data point by clicking on the slope field with the mouse.
 o eulerPointNumber
This determines the number of iterations to be used when graphing an approximation according to Euler's method.
 o fieldColor
This is the color to be used to draw the slope field The default color is black.
 o slopeRadius
This determines the length in pixels of the line segments used to show the slope field.
 o xDerivative
This is the formula that is used for the derivative of x.
 o yDerivative
This is the formula that is used for the derivative of y in the differential equation.

Constructor Index

 o EDU.emporia.mathbeans.SlopeField()

Method Index

 o addDataPoint(Point2D.Double)
Adds a dataPoint to be used to generate an Euler approximation.
 o addDataPoint(double, double)
Another version of the addDataPoint method that accepts the coordinates of the point to be added.
 o getEulerDelta()
Gets the increment that will be used in drawing the graph of an approximate solution using Euler's method.
 o getEulerGraphColor()
Gets the color used for drawing the graph of the approximate solutions.
 o getEulerPointNumber()
Gets the number of iterations to be used in drawing an approximate graph using Euler's method.
 o getFieldColor()
Gets the color to be used for the slope field.
 o getSlopeRadius()
Gets the radius (in pixels) to be used in drawing the line segments for the slope fields.
 o getXDerivative()
Gets the formula g(x,y) to be used in the differential equation y'=g(x,y)
 o getYDerivative()
Gets the formula to be used in the differential equatio y'=f(x,y).
 o isEulerMouseEnabled()
Gets the value of the variable eulerMouseEnabled.
 o main(String[])
 o paintComponent(Graphics)
Paints the Grid
 o removeAllDataPoints()
Clears all points from the Slope Field.
 o removeDataPoint(Point2D.Double)
Removes a point from the Vector.
 o setEulerDelta(double)
Sets the increment that will be used in Euler's method when drawing the graph of an approximate solution.
 o setEulerGraphColor(Color)
Sets the color used for the approximate solutions.
 o setEulerMouseEnabled(boolean)
Sets whether or not the user will be able to click on the slope field with a mouse and have an approximation drawn through that point.
 o setEulerPointNumber(int)
Sets the number of iterations that will be used in drawing a graph using Euler's method.
 o setFieldColor(Color)
Sets the color to be used for the slope field.
 o setSlopeRadius(int)
Sets the radius in pixels to be used in drawing the line segments for the slope field.
 o setXDerivative(String)
Sets the formula for g(x,y) to be used in the differential equation x'=g(x,y).
 o setYDerivative(String)
Sets the formula for f(x,y) to be used in the differential equation y'=f(x,y).
 o toString()
Gives a String description of the coordinate system

Variables

 o dataPoints
protected java.util.Vector dataPoints
This is a Vector of points. Each point will be used as a starting point for an Euler approximation to a solution.

 o eulerDelta
protected double eulerDelta
This is the delta that is used in Euler's approximation to get the next point. Smaller values will result in more accuracy. The default is 0.1

 o eulerGraphColor
protected java.awt.Color eulerGraphColor
This determines the color that will be used to draw the graph that approximates the solution. The default is a navy blue.

 o eulerMouseEnabled
protected boolean eulerMouseEnabled
When this is true the user will be able to add a data point by clicking on the slope field with the mouse. This will result in a curve being drawn that approximates a solution to the differential equation.

 o eulerPointNumber
protected int eulerPointNumber
This determines the number of iterations to be used when graphing an approximation according to Euler's method. The actual number of points is actually twice this number since it graphs the curve in both the positive and negative direction. The default is 200.

 o fieldColor
protected java.awt.Color fieldColor
This is the color to be used to draw the slope field The default color is black.

 o slopeRadius
protected int slopeRadius
This determines the length in pixels of the line segments used to show the slope field. It must be a positive integer.

 o xDerivative
protected java.lang.String xDerivative
This is the formula that is used for the derivative of x. If it is intended to represent a single differential equation of the form y'=f(x,y), then this should have value 1. The default is 1.

 o yDerivative
protected java.lang.String yDerivative
This is the formula that is used for the derivative of y in the differential equation. It should be a expressed in terms of x and y. The default value is x.

Constructors

 o SlopeField
public SlopeField()

Methods

 o addDataPoint
public void addDataPoint(EDU.emporia.mathtools.Point2D.Double p)
Adds a dataPoint to be used to generate an Euler approximation.

Parameters:
p - A Point2D object
 o addDataPoint
public void addDataPoint(double x,
                         double y)
Another version of the addDataPoint method that accepts the coordinates of the point to be added.

Parameters:
x - The first coordinate of the point to be added.
y - The second coordinate of the point to be added.
 o getEulerDelta
public double getEulerDelta()
Gets the increment that will be used in drawing the graph of an approximate solution using Euler's method.

 o getEulerGraphColor
public java.awt.Color getEulerGraphColor()
Gets the color used for drawing the graph of the approximate solutions.

 o getEulerPointNumber
public int getEulerPointNumber()
Gets the number of iterations to be used in drawing an approximate graph using Euler's method.

 o getFieldColor
public java.awt.Color getFieldColor()
Gets the color to be used for the slope field.

 o getSlopeRadius
public int getSlopeRadius()
Gets the radius (in pixels) to be used in drawing the line segments for the slope fields.

Returns:
Half the width (in pixels) of the square that will contain the line segment.
 o getXDerivative
public java.lang.String getXDerivative()
Gets the formula g(x,y) to be used in the differential equation y'=g(x,y)

Returns:
The formula for g(x,y)
 o getYDerivative
public java.lang.String getYDerivative()
Gets the formula to be used in the differential equatio y'=f(x,y).

Returns:
The formula f(x,y)
 o isEulerMouseEnabled
public boolean isEulerMouseEnabled()
Gets the value of the variable eulerMouseEnabled.

Returns:
True if the user can generate graphs with a mouse click and false otherwise.
 o main
public static void main(String[] argv)
 o paintComponent
public void paintComponent(Graphics g)
Paints the Grid

Overrides:
paintComponent in class MathGrapher
 o removeAllDataPoints
public void removeAllDataPoints()
Clears all points from the Slope Field.

 o removeDataPoint
public void removeDataPoint(EDU.emporia.mathtools.Point2D.Double p)
Removes a point from the Vector.

 o setEulerDelta
public void setEulerDelta(double eulerDelta)
Sets the increment that will be used in Euler's method when drawing the graph of an approximate solution.

 o setEulerGraphColor
public void setEulerGraphColor(Color eulerGraphColor)
Sets the color used for the approximate solutions.

 o setEulerMouseEnabled
public void setEulerMouseEnabled(boolean eulerMouseEnabled)
Sets whether or not the user will be able to click on the slope field with a mouse and have an approximation drawn through that point.

 o setEulerPointNumber
public void setEulerPointNumber(int eulerPointNumber)
Sets the number of iterations that will be used in drawing a graph using Euler's method. Since the graph is drawn in both the positive and the negative direction there are actually twice this many points used.

 o setFieldColor
public void setFieldColor(Color fieldColor)
Sets the color to be used for the slope field.

 o setSlopeRadius
public void setSlopeRadius(int slopeRadius)
Sets the radius in pixels to be used in drawing the line segments for the slope field. Will not allow a value that is not positive.

 o setXDerivative
public void setXDerivative(String xDerivative) throws Graphable_error
Sets the formula for g(x,y) to be used in the differential equation x'=g(x,y).

Throws: Graphable_error
 o setYDerivative
public void setYDerivative(String yDerivative) throws Graphable_error
Sets the formula for f(x,y) to be used in the differential equation y'=f(x,y).

Throws: Graphable_error
 o toString
public java.lang.String toString()
Gives a String description of the coordinate system

Overrides:
toString in class MathGrid

All Packages  Class Hierarchy  This Package  Previous  Next  Index