|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component net.sourceforge.webcompmath.draw.Drawable net.sourceforge.webcompmath.draw.RiemannSumRects
public class RiemannSumRects
A RiemannSumRects calculates a Riemann sum for a function. It implements Computable and InputObject. You can specify and change the number of intervals in the sum, as well as the method used to calculate the sum. Functions exist to return Value objects for the sum using different computations. This class was written by Gabriel Weinstock, with some modifications by David Eck
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 |
CIRCLE_FRONT
Circle cross section with diameter along the base. |
static int |
CIRCLE_REAR
Circle cross section with diameter along the base. |
static int |
CIRCUMSCRIBED
Summation method type: circumscribed (maximum value on the rectangle's interval) |
static int |
CURRENT_METHOD
For use in getValueObject(), to indicate whatever summation method is currently set for drawing. |
static int |
EQUILATERAL
Equilateral triangle cross section with side along the base. |
static int |
INSCRIBED
Summation method type: inscribed (minimum value on the rectangle's interval) |
static int |
ISOSCELES_HYP
Right isosceles triangle cross section with hypotenuse along the base. |
static int |
ISOSCELES_LEG
Right isosceles triangle cross section with leg along the base. |
static int |
LEFTENDPOINT
Summation method type: left end point |
protected int |
lineWidth
The width, in pixels, of the outlines of the rects. |
static int |
MIDPOINT
Summation method type: mid point |
static int |
POLAR
Circular segment used for polar areas |
static int |
RECTANGLE
Rectangle (or trapezoid) shape |
static int |
RIGHTENDPOINT
Summation method type: right end point |
static int |
SEMICIRCLE
Semicircle cross section with diameter along the base. |
static int |
SQUARE_DIAG_FRONT
Square cross section with diagonal along the base. |
static int |
SQUARE_DIAG_REAR
Square cross section with diagonal along the base. |
static int |
SQUARE_SIDE
Square cross section with side along the base. |
static int |
TRAPEZOID
Summation method type: trapezoid |
static int |
WASHER_FRONT
Front half of washer |
static int |
WASHER_REAR
Rear half of washer |
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 | |
---|---|
RiemannSumRects()
Construct a RiemannSumRects object that initially has nothing to draw and that is set up to use the default number of intervals, 5. |
|
RiemannSumRects(Function f,
Function lf,
Value i)
Construct a new RiemannSumRects object. |
|
RiemannSumRects(Function f,
Value i)
Construct a new RiemannSumRects object. |
Method Summary | |
---|---|
void |
compute()
This is generally called by a Controller. |
void |
draw(java.awt.Graphics g,
boolean coordsChanged)
Draw the Rieman sum rects. |
java.awt.Color |
getColor()
Get the current (positive) color used to draw the rectangles |
Function |
getFuction()
Returns the function whose Riemann sums are computed. |
Value |
getIntervalCount()
Get the number of intervals used. |
int |
getLineWidth()
Get the width, in pixels, of lines that are drawn. |
Function |
getLowerFuction()
Returns the lower function. |
int |
getMethod()
Return the current method used to find the rectangle sums |
java.awt.Color |
getNegFillColor()
Get the negative fill color |
java.awt.Color |
getNegOutlineColor()
Get the negative outline color |
java.awt.Color |
getOutlineColor()
Get the (positive) color that is used to draw outlines around the rects. |
java.awt.Color |
getPosFillColor()
Get the positive fill color |
java.awt.Color |
getPosOutlineColor()
Get the positive outline color |
int |
getShape()
Get the shape for the Riemann sum. |
Value |
getValueObject(int which)
Gets a Value object that gives the value of the Riemann sum for the specified method. |
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 rectangles. |
void |
setFunction(Function func)
Set the function whose Riemann sums are to be computed. |
void |
setIntervalCount(Value c)
Set the interval count (the RiemannSumRects 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 |
setLowerFunction(Function func)
Set the lower function, when computing area between curves. |
void |
setMethod(int m)
Set the method used to calculate the rectangles. |
void |
setNegFillColor(java.awt.Color negFillColor)
Set the negative fill color. |
void |
setNegOutlineColor(java.awt.Color negOutlineColor)
Set the negative outline color. |
void |
setOutlineColor(java.awt.Color c)
Set the color that will be used to draw outlines around the rects. |
void |
setPosFillColor(java.awt.Color posFillColor)
Set the positive fill color |
void |
setPosOutlineColor(java.awt.Color posOutlineColor)
Set the positive outline color |
void |
setShape(int shape)
Set the shape for the Riemann sum. |
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 |
---|
protected int lineWidth
public static final int LEFTENDPOINT
public static final int RIGHTENDPOINT
public static final int MIDPOINT
public static final int CIRCUMSCRIBED
public static final int INSCRIBED
public static final int TRAPEZOID
public static final int CURRENT_METHOD
public static final int RECTANGLE
public static final int WASHER_FRONT
public static final int WASHER_REAR
public static final int SQUARE_SIDE
public static final int SQUARE_DIAG_FRONT
public static final int SQUARE_DIAG_REAR
public static final int SEMICIRCLE
public static final int CIRCLE_FRONT
public static final int CIRCLE_REAR
public static final int EQUILATERAL
public static final int ISOSCELES_HYP
public static final int ISOSCELES_LEG
public static final int POLAR
Constructor Detail |
---|
public RiemannSumRects()
public RiemannSumRects(Function f, Value i)
i
- a Value object representing the number of intervals. If null,
five intervals are used.f
- a Function object used to derive the Riemann sum. If null,
nothing is drawn.public RiemannSumRects(Function f, Function lf, Value i)
f
- a Function object used to derive the Riemann sum. If null,
nothing is drawn.lf
- the lower function, may be null to use the horizontal axisi
- a Value object representing the number of intervals. If null,
five intervals are used.Method Detail |
---|
public int getShape()
public void setShape(int shape)
shape
- the shape to setpublic java.awt.Color getColor()
public void setColor(java.awt.Color c)
c
- rectangle colorpublic void setOutlineColor(java.awt.Color c)
c
- outline colorpublic java.awt.Color getOutlineColor()
public java.awt.Color getNegFillColor()
public void setNegFillColor(java.awt.Color negFillColor)
negFillColor
- the negFillColor to setpublic java.awt.Color getNegOutlineColor()
public void setNegOutlineColor(java.awt.Color negOutlineColor)
negOutlineColor
- the negOutlineColor to setpublic java.awt.Color getPosFillColor()
public void setPosFillColor(java.awt.Color posFillColor)
posFillColor
- the posFillColor to setpublic java.awt.Color getPosOutlineColor()
public void setPosOutlineColor(java.awt.Color posOutlineColor)
posOutlineColor
- the posOutlineColor to setpublic void setFunction(Function func)
func
- function to computer Riemann sum forpublic Function getFuction()
public void setLowerFunction(Function func)
func
- lower functionpublic Function getLowerFuction()
public void setMethod(int m)
m
- can be: LEFTENDPOINT, RIGHTENDPOINT, MIDPOINT, CIRCUMSCRIBED,
INSCRIBED or TRAPEZOID (these are integers ranging from 0 to
5, respectively) TRAPEZOID is not valid for POLAR shapes.public int getMethod()
public void setLineWidth(int width)
width
- line widthpublic int getLineWidth()
public void compute()
compute
in interface Computable
public Value getIntervalCount()
public void setIntervalCount(Value c)
c
- a Value object representing the interval countpublic Value getXMax()
public void setXMax(Value max)
max
- The xMax to set.public Value getXMin()
public void setXMin(Value min)
min
- The xMin to set.public void draw(java.awt.Graphics g, boolean coordsChanged)
draw
in class Drawable
g
- graphics contextcoordsChanged
- true or falsepublic Value getValueObject(int which)
which
- integer stating the method used to derive the sum; one of the
constants LEFTENDPOINT, RIGHTENDPOINT, MIDPOINT,
CIRCUMSCRIBED, INSCRIBED, TRAPEZOID, or CURRENT_METHOD.
public boolean isInverse()
public void setInverse(boolean inverse)
inverse
- true for inverse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |