| java.lang.Object edu.hws.jcm.draw.Drawable edu.hws.jcm.functions.TableFunctionGraph
TableFunctionGraph | public class TableFunctionGraph extends Drawable implements MouseListener,MouseMotionListener(Code) | | A TableFunctionGraph is a Drawable object that can be added to a CoordinateRect (or DisplayCanvas).
It draws the graph of a specified TableFunction.
A TableFunction is a function and can also be graphed by an object of the class edu.hws.jcm.draw.Graph1D.
However, a TableFunctionGraph offers the option of showing the points from the table that defines
the function as small disks (true by default) and the option of making the graph "interactive" so
that the user can drag the points (false by default).
|
Method Summary | |
public void | draw(Graphics g, boolean coordsChanged) Override the draw() method from class Drawable to draw the function. | public Color | getColor() Get the non-null color that is used for drawing the graph. | public TableFunction | getFunction() Get the TableFunction whose graph is drawn by this TableFunctionGraph. | public boolean | getInteractive() Get the value of the interactive property, which is true if the user can
modify the function by dragging the points from the table. | public Computable | getOnDrag() Get the Computable that is notified as the user drags a point. | public Computable | getOnFinishDrag() Get the Computable that is notified when the user finishes dragging a point. | public boolean | getShowPoints() Get the showPoints property, which determines whether the points
from the table that defines the function are visible as little
disks. | public void | mouseClicked(MouseEvent evt) Empty method, required by the MouseListener interface. | public void | mouseDragged(MouseEvent evt) Method required by the MouseListener interface. | public void | mouseEntered(MouseEvent evt) Empty method, required by the MouseMotionListener interface. | public void | mouseExited(MouseEvent evt) Empty method, required by the MouseMotionListener interface. | public void | mouseMoved(MouseEvent evt) Empty method, required by the MouseMotionListener interface. | public void | mousePressed(MouseEvent evt) Method required by the MouseListener interface. | public void | mouseReleased(MouseEvent evt) Method required by the MouseListener interface. | public void | setColor(Color c) Set the color that is used for drawing the graph. | public void | setFunction(TableFunction function) Set the function whose graph is drawn by this TableFunctionGraph. | public void | setFunctionStyle(int style) Provided as a convenience. | public void | setInteractive(boolean interactive) Set the value of the interactive property, which is true if the user can
modify the function by dragging the points from the table. | public void | setOnDrag(Computable c) Specify a controller whose compute() method will be called repeatedly
as the user drags one of the points from the table function. | public void | setOnFinishDrag(Computable c) Specify a controller whose compute() method will be called once
when the user finishes dragging one of the points from the table function. | protected void | setOwnerData(DisplayCanvas canvas, CoordinateRect coords) Sets the values of member variables canvas and coords. | public void | setShowPoints(boolean show) Set the showPoints property, which determines whether the points
from the table that defines the function are visible as little
disks. |
TableFunctionGraph | public TableFunctionGraph()(Code) | | Create a TableFunctionGraph that initially draws no function. A function can be set
later with setFunction.
|
TableFunctionGraph | public TableFunctionGraph(TableFunction function)(Code) | | Create a TableFunctionGraph to draw the specified TableFunction.
|
draw | public void draw(Graphics g, boolean coordsChanged)(Code) | | Override the draw() method from class Drawable to draw the function.
This is not meant to be called directly.
|
getColor | public Color getColor()(Code) | | Get the non-null color that is used for drawing the graph.
|
getFunction | public TableFunction getFunction()(Code) | | Get the TableFunction whose graph is drawn by this TableFunctionGraph. If the value is null,
then no graph is drawn.
|
getInteractive | public boolean getInteractive()(Code) | | Get the value of the interactive property, which is true if the user can
modify the function by dragging the points from the table.
|
getOnDrag | public Computable getOnDrag()(Code) | | Get the Computable that is notified as the user drags a point.
|
getOnFinishDrag | public Computable getOnFinishDrag()(Code) | | Get the Computable that is notified when the user finishes dragging a point.
|
getShowPoints | public boolean getShowPoints()(Code) | | Get the showPoints property, which determines whether the points
from the table that defines the function are visible as little
disks.
|
mouseClicked | public void mouseClicked(MouseEvent evt)(Code) | | Empty method, required by the MouseListener interface.
|
mouseDragged | public void mouseDragged(MouseEvent evt)(Code) | | Method required by the MouseListener interface. Defined here to
support dragging of points on the function's graph. Not meant to be called directly.
|
mouseEntered | public void mouseEntered(MouseEvent evt)(Code) | | Empty method, required by the MouseMotionListener interface.
|
mouseExited | public void mouseExited(MouseEvent evt)(Code) | | Empty method, required by the MouseMotionListener interface.
|
mouseMoved | public void mouseMoved(MouseEvent evt)(Code) | | Empty method, required by the MouseMotionListener interface.
|
mousePressed | public void mousePressed(MouseEvent evt)(Code) | | Method required by the MouseListener interface. Defined here to
support dragging of points on the function's graph. Not meant to be called directly.
|
mouseReleased | public void mouseReleased(MouseEvent evt)(Code) | | Method required by the MouseListener interface. Defined here to
support dragging of points on the function's graph. Not meant to be called directly.
|
setColor | public void setColor(Color c)(Code) | | Set the color that is used for drawing the graph. The defalt is magenta.
If the specified Color value is null, the call to setColor is ignored.
|
setFunction | public void setFunction(TableFunction function)(Code) | | Set the function whose graph is drawn by this TableFunctionGraph. If the value is null,
nothing is drawn
|
setFunctionStyle | public void setFunctionStyle(int style)(Code) | | Provided as a convenience. If the function for this TableFunctionGraph is non-null,
its style is set to the specified style, and the graph is redrawn. The parameter
should be one of the constants TableFunction.SMOOTH, TableFunction.PIECEWISE_LINEAR,
TableFunction.STEP, TableFunction.STEP_LEFT, or TableFunction.STEP_RIGHT.
|
setInteractive | public void setInteractive(boolean interactive)(Code) | | Set the value of the interactive property, which is true if the user can
modify the function by dragging the points from the table. The default is false.
|
setOnDrag | public void setOnDrag(Computable c)(Code) | | Specify a controller whose compute() method will be called repeatedly
as the user drags one of the points from the table function. This only
applies if the "interactive" property is true.
|
setOnFinishDrag | public void setOnFinishDrag(Computable c)(Code) | | Specify a controller whose compute() method will be called once
when the user finishes dragging one of the points from the table function.
This only applies if the "interactive" property is true.
|
setOwnerData | protected void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)(Code) | | Sets the values of member variables canvas and coords. This is
designed to be called only by the CoordinateRect class. This overrides
Drawable.setOwnerData();
|
setShowPoints | public void setShowPoints(boolean show)(Code) | | Set the showPoints property, which determines whether the points
from the table that defines the function are visible as little
disks. The default is true;
|
|
|