net.sourceforge.webcompmath.draw
Class Graph1D

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

public class Graph1D
extends Drawable
implements Computable

A Graph1D represents the graph of a function of one variable, to be displayed in a given CoordinateRect. A Graph1D is a Computable. The data for the graph is recomputed when its compute() method is called. It will also be re- computed, before it is drawn, if the coordinate rect has changed in some way.

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
 
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
Graph1D()
          Create a Graph1D with no function to graph.
Graph1D(Function func)
          Create a graph of the specified function.
 
Method Summary
 void compute()
          Recompute data for the graph and make sure that the area of the display canvas that shows the graph is redrawn.
 void draw(java.awt.Graphics g, boolean coordsChanged)
          Draw the graph (possibly recomputing the data if the CoordinateRect has changed).
 java.awt.Color getColor()
          Get the color that is used to draw the graph.
 Function getFunction()
          Get the (possibly null) function whose graph is drawn.
 float getLineWidth()
          Get the line width
 boolean isDashed()
          Get whether or not to use dashed style
 boolean isInverse()
          Get whether to invert the graph.
 void setColor(java.awt.Color c)
          Set the color to be used for drawing the graph.
 void setDashed(boolean d)
          Set whether or not to use dashed style
 void setFunction(Function f)
          Set the function to be graphed.
 void setInverse(boolean inverse)
          Set whether to invert the graph
 void setLineWidth()
          setter of thickness of graph test pkhg 050422
 void setLineWidth(float thickness)
          Setter for thickness of graph, only between 0.0f and 10.0f.
 void setVariableInput(VariableInput varThickness)
          to make thicknes of graph variable with the help of an VariableInput
 void setWithDash()
          Deprecated. 
 void setWithoutDash()
          Deprecated. 
 
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
 

Constructor Detail

Graph1D

public Graph1D()
Create a Graph1D with no function to graph. One can be set later with setFunction();


Graph1D

public Graph1D(Function func)
Create a graph of the specified function.

Parameters:
func - The function to be graphed. If func is null, nothing is drawn. If func is non-null, it must be a function of one variable.
Method Detail

setColor

public void setColor(java.awt.Color c)
Set the color to be used for drawing the graph. The default color is magenta.

Parameters:
c - graph color

getColor

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

Returns:
graph color

setFunction

public void setFunction(Function f)
Set the function to be graphed. If it is null, nothing is drawn. If it is non-null, it must be a function of one variable, or an error will occur.

Parameters:
f - function to graph

getFunction

public Function getFunction()
Get the (possibly null) function whose graph is drawn.

Returns:
function to graph

compute

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

Specified by:
compute in interface Computable

setVariableInput

public void setVariableInput(VariableInput varThickness)
to make thicknes of graph variable with the help of an VariableInput

Parameters:
varThickness - the variableInput to use

setLineWidth

public void setLineWidth()
setter of thickness of graph test pkhg 050422


setLineWidth

public void setLineWidth(float thickness)
Setter for thickness of graph, only between 0.0f and 10.0f. If set to 0, the thinnest possible line is drawn.

Parameters:
thickness -

getLineWidth

public float getLineWidth()
Get the line width

Returns:
line width as a float

setWithDash

@Deprecated
public void setWithDash()
Deprecated. 

to set a (fixed) dash


setWithoutDash

@Deprecated
public void setWithoutDash()
Deprecated. 

to clear dashing


isDashed

public boolean isDashed()
Get whether or not to use dashed style

Returns:
true for dashed

setDashed

public void setDashed(boolean d)
Set whether or not to use dashed style

Parameters:
d - true for dashed

draw

public void draw(java.awt.Graphics g,
                 boolean coordsChanged)
Draw the graph (possibly recomputing the data if the CoordinateRect has changed). This is not usually called directly.

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

isInverse

public boolean isInverse()
Get whether to invert the graph.

Returns:
true for inverse

setInverse

public void setInverse(boolean inverse)
Set whether to invert the graph

Parameters:
inverse - true for inverse