

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object  +edu.hws.jcm.draw.Drawable  +edu.hws.jcm.draw.VectorField
A VectorField displays lines or arrows on a grid of points where the direction and/or lengths are given by two functions (f1(x,y),f2(x,y)). This is probably more useful as a "direction field" than as a "vector field."
Field Summary  
static int 
ARROWS
One of the possible styles for displaying a VectorField: as a direction field shown as arrows of equal length. 
static int 
CLAMPED_VECTORS
One of the possible styles for displaying a VectorField: as a vector field where a vector is shown as an arrow from (x,y) to (x+xFunc(x,y),y+xFunc(x,y)), except that a maximum length is imposed. 
static int 
LINES
One of the possible styles for displaying a VectorField: as a direction field shown as tangent lines. 
static int 
SCALED_LINES
One of the possible styles for displaying a VectorField: as a field of tangent lines where the length of the line is proportional to the length of the vector. 
static int 
SCALED_VECTORS
One of the possible styles for displaying a VectorField: as a vector field where a vector is shown as an arrow with length proportional to the length of the vector. 
Fields inherited from class edu.hws.jcm.draw.Drawable 
canvas, coords 
Constructor Summary  
VectorField()
Create a VectorField object with nothing to graph. 

VectorField(Function xFunc,
Function yFunc)
Create a VectorField that will be displayed using the default style, as a direction field of equallength arrows. 

VectorField(Function xFunc,
Function yFunc,
int style)
Create a VectorField with the specified functions and style. 
Method Summary  
void 
compute()
Recompute data for the vector field and make sure that the area of the display canvas that shows the vector field is redrawn. 
void 
draw(java.awt.Graphics g,
boolean coordsChanged)
Draw the vector field (possibly recomputing the data if the CoordinateRect has changed). 
java.awt.Color 
getColor()
Get the color that is used to draw the vector field. 
int 
getPixelSpacing()
Get the value of the pixelSpacing property, which determines the grid spacing for the vector field. 
int 
getStyle()
Get the style in which the vector field is displayed. 
Function 
getXFunction()
Get the (possibly null) function that gives the xcomponent of the vector field. 
Function 
getYFunction()
Get the (possibly null) function that gives the ycomponent of the vector field. 
void 
setColor(java.awt.Color c)
Set the color to be used for drawing the vector field. 
void 
setFunctions(Function dx,
Function dy)
Sets the functions that give the components of the vector field. 
void 
setPixelSpacing(int spacing)
Set the value of the pixelSpacing property, which determines the grid spacing for the vector field. 
void 
setStyle(int style)
Set the style in which the vector field is displayed. 
void 
setXFunction(Function dx)
Set the function that gives the xcomponent of the vector field. 
void 
setYFunction(Function dy)
Set the function that gives the ycomponent of the vector field. 
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 
Field Detail 
public static final int ARROWS
public static final int LINES
public static final int CLAMPED_VECTORS
public static final int SCALED_LINES
public static final int SCALED_VECTORS
Constructor Detail 
public VectorField()
public VectorField(Function xFunc, Function yFunc)
public VectorField(Function xFunc, Function yFunc, int style)
xFunc
 A Function of two variables giving the xcomponent of the vector field. If this
is null, then nothing will be drawn.yFunc
 A Function of two variables giving the ycomponent of the vector field. If this
is null, then nothing will be drawn.style
 The style in which the direction field is drawn. This can be one of the
constants ARROWS (a direction field of equallenth arrows), LINES (equal length lines),
CLAMPED_VECTORS (vectors drawn at actual length, unless too long), SCALED_VECTORS (vectors scaled so longest has
length equal to the grid spacing), or SCALED_LINES (lines scaled so longest has length
equal to the grid spacing).Method Detail 
public void setColor(java.awt.Color c)
public java.awt.Color getColor()
public void setFunctions(Function dx, Function dy)
public void setXFunction(Function dx)
public void setYFunction(Function dy)
public Function getXFunction()
public Function getYFunction()
public int getStyle()
public void setStyle(int style)
public int getPixelSpacing()
public void setPixelSpacing(int spacing)
public void compute()
compute
in interface Computable
public void draw(java.awt.Graphics g, boolean coordsChanged)
draw
in class Drawable
edu.hws.jcm.draw.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: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 