net.sourceforge.webcompmath.draw
Class Sequence

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

public class Sequence
extends Drawable
implements Computable

A Sequence is like a Graph1D, except that only integer values of the independent variable are used, and discrete points are plotted.

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 CIRCLE
          Circle shape
protected  int lineWidth
          The width, in pixels, of the outlines of the symbols.
static int SQUARE
          Square shape
 
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
Sequence()
          Construct a Sequence object that initially has nothing to draw.
Sequence(Function f, Value lower, Value upper, int shape)
          Construct a new Sequence object.
 
Method Summary
 void compute()
          This is generally called by a Controller.
 void draw(java.awt.Graphics g, boolean coordsChanged)
          Draw the Sequence.
 java.awt.Color getFillColor()
          Get the fill color
 Function getFuction()
          Returns the function whose sequence is computed.
 int getLineWidth()
          Get the width, in pixels, of outlines that are drawn.
 java.awt.Color getOutlineColor()
          Get the (positive) color that is used to draw outlines around the symbols.
 int getShape()
          Get the shape for the symbols.
 float getSymbolSize()
          Get the size in pixels.
 Value getValueObject()
          Gets a Value object that gives the value of the partial sum for the sequence.
 Value getXMax()
          Get the max x value
 Value getXMin()
          Get the min x value
 void setFillColor(java.awt.Color fillColor)
          Set the fill color.
 void setFunction(Function func)
          Set the function whose sequence is to be computed.
 void setLineWidth(int width)
          Set the width, in pixels, of outlines.
 void setOutlineColor(java.awt.Color c)
          Set the color that will be used to draw outlines around the symbols.
 void setShape(int shape)
          Set the shape for the symbols.
 void setSymbolSize(float size)
          Set the size in pixels.
 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

lineWidth

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


CIRCLE

public static final int CIRCLE
Circle shape

See Also:
Constant Field Values

SQUARE

public static final int SQUARE
Square shape

See Also:
Constant Field Values
Constructor Detail

Sequence

public Sequence()
Construct a Sequence object that initially has nothing to draw.


Sequence

public Sequence(Function f,
                Value lower,
                Value upper,
                int shape)
Construct a new Sequence object.

Parameters:
f - a Function object used to generate the sequence. If null, nothing is drawn.
lower - the lower limit
upper - the upper limit
shape - the shape to use for symbols
Method Detail

getShape

public int getShape()
Get the shape for the symbols.

Returns:
the shape

setShape

public void setShape(int shape)
Set the shape for the symbols. The default is CIRCLE.

Parameters:
shape - the shape to set

setOutlineColor

public void setOutlineColor(java.awt.Color c)
Set the color that will be used to draw outlines around the symbols. If this is null, then no outlines are drawn. The default is black.

Parameters:
c - outline color

getOutlineColor

public java.awt.Color getOutlineColor()
Get the (positive) color that is used to draw outlines around the symbols. If this is null, then no outlines are drawn.

Returns:
outline color

getFillColor

public java.awt.Color getFillColor()
Get the fill color

Returns:
the fillColor

setFillColor

public void setFillColor(java.awt.Color fillColor)
Set the fill color.

Parameters:
fillColor - the fillColor to set

setFunction

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

Parameters:
func - function

getFuction

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

Returns:
function

setLineWidth

public void setLineWidth(int width)
Set the width, in pixels, of outlines. Must be between 0 and 10. If set to 0, the thinnest possible line is drawn.

Parameters:
width - line width

getLineWidth

public int getLineWidth()
Get the width, in pixels, of outlines 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

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 null, 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 null, 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 Sequence. 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 partial sum for the sequence.

Returns:
a Value object representing the sum for

getSymbolSize

public float getSymbolSize()
Get the size in pixels.

Returns:
the size

setSymbolSize

public void setSymbolSize(float size)
Set the size in pixels. This is the height and width of the sqaure box that just contains a symbol. For a circle it is the diameter. For a square it is the side length. The default is 5.

Parameters:
size - the size to set