public class TableFunctionGraph extends Drawable implements MouseListener, MouseMotionListener
Constructor and Description |
---|
TableFunctionGraph()
Create a TableFunctionGraph that initially draws no function.
|
TableFunctionGraph(TableFunction function)
Create a TableFunctionGraph to draw the specified TableFunction.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Graphics g,
boolean coordsChanged)
Override the draw() method from class Drawable to draw the function.
|
Color |
getColor()
Get the non-null color that is used for drawing the graph.
|
TableFunction |
getFunction()
Get the TableFunction whose graph is drawn by this TableFunctionGraph.
|
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.
|
Computable |
getOnDrag()
Get the Computable that is notified as the user drags a point.
|
Computable |
getOnFinishDrag()
Get the Computable that is notified when the user finishes dragging a point.
|
boolean |
getShowPoints()
Get the showPoints property, which determines whether the points
from the table that defines the function are visible as little
disks.
|
void |
mouseClicked(MouseEvent evt)
Empty method, required by the MouseListener interface.
|
void |
mouseDragged(MouseEvent evt)
Method required by the MouseListener interface.
|
void |
mouseEntered(MouseEvent evt)
Empty method, required by the MouseMotionListener interface.
|
void |
mouseExited(MouseEvent evt)
Empty method, required by the MouseMotionListener interface.
|
void |
mouseMoved(MouseEvent evt)
Empty method, required by the MouseMotionListener interface.
|
void |
mousePressed(MouseEvent evt)
Method required by the MouseListener interface.
|
void |
mouseReleased(MouseEvent evt)
Method required by the MouseListener interface.
|
void |
setColor(Color c)
Set the color that is used for drawing the graph.
|
void |
setFunction(TableFunction function)
Set the function whose graph is drawn by this TableFunctionGraph.
|
void |
setFunctionStyle(int style)
Provided as a convenience.
|
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.
|
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.
|
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.
|
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.
|
getVisible, needsRedraw, setVisible
public TableFunctionGraph()
public TableFunctionGraph(TableFunction function)
public void setFunction(TableFunction function)
public TableFunction getFunction()
public void setOnDrag(Computable c)
public Computable getOnDrag()
public void setOnFinishDrag(Computable c)
public Computable getOnFinishDrag()
public void setInteractive(boolean interactive)
public boolean getInteractive()
public void setShowPoints(boolean show)
public boolean getShowPoints()
public void setColor(Color c)
public Color getColor()
protected void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)
setOwnerData
in class Drawable
public void setFunctionStyle(int style)
public void draw(Graphics g, boolean coordsChanged)
draw
in class 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 void mousePressed(MouseEvent evt)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent evt)
mouseReleased
in interface MouseListener
public void mouseDragged(MouseEvent evt)
mouseDragged
in interface MouseMotionListener
public void mouseClicked(MouseEvent evt)
mouseClicked
in interface MouseListener
public void mouseEntered(MouseEvent evt)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent evt)
mouseExited
in interface MouseListener
public void mouseMoved(MouseEvent evt)
mouseMoved
in interface MouseMotionListener