net.sourceforge.webcompmath.draw
Class RiemannArcLength

java.lang.Object
  extended by java.awt.Component
      extended by net.sourceforge.webcompmath.draw.Drawable
          extended by net.sourceforge.webcompmath.draw.RiemannArcLength
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, Computable
Direct Known Subclasses:
WCMRiemannArcLengthBean

public class RiemannArcLength
extends Drawable
implements Computable

A RiemannArcLength displays segments used in computing the length of a curve. It supports standard functions as well as parametric and polar curves.

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
protected  int lineWidth
          The width, in pixels, of the line segments.
static int PARAMETRIC
          Type of curve is a parametric curve
static int POLAR
          Type of curve is a polar curve
static int STANDARD
          Type of curve is a standard function
 
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
RiemannArcLength()
          Construct a RiemannArcLength object that initially has nothing to draw and that is set up to use the default number of intervals, 5.
RiemannArcLength(Function f, Function f2, Value i, int type)
          Construct a new RiemannArcLength object
RiemannArcLength(Function f, Value i, int type)
          Construct a new RiemannArcLength object.
 
Method Summary
 void compute()
          This is generally called by a Controller.
 void draw(java.awt.Graphics g, boolean coordsChanged)
          Draw the Riemann arc segments.
 java.awt.Color getColor()
          Get the current (positive) color used to draw the line segments
 Function getFuction()
          Returns the function whose arc length is computed.
 Function getFuction2()
          Returns the second function.
 Value getIntervalCount()
          Get the number of intervals used.
 int getLineWidth()
          Get the width, in pixels, of lines that are drawn.
 int getType()
          Get the type.
 Value getValueObject()
          Gets a Value object that gives the value of the Riemann arc length
 Value getXMax()
          Get the max x value
 Value getXMin()
          Get the min x value
 boolean isInverse()
          Get whether to display inverse version
 void setColor(java.awt.Color c)
          Set the color used to draw the line segments.
 void setFunction(Function func)
          Set the function whose arc length is to be computed.
 void setFunction2(Function func)
          Set the second function, used to specify the y function when computing the arc length of a parametric curve.
 void setIntervalCount(Value c)
          Set the interval count (the RiemannArcLength will be redrawn after this function is called).
 void setInverse(boolean inverse)
          Set whether to show as inverse
 void setLineWidth(int width)
          Set the width, in pixels, of lines that are drawn.
 void setType(int type)
          Set the type, one of STANDARD, PARAMETRIC, or POLAR
 void setXMax(Value max)
          Set the max x value.
 void setXMin(Value min)
          Set the min x value.
 
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

STANDARD

public static final int STANDARD
Type of curve is a standard function

See Also:
Constant Field Values

PARAMETRIC

public static final int PARAMETRIC
Type of curve is a parametric curve

See Also:
Constant Field Values

POLAR

public static final int POLAR
Type of curve is a polar curve

See Also:
Constant Field Values

lineWidth

protected int lineWidth
The width, in pixels, of the line segments. It is restricted to being an integer in the range from 0 to 10. A value of 0 means that lines won't be drawn at all.

Constructor Detail

RiemannArcLength

public RiemannArcLength()
Construct a RiemannArcLength object that initially has nothing to draw and that is set up to use the default number of intervals, 5.


RiemannArcLength

public RiemannArcLength(Function f,
                        Value i,
                        int type)
Construct a new RiemannArcLength object.

Parameters:
i - a Value object representing the number of intervals. If null, five intervals are used.
f - a Function object used to derive the Riemann arc length. If null, nothing is drawn.
type - one of STANDARD, PARAMETRIC, or POLAR

RiemannArcLength

public RiemannArcLength(Function f,
                        Function f2,
                        Value i,
                        int type)
Construct a new RiemannArcLength object

Parameters:
f - a Function object used to derive the Riemann arc length. If null, nothing is drawn.
f2 - the second function
i - a Value object representing the number of intervals. If null, five intervals are used. *
type - one of STANDARD, PARAMETRIC, or POLAR
Method Detail

getColor

public java.awt.Color getColor()
Get the current (positive) color used to draw the line segments

Returns:
rectangle color

setColor

public void setColor(java.awt.Color c)
Set the color used to draw the line segments. The default color is a light yellow.

Parameters:
c - rectangle color

setFunction

public void setFunction(Function func)
Set the function whose arc length is to be computed. For parametric curves this is the x function. If null, nothing is drawn. The function, if non-null, must have arity 1, or an IllegalArgumentException is thrown.

Parameters:
func - function to computer Riemann sum for

getFuction

public Function getFuction()
Returns the function whose arc length is computed. Can be null.

Returns:
function to computer Riemann sum for

setFunction2

public void setFunction2(Function func)
Set the second function, used to specify the y function when computing the arc length of a parametric curve. The function, if non-null, must have arity 1, or an IllegalArgumentException is thrown.

Parameters:
func - second function

getFuction2

public Function getFuction2()
Returns the second function. Can be null.

Returns:
second function

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

compute

public void compute()
This is generally called by a Controller. Indicates that all data should be recomputed because input values that the data depends on might have changed.

Specified by:
compute in interface Computable

getIntervalCount

public Value getIntervalCount()
Get the number of intervals used.

Returns:
a Value object representing the number of intervals

setIntervalCount

public void setIntervalCount(Value c)
Set the interval count (the RiemannArcLength will be redrawn after this function is called). The value will be clamped to be a value between 1 and 5000. If the value is null, the default number of intervals, five, is used.

Parameters:
c - a Value object representing the interval count

getXMax

public Value getXMax()
Get the max x value

Returns:
Returns the xMax.

setXMax

public void setXMax(Value max)
Set the max x value. If Double.NaN, then use the current xMax of the graph

Parameters:
max - The xMax to set.

getXMin

public Value getXMin()
Get the min x value

Returns:
Returns the xMin.

setXMin

public void setXMin(Value min)
Set the min x value. If Double.NaN, then use the current xMin of the graph

Parameters:
min - The xMin to set.

draw

public void draw(java.awt.Graphics g,
                 boolean coordsChanged)
Draw the Riemann arc segments. This is generally called by an object of class CoordinateRect

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

getValueObject

public Value getValueObject()
Gets a Value object that gives the value of the Riemann arc length

Returns:
a Value object representing the sum for the given method integer stating the method used to derive the sum; one of the constants LEFTENDPOINT, RIGHTENDPOINT, MIDPOINT, CIRCUMSCRIBED, INSCRIBED, TRAPEZOID, or CURRENT_METHOD.

isInverse

public boolean isInverse()
Get whether to display inverse version

Returns:
true if inverse

setInverse

public void setInverse(boolean inverse)
Set whether to show as inverse

Parameters:
inverse - true for inverse

getType

public int getType()
Get the type.

Returns:
the type

setType

public void setType(int type)
Set the type, one of STANDARD, PARAMETRIC, or POLAR

Parameters:
type - the type to set