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
-
dataPoints
- This is a Vector of points.
-
eulerDelta
- This is the delta that is used in Euler's approximation
to get the next point.
-
eulerGraphColor
- This determines the color that will be used to draw the
graph that approximates the solution.
-
eulerMouseEnabled
- When this is true the user will be able to add a data
point by clicking on the slope field with the mouse.
-
eulerPointNumber
- This determines the number of iterations to be used when
graphing an approximation according to Euler's method.
-
fieldColor
- This is the color to be used to draw the slope field
The default color is black.
-
slopeRadius
- This determines the length in pixels of the line
segments used to show the slope field.
-
xDerivative
- This is the formula that is used for the derivative of
x.
-
yDerivative
- This is the formula that is used for the derivative of
y in the differential equation.
-
EDU.emporia.mathbeans.SlopeField()
-
-
addDataPoint(Point2D.Double)
- Adds a dataPoint to be used to generate an Euler
approximation.
-
addDataPoint(double, double)
- Another version of the addDataPoint method that accepts
the coordinates of the point to be added.
-
getEulerDelta()
- Gets the increment that will be used in drawing the
graph of an approximate solution using Euler's method.
-
getEulerGraphColor()
- Gets the color used for drawing the graph of the
approximate solutions.
-
getEulerPointNumber()
- Gets the number of iterations to be used in drawing
an approximate graph using Euler's method.
-
getFieldColor()
- Gets the color to be used for the slope field.
-
getSlopeRadius()
- Gets the radius (in pixels) to be used in drawing the
line segments for the slope fields.
-
getXDerivative()
- Gets the formula g(x,y) to be used in the differential
equation y'=g(x,y)
-
getYDerivative()
- Gets the formula to be used in the differential equatio
y'=f(x,y).
-
isEulerMouseEnabled()
- Gets the value of the variable eulerMouseEnabled.
-
main(String[])
-
-
paintComponent(Graphics)
- Paints the Grid
-
removeAllDataPoints()
- Clears all points from the Slope Field.
-
removeDataPoint(Point2D.Double)
- Removes a point from the Vector.
-
setEulerDelta(double)
- Sets the increment that will be used in Euler's method
when drawing the graph of an approximate solution.
-
setEulerGraphColor(Color)
- Sets the color used for the approximate solutions.
-
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.
-
setEulerPointNumber(int)
- Sets the number of iterations that will be used in
drawing a graph using Euler's method.
-
setFieldColor(Color)
- Sets the color to be used for the slope field.
-
setSlopeRadius(int)
- Sets the radius in pixels to be used in drawing the
line segments for the slope field.
-
setXDerivative(String)
- Sets the formula for g(x,y) to be used in the
differential equation x'=g(x,y).
-
setYDerivative(String)
- Sets the formula for f(x,y) to be used in the differential
equation y'=f(x,y).
-
toString()
- Gives a String description of the coordinate system
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.
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
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.
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.
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.
fieldColor
protected java.awt.Color fieldColor
- This is the color to be used to draw the slope field
The default color is black.
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.
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.
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.
SlopeField
public SlopeField()
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
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.
getEulerDelta
public double getEulerDelta()
- Gets the increment that will be used in drawing the
graph of an approximate solution using Euler's method.
getEulerGraphColor
public java.awt.Color getEulerGraphColor()
- Gets the color used for drawing the graph of the
approximate solutions.
getEulerPointNumber
public int getEulerPointNumber()
- Gets the number of iterations to be used in drawing
an approximate graph using Euler's method.
getFieldColor
public java.awt.Color getFieldColor()
- Gets the color to be used for the slope field.
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.
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)
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)
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.
main
public static void main(String[] argv)
paintComponent
public void paintComponent(Graphics g)
- Paints the Grid
- Overrides:
- paintComponent in class MathGrapher
removeAllDataPoints
public void removeAllDataPoints()
- Clears all points from the Slope Field.
removeDataPoint
public void removeDataPoint(EDU.emporia.mathtools.Point2D.Double p)
- Removes a point from the Vector.
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.
setEulerGraphColor
public void setEulerGraphColor(Color eulerGraphColor)
- Sets the color used for the approximate solutions.
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.
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.
setFieldColor
public void setFieldColor(Color fieldColor)
- Sets the color to be used for the slope field.
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.
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
-
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
-
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