|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.hws.jcm.draw.Drawable
edu.hws.jcm.draw.Graph1D
public class Graph1D
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 recomputed, before it is drawn, if the coordinate rect has changed in some way.
Field Summary |
---|
Fields inherited from class edu.hws.jcm.draw.Drawable |
---|
canvas, coords |
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. |
void |
setColor(java.awt.Color c)
Set the color to be used for drawing the graph. |
void |
setFunction(Function f)
Set the function to be graphed. |
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 |
Constructor Detail |
---|
public Graph1D()
public Graph1D(Function func)
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 |
---|
public void setColor(java.awt.Color c)
public java.awt.Color getColor()
public void setFunction(Function f)
public Function getFunction()
public void compute()
compute
in interface Computable
public void draw(java.awt.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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |