

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object  +edu.hws.jcm.draw.Drawable  +edu.hws.jcm.draw.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
Field Summary  
static int 
CIRCUMSCRIBED
Summation method type. 
static int 
CURRENT_METHOD
For use in getValueObject(), to indicate whatever summation method is currently set for drawing. 
static int 
INSCRIBED
Summation method type. 
static int 
LEFTENDPOINT
Summation method type. 
static int 
MIDPOINT
Summation method type. 
static int 
RIGHTENDPOINT
Summation method type. 
static int 
TRAPEZOID
Summation method type. 
Fields inherited from class edu.hws.jcm.draw.Drawable 
canvas, coords 
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,
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 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 
getMethod()
Return the current method used to find the rectangle sums 
java.awt.Color 
getOutlineColor()
Get the color that is used to draw outlines around the rects. 
Value 
getValueObject(int which)
Gets a Value object that gives the value of the Riemann sum for the specified method. 
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 
setMethod(int m)
Set the method used to calculate the rectangles. 
void 
setOutlineColor(java.awt.Color c)
Set the color that will be used to draw outlines around the rects. 
Methods inherited from class edu.hws.jcm.draw.Drawable 
getVisible, needsRedraw, setOwnerData, setVisible 
Methods inherited from class java.lang.Object 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 
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
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.Method Detail 
public java.awt.Color getColor()
public void setColor(java.awt.Color c)
public void setOutlineColor(java.awt.Color c)
public java.awt.Color getOutlineColor()
public void setFunction(Function func)
public Function getFuction()
public void setMethod(int m)
m
 can be: LEFTENDPOINT, RIGHTENDPOINT, MIDPOINT, CIRCUMSCRIBED,
INSCRIBED or TRAPEZOID (these are integers ranging from 0 to 5,
respectively)public int getMethod()
public void compute()
compute
in interface Computable
public Value getIntervalCount()
public void setIntervalCount(Value c)
c
 a Value object representing the interval countpublic void draw(java.awt.Graphics g, boolean coordsChanged)
draw
in class Drawable
edu.hws.jcm.draw.Drawable
g
 The graphics context in which the Drawble is to be drawn. (The drawing
can change the color in g, but should not permanently change font, painting mode, etc.
Thus, every drawable is responsible for setting the color it wants to use.)coordsChanged
 Indicates whether the CoordinateRect has changed.public 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.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 