net.sourceforge.webcompmath.draw.beans
Class WCMIntegralCurveBean

java.lang.Object
  extended by java.awt.Component
      extended by net.sourceforge.webcompmath.draw.Drawable
          extended by net.sourceforge.webcompmath.draw.beans.WCMIntegralCurveBean
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, Computable

public class WCMIntegralCurveBean
extends Drawable
implements Computable

An intergral curve draws a solution to a set of differential equations. You can use it with a vector field or by itself.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int DASHED_STYLE
          Specifies that the shape should be drawn with dashed line(s).
static int EULER
          Use Euler's method
protected  int lineStyle
          The line style, SOLID_STYLE or DASHED_STYLE
static int RK2
          Use Runge-Kutta 2
static int RK4
          Use Runge-Kutta 4
static int SOLID_STYLE
          Specifies that the shape should be drawn with solid line(s).
 
Fields inherited from class net.sourceforge.webcompmath.draw.Drawable
canvas, coords
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
WCMIntegralCurveBean()
          Create an integral curve object with a default graph.
WCMIntegralCurveBean(Function xFunc, Function yFunc, Value x, Value y, Value dt, int method, Value stepsMinus, Value stepsPlus)
          Create an integral curve with the specified functions and method.
 
Method Summary
 void compute()
          Recompute data for the integral curve and make sure that the area of the display canvas that shows the curve is redrawn.
 void draw(java.awt.Graphics g, boolean coordsChanged)
          Draw the curve (possibly recomputing the data if the CoordinateRect has changed).
 java.awt.Color getColor()
          Get the color that is used to draw the integral curve.
 Value getDeltaT()
          Get the delta T
 int getLineStyle()
          Get the line style, SOLID_STYLE or DASHED_STYLE
 int getLineWidth()
          Get the width, in pixels, of lines that are drawn.
 int getMethod()
          Get the method.
 Value getStepsMinus()
          Get the number of steps in the minus direction
 Value getStepsPlus()
          Get the number of steps in the positive direction
 Value getXCoord()
          Get the starting x coord
 Function getXFunction()
          Get the (possibly null) function that gives the x-component of the integral curve
 Value getYCoord()
          Get the starting y coordinate
 Function getYFunction()
          Get the (possibly null) function that gives the y-component of the vector field.
 void setColor(java.awt.Color c)
          Set the color to be used for drawing the integral curve.
 void setDeltaT(Value deltaT)
          Set the delta t
 void setFunctions(Function dx, Function dy)
          Sets the functions that give the components of the integral curve.
 void setLineStyle(int lineStyle)
          Set the line style, SOLID_STYLE or DASHED_STYLE
 void setLineWidth(int width)
          Set the width, in pixels, of lines that are drawn.
 void setMethod(int method)
          Set the method.This should be one of the constants EULER, RK2 or RK4
 void setStepsMinus(Value stepsMinus)
          Set the number of steps in the minus direction
 void setStepsPlus(Value stepsPlus)
          Set the number of steps in the positive direction
 void setXCoord(Value coord)
          Set the starting x coord
 void setXFunction(Function dx)
          Set the function that gives the x-component of the integral curve.
 void setYCoord(Value coord)
          Set the starting y coordinate
 void setYFunction(Function dy)
          Set the function that gives the y-component of the integral curve.
 
Methods inherited from class net.sourceforge.webcompmath.draw.Drawable
getVisible, needsRedraw, setOwnerData, setVisible
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EULER

public static final int EULER
Use Euler's method

See Also:
Constant Field Values

RK2

public static final int RK2
Use Runge-Kutta 2

See Also:
Constant Field Values

RK4

public static final int RK4
Use Runge-Kutta 4

See Also:
Constant Field Values

SOLID_STYLE

public static final int SOLID_STYLE
Specifies that the shape should be drawn with solid line(s). This is the default.

See Also:
Constant Field Values

DASHED_STYLE

public static final int DASHED_STYLE
Specifies that the shape should be drawn with dashed line(s).

See Also:
Constant Field Values

lineStyle

protected int lineStyle
The line style, SOLID_STYLE or DASHED_STYLE

Constructor Detail

WCMIntegralCurveBean

public WCMIntegralCurveBean()
Create an integral curve object with a default graph. The functions and other values can be changed later. The default method is EULER


WCMIntegralCurveBean

public WCMIntegralCurveBean(Function xFunc,
                            Function yFunc,
                            Value x,
                            Value y,
                            Value dt,
                            int method,
                            Value stepsMinus,
                            Value stepsPlus)
Create an integral curve with the specified functions and method.

Parameters:
xFunc - A Function of two variables giving the x-component of the integral curve. If this is null, then nothing will be drawn.
yFunc - A Function of two variables giving the y-component of the integral curve. If this is null, then nothing will be drawn.
x - the x coordinate of the starting point
y - the y coordinate of the starting point
dt - the delta t
method - one of EULER, RK2 or RK4
stepsMinus - steps in the negative direction
stepsPlus - steps in the positive direction
Method Detail

setColor

public void setColor(java.awt.Color c)
Set the color to be used for drawing the integral curve. The default color is light gray.

Parameters:
c - field line color

getColor

public java.awt.Color getColor()
Get the color that is used to draw the integral curve.

Returns:
field line color

setFunctions

public void setFunctions(Function dx,
                         Function dy)
Sets the functions that give the components of the integral curve. If either function is null, then nothing is drawn. If non-null, each function must be a function of two variables.

Parameters:
dx - function that gives the x-component of the integral curve
dy - function that gives the y-component of the integral curve

setXFunction

public void setXFunction(Function dx)
Set the function that gives the x-component of the integral curve. If this is null, then nothing is drawn. If non-null, it must be a function of two variables.

Parameters:
dx - function that gives the x-component of the integral curve

setYFunction

public void setYFunction(Function dy)
Set the function that gives the y-component of the integral curve. If this is null, then nothing is drawn. If non-null, it must be a function of two variables.

Parameters:
dy - function that gives the y-component of the integral curve

getXFunction

public Function getXFunction()
Get the (possibly null) function that gives the x-component of the integral curve

Returns:
function that gives the x-component of the integral curve

getYFunction

public Function getYFunction()
Get the (possibly null) function that gives the y-component of the vector field.

Returns:
function that gives the y-component of the integral curve

getMethod

public int getMethod()
Get the method.

Returns:
EULER, RK2 or RK4

setMethod

public void setMethod(int method)
Set the method.This should be one of the constants EULER, RK2 or RK4

Parameters:
method - method constant

setLineWidth

public void setLineWidth(int width)
Set the width, in pixels, of lines that are drawn. If set to 0, the thinnest possible line is drawn.

Parameters:
width - line width

getLineWidth

public int getLineWidth()
Get the width, in pixels, of lines that are drawn.

Returns:
line width

getLineStyle

public int getLineStyle()
Get the line style, SOLID_STYLE or DASHED_STYLE

Returns:
Returns the lineStyle.

setLineStyle

public void setLineStyle(int lineStyle)
Set the line style, SOLID_STYLE or DASHED_STYLE

Parameters:
lineStyle - The lineStyle to set.

getDeltaT

public Value getDeltaT()
Get the delta T

Returns:
Returns the deltaT.

setDeltaT

public void setDeltaT(Value deltaT)
Set the delta t

Parameters:
deltaT - The deltaT to set.

getXCoord

public Value getXCoord()
Get the starting x coord

Returns:
Returns the xCoord.

setXCoord

public void setXCoord(Value coord)
Set the starting x coord

Parameters:
coord - The xCoord to set.

getYCoord

public Value getYCoord()
Get the starting y coordinate

Returns:
Returns the yCoord.

setYCoord

public void setYCoord(Value coord)
Set the starting y coordinate

Parameters:
coord - The yCoord to set.

getStepsMinus

public Value getStepsMinus()
Get the number of steps in the minus direction

Returns:
the number of steps

setStepsMinus

public void setStepsMinus(Value stepsMinus)
Set the number of steps in the minus direction

Parameters:
stepsMinus - the number of steps

getStepsPlus

public Value getStepsPlus()
Get the number of steps in the positive direction

Returns:
the number of steps

setStepsPlus

public void setStepsPlus(Value stepsPlus)
Set the number of steps in the positive direction

Parameters:
stepsPlus - the number of steps

compute

public void compute()
Recompute data for the integral curve and make sure that the area of the display canvas that shows the curve is redrawn. This method is ordinarily called by a Controller.

Specified by:
compute in interface Computable

draw

public void draw(java.awt.Graphics g,
                 boolean coordsChanged)
Draw the curve (possibly recomputing the data if the CoordinateRect has changed).

Specified by:
draw in class Drawable
Parameters:
g - graphics context
coordsChanged - true or false