|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component net.sourceforge.webcompmath.draw.Drawable net.sourceforge.webcompmath.draw.VectorField
public class 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."
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 | |
---|---|
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. |
protected int |
lineWidth
The width, in pixels, of 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 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 | |
---|---|
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 equal-length 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 |
getLineWidth()
Get the width, in pixels, of lines that are drawn. |
int |
getPixelSpacing()
Get the value of the pixelSpacing property, which determines the grid spacing for the vector field. |
double |
getRealXSpacing()
Get the value of the realXSpacing property, which determines the grid spacing for the vector field in the x direction. |
double |
getRealYSpacing()
Get the value of the realYSpacing property, which determines the grid spacing for the vector field in the x direction. |
int |
getStyle()
Get the style in which the vector field is displayed. |
Function |
getXFunction()
Get the (possibly null) function that gives the x-component of the vector field. |
Function |
getYFunction()
Get the (possibly null) function that gives the y-component 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 |
setLineWidth(int width)
Set the width, in pixels, of lines that are drawn. |
void |
setPixelSpacing(int spacing)
Set the value of the pixelSpacing property, which determines the grid spacing for the vector field. |
void |
setRealXSpacing(double realXSpacing)
Set the value of the realXSpacing property, which determines the grid spacing for the vector field in the x direction. |
void |
setRealYSpacing(double realYSpacing)
Set the value of the realYSpacing property, which determines the grid spacing for the vector field in the x direction. |
void |
setStyle(int style)
Set the style in which the vector field is displayed. |
void |
setXFunction(Function dx)
Set the function that gives the x-component of the vector field. |
void |
setYFunction(Function dy)
Set the function that gives the y-component of the vector field. |
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 |
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
protected int lineWidth
Constructor Detail |
---|
public VectorField()
public VectorField(Function xFunc, Function yFunc)
xFunc
- A Function of two variables giving the x-component of the
vector field. If this is null, then nothing will be drawn.yFunc
- A Function of two variables giving the y-component of the
vector field. If this is null, then nothing will be drawn.public VectorField(Function xFunc, Function yFunc, int style)
xFunc
- A Function of two variables giving the x-component of the
vector field. If this is null, then nothing will be drawn.yFunc
- A Function of two variables giving the y-component 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 equal-lenth
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)
c
- field line colorpublic java.awt.Color getColor()
public void setFunctions(Function dx, Function dy)
dx
- function that gives the x-component of the vector fielddy
- function that gives the y-component of the vector fieldpublic void setXFunction(Function dx)
dx
- function that gives the x-component of the vector fieldpublic void setYFunction(Function dy)
dy
- function that gives the y-component of the vector fieldpublic Function getXFunction()
public Function getYFunction()
public int getStyle()
public void setStyle(int style)
style
- vector field style constantpublic int getPixelSpacing()
public void setPixelSpacing(int spacing)
spacing
- pixel spacingpublic double getRealXSpacing()
public void setRealXSpacing(double realXSpacing)
realXSpacing
- the real spacingpublic double getRealYSpacing()
public void setRealYSpacing(double realYSpacing)
realYSpacing
- the real spacingpublic void setLineWidth(int width)
width
- line widthpublic int getLineWidth()
public void compute()
compute
in interface Computable
public void draw(java.awt.Graphics g, boolean coordsChanged)
draw
in class Drawable
g
- graphics contextcoordsChanged
- true or false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |