eField4
Class EField

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byedu.davidson.tools.SApplet
                      extended byeField4.EField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class EField
extends SApplet

EField is part of the Davidson College Physlets project. EField plots electric fields given a potential function and/or point charges. Both fixed charges and moving test charges can be specified using "add" methods.

The following embedding parameters are defined:

Parameter Value Data Type Description
FPS 10 double Frames per second during animation.
dt 0.1 double Animation time step per frame.
ShowControls true boolean Show VCR buttons at bottom of applet.
ShowContours true boolean Show equipotential contours.
ShowPoles true boolean Show fixed charges.
ShowLabels true boolean Add labels to contour lines.
ShowFieldLines false boolean Draw field lines. Computationally EXPENSIVE
ShowFieldVectors true boolean Draw direction arrows to represent field.
PointChargeMode true boolean Select between point charge and line charge mode.  Use 1/(r*r) dependence for fixed charge if true.  Use 1/r dependence if false.
PixPerUnit 10 double Conversion from pixel units to world units.
GridUnit 1.0 double The grid spacing.  A value of 0 will suppress the grid.
Potential 0 string The potential function, U(x,y).
Range -1,1,-1,1 string Approximate x and y coordinate range.  X range takes precedence to insure 1:1 aspect ratio. MUST be a string: "-1,1,-1,1"
GridSize 64   (Not Implemented.)

Various objects in EField implement the data source interface.  This interface, SDataSource, enables inter-applet data passing between Physlets.

Object Identifier Variables
Fixed Charges. The id is returned when an object is created using an add method.
id=addCharge(double x, double y, double m)
t, x, y, vx, vy, ax, ay, fx, fy, p, m, q
Note: p is the potential and q is the magnitude of the charge.
All shapes: circle, rectangle, box, etc. The id is returned when an object is created using an add method. t, x, y, vx, vy, ax, ay
clock id=getClockID() t

Methods to access the animation clock can be found in the superclass documentation, SApplet.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.davidson.tools.SApplet
destroyed
 
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
 
Method Summary
 int addBox(double x, double y, int width, int height)
          Adds a box.
 int addCharge(double x, double y, double q)
          Add a fixed charge.
 int addCircle(double x, double y, int radius)
          Adds a filled circle.
 int addImage(java.lang.String file, double x, double y)
          Adds an image to the animation.
 int addLineAnchor(int id, double x, double y)
          Adds a line from a point(x,y) to an object on the screen.
 int addObject(java.lang.String name, java.lang.String parList)
          Create an object and add it to the Physlet.
 int addPolyShape(int n, java.lang.String hStr, java.lang.String vStr, double x, double y)
          Adds a polygon to the animation.
 int addRectangle(double x, double y, int width, int height)
          Add a filled rectangle.
 int addRelPolyShape(int n, java.lang.String hStr, java.lang.String vStr, double x, double y)
          Add a polygon to the animation.
 int addShell(double x, double y, int radius)
          Adds a spherical shell.
 int addSpringAnchor(int id, double x, double y)
          Adds a spring from a point(x,y) to an object on the screen.
 int addTestCharge(double x, double y, double vx, double vy)
          Adds a test charge.
 void clearSeries(int s)
          Clear the data from a graph series.
 void deleteCharges()
          Deletes the fixed charges.
 void deleteDataConnection(int id)
          Break the data connection identified by the id.
 void deleteDataConnections()
          Break all data connections.
 void deleteObject(int id)
          Delete an object from the applet.
 void deleteSeries(int s)
          Delete a series from the graph
 void deleteTestCharges()
          Deletes the test charges.
 void forward()
          Resume the simulation with a positive time step.
 int getCollisionID()
          Gets the id for collisions.
 int getGraphID()
          Gets the series ID for the graph object.
 int getSeriesID(int sid)
          Gets the series ID, that is the hashcode, from a series number.
 double getTime()
          Gets the y velocity of an object.
 double getVX(int id)
          Gets the x velocity of an object.
 double getVY(int id)
          Gets the y velocity of an object.
 double getX(int id)
          Gets the x position of an object.
 double getXPos(int id)
          Bug-fix to get the x of an object on Netscape and Sun.
 double getY(int id)
          Gets the y position of an object.
 double getYPos(int id)
          Bug-fix to get the y of an object on Netscape and Sun.
 int makeDataConnection(int sourceID, int listenerID, int seriesID, java.lang.String xStr, java.lang.String yStr)
          Make a data connection between a data source, i.e. a charge, and a data listener.
 void pause()
          Pause the simulation
 void reset()
          Reset the initial conditions at time t=0.
 void reverse()
          Resume the simulation with a negative time step.
 boolean set(int id, java.lang.String name, java.lang.String parList)
          Change the properies of an object.
 boolean setAnimationSlave(int masterID, int slaveID)
          Force an object to follow another object on the screen.
 void setAutoRefresh(boolean ar)
          Repaint whenevers the system parameters are changed.
 void setBz(double bz)
          Sets the z component of the magnetic field.
 void setCaption(java.lang.String c)
          Sets the caption.
 void setChargeLabel(java.lang.String l)
          Sets the charge label.
 boolean setChargeMagnitude(int id, double mag)
          Sets the magnitude for a charge.
 void setChargeRGB(int r, int g, int b)
          Sets the color for new charges.
 void setChargeTrail(int t)
          Sets the animation the default trail length.
 void setCollisionMessage(java.lang.String msg)
          Display a message in the yellow message box.
 boolean setConstrainR(int id, double r, double x, double y)
          Constrain the motion of the test charges to a circular path.
 boolean setConstraintStr(int id, java.lang.String str, double xmin, double xmax)
          Constrain the motion of the test charges to a path given my F(x).
 boolean setConstrainX(int id, double x, double xmin, double xmax)
          Constrain the motion of the test charges to a path of constant x.
 boolean setConstrainY(int id, double y, double ymin, double ymax)
          Constrain the motion of the test charges to a path of constant y.
 boolean setDamping(int id, double d)
          Sets the color for an object.
 void setDampOnMousePressed(boolean damp)
          Sets the velocity of an object to zero if it is being dragged.
 void setDefault()
          Sets the default conditions.
 boolean setDisplayOffset(int id, int xOff, int yOff)
          Offset the object's position on the screen from its default drawing position.
 void setDrag(boolean drag)
          Sets drag for all subsequently created charges.
 boolean setDragable(int id, boolean drag)
          Make the object with the given id dragable.
 void setFieldResolution(int r)
          Sets the field resolution determines how the spacing of the field vectors on the grid.
 boolean setFont(int id, java.lang.String family, int style, int size)
          change the object's font for any text that is displayed.
 boolean setFootPrints(int id, int n)
          Sets the trail to leave footprints as the charge moves.
 boolean setFormat(int id, java.lang.String fstr)
          Change the object's format for the display of numeric data.
 boolean setGhost(int id, boolean ghost)
          Have the charge draw ghost images as it moves.
 void setGridSize(int n)
          Sets the grid size for the evaluation of the potential energy.
 void setHideCharge(boolean hc)
          Hide all charges.
 boolean setLabel(int id, java.lang.String label)
          Make the object label.
 boolean setMass(int id, double m)
          Sets the mass of an object.
 void setMaxTime(double max, java.lang.String msg)
          Stop the simulation at a predetermined time and display a message for the user.
 boolean setObjectFont(int id, java.lang.String family, int style, int size)
          Sets the object's font if the object has text that can be displayed.
 boolean setOnScreenSize(int id, int size)
          Sets the size for an object.
 void setPointChargeMode(boolean pcm)
          Sets point charge to produce 1/(r*r) field.
 void setPotential(java.lang.String ps, double xmin, double xmax, double ymin, double ymax)
          Sets the potential function.
 boolean setRGB(int id, int r, int g, int b)
          Sets the color for an object.
 void setSeriesRGB(int id, int r, int g, int b)
          Sets the series line and marker color.
 void setSeriesStyle(int id, boolean conPts, int m)
          Sets the series style for the graoh object.
 void setShowCharge(boolean sc)
          Display all fixed charges on the screen.
 void setShowConstraintPath(int id, boolean sc)
          Show a the constraint function that test particles must follow.
 void setShowContours(boolean sc)
          Show the contour lines.
 void setShowCoordOnDrag(boolean sc)
          Show the coordinates on a mouse drag.
 void setShowEOnDrag(boolean se)
          Show the field at the mouse postion on a mouse drag.
 void setShowEquipotentialOnClick(boolean sp)
          Draw equipotential starting at the mouse click.
 void setShowEquipotentialOnDoubleClick(boolean sp)
          Draw equipotential starting at the mouse double click.
 boolean setShowFComponents(int id, boolean sc)
          Enable the charge force vector to show components when it is drawn.
 void setShowFieldLineOnClick(boolean sfl)
          Draw a field line starting at the mouse click.
 void setShowFieldLineOnDoubleClick(boolean sfl)
          Draw a field line starting at the mouse double click.
 void setShowFieldLines(boolean sfl)
          Show the field lines.
 void setShowFieldVectors(boolean sfv)
          Show the direction field vectors.
 boolean setShowFOnDrag(int id, boolean sfm)
          Enable the charge to show the force magnitude in the message box.
 void setShowForce(boolean sf)
          Show the default to show the force vector on all subsequently created test charges.
 boolean setShowFVector(int id, boolean sf)
          Enable the charge to show the net force vector when it is drawn.
 void setShowLabels(boolean sl)
          Show the contour labels.
 void setShowTime(boolean st)
          Show the simulation time.
 boolean setShowVComponents(int id, boolean svc)
          Enable the charge velocity vector to show components when it is drawn.
 void setShowVelocity(boolean sv)
          Show the default to show the velocity vector on newly created test charges.
 void setShowVOnDrag(boolean sv)
          Show the potential at the mouse postion on a mouse drag.
 boolean setShowVVector(int id, boolean sv)
          Enable the charge to show the net velocity vector when it is drawn.
 int setSketchMode(boolean sketch)
          Enable sketching with the mouse.
 boolean setSpeed(int id, double speed)
          Change the speed of a test charge.
 boolean setSticky(int id, boolean isSticky)
          Make the object stickey so that collisions stop the animation.
 void setTimeContinuous()
          Let the simulation continue forever.
 void setTimeCycle(double max)
          Cycle the simulation
 void setTimeOneShot(double max, java.lang.String msg)
          Run the simulaiton one time.
 void setTimeVisibility(boolean visible)
          Enable the time display in the applet window.
 void setTolerance(double t)
          Sets the tolerance for the animation calculations.
 boolean setTrail(int id, int pts)
          Sets the trail behind a charge.
 boolean setTrajectory(int id, java.lang.String xStr, java.lang.String yStr)
          Sets the trajectory of a pole.
 boolean setVisibility(int id, boolean show)
          Show the visibility of the object.
 boolean setX(int id, double x)
          Sets the x position of an object.
 boolean setXPos(int id, double x)
           
 void setXRange(double xmin, double xmax)
          Sets the scale using the horizontal axis.
 boolean setXY(int id, double x, double y)
          Sets the position of an object.
 boolean setY(int id, double y)
          Sets the y position of an object.
 boolean setYPos(int id, double y)
           
 void setYRange(double ymin, double ymax)
           
 void setZColorScale(double colorScale)
          Sets the color scale on the vector field.
 void stepBack()
           
 void stepForward()
           
 void stepTimeBack()
          Step the simulation one negative time step.
 void stepTimeForward()
          Step the simulation one positive time step.
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, checkAppletNames, cleanupDataConnections, clearAllData, clearData, formatValue, getAppletName, getClockID, getClockTime, getDataFromDS, getDataListener, getDataSource, getDataSource, getDebugLevel, getID, getSourceData, getSourceVariables, isClockRunning, isValidFunction, removeDataListener, removeDataSource, sendDataToListener, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setConnectionWindowX, setConnectionWindowY, setDebugLevel, setDt, setExternalClock, setFPS, setIndependentClock, startClock, stepClock, stepTime, stop, stopClock, updateDataConnection, updateDataConnections
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getGraphID

public int getGraphID()
Gets the series ID for the graph object. This ID is used to make a connection to a SDataSource.


getCollisionID

public int getCollisionID()
Gets the id for collisions. This id can be used to access the collision as a data source.

Returns:
int The id of the ensemble containing all objects on the screen. Used as a data source.

getSeriesID

public int getSeriesID(int sid)
Gets the series ID, that is the hashcode, from a series number. Hash codes are unique object identifiers that are defind by the Java VM. Series numbers are 0,1,2,.......


setSeriesStyle

public void setSeriesStyle(int id,
                           boolean conPts,
                           int m)
Sets the series style for the graoh object.

Parameters:
id - The series id.
conPts - Connect the points?
m - Marker style. (m=1 is cross; m=2 is square, m=3 is circle)

deleteSeries

public void deleteSeries(int s)
Delete a series from the graph


clearSeries

public void clearSeries(int s)
Clear the data from a graph series. Series properties such as color and style remain unchanged.


getX

public double getX(int id)
Gets the x position of an object.

Parameters:
id - The id of the object.

getY

public double getY(int id)
Gets the y position of an object.

Parameters:
id - The id of the object.

getVX

public double getVX(int id)
Gets the x velocity of an object.

Parameters:
id - The id of the object.

getVY

public double getVY(int id)
Gets the y velocity of an object.

Parameters:
id - The id of the object.

getTime

public double getTime()
Gets the y velocity of an object.


addObject

public int addObject(java.lang.String name,
                     java.lang.String parList)
Create an object and add it to the Physlet. The first argument is the name of the object to be added and the second is a comma-delimited list of parameters. For example, a circle can be added a follows:

addObject ("circle", "x = 0, y = -1.0, r = 10");

See the supplemental documentation for a list of object names and parameters.

Parameters:
name - the type of object to be created.
parList - a list of parameters to be set
Returns:
id that identifies the object.

addTestCharge

public int addTestCharge(double x,
                         double y,
                         double vx,
                         double vy)
Adds a test charge. A test charge moves with F=E but does not effect the potentials or fields. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The xy position.
vx - The x velocity.
vy - The y velocity.
Returns:
An ID that identifies the charge.

addCharge

public int addCharge(double x,
                     double y,
                     double q)
Add a fixed charge. A fixed charge does not move but does effect the field and the potential at the test charges. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The y position.
q - The magnitude of the charge.
Returns:
An ID that identifies the charge.

addRectangle

public int addRectangle(double x,
                        double y,
                        int width,
                        int height)
Add a filled rectangle. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The y position.
width - The width of the rectangle in pixels.
height - The height of the rectangle in pixels.
Returns:
An ID that identifies the rectangle.

addBox

public int addBox(double x,
                  double y,
                  int width,
                  int height)
Adds a box. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The y position.
width - The width of the box in pixels.
height - The height of the box in pixels.
Returns:
An ID that identifies the box.

addLineAnchor

public int addLineAnchor(int id,
                         double x,
                         double y)
Adds a line from a point(x,y) to an object on the screen. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The y position.
Returns:
An ID that identifies the anchor.

addImage

public int addImage(java.lang.String file,
                    double x,
                    double y)
Adds an image to the animation. Looks for image in the code base, the document base, and absolute URL. This method is an alternative to the addObject method.

Parameters:
file - Location of image relative to the document containing the HTML page.

addSpringAnchor

public int addSpringAnchor(int id,
                           double x,
                           double y)
Adds a spring from a point(x,y) to an object on the screen. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The y position.
Returns:
An ID that identifies the anchor.

addCircle

public int addCircle(double x,
                     double y,
                     int radius)
Adds a filled circle. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The y position.
Returns:
An ID that identifies the circle.

addShell

public int addShell(double x,
                    double y,
                    int radius)
Adds a spherical shell. This method is an alternative to the addObject method.

Parameters:
x - The x position.
y - The y position.
Returns:
An ID that identifies the box.

addPolyShape

public int addPolyShape(int n,
                        java.lang.String hStr,
                        java.lang.String vStr,
                        double x,
                        double y)
Adds a polygon to the animation. The polygon can have an arbitrary number of points but the shape is fixed. The position can be a function of time. This method is an alternative to the addObject method.

Parameters:
n - The number of vertices in the polygon.
hStr - A comma separated list of the x postions of the vertices in pixel units. MUST BE A STRING.
vStr - A comma separated list of the y postions of the vertices in pixel units. MUST BE A STRING.
x - The x position of the base.
y - The y position of the base.
Returns:
The id of the shape.
See Also:
EField.addRectangle(double, double, int, int)

addRelPolyShape

public int addRelPolyShape(int n,
                           java.lang.String hStr,
                           java.lang.String vStr,
                           double x,
                           double y)
Add a polygon to the animation. The polygon can have an arbitrary number of points but the shape is fixed. Use relative postions for the vertices. This method is an alternative to the addObject method.

Parameters:
n - The number of vertices in the polygon.
hStr - A comma separated list of the x postions of the relative vertices in pixel units. MUST BE A STRING.
vStr - A comma separated list of the y postions of the relative vertices in pixel units. MUST BE A STRING.
x - The x position of the base.
y - The y position of the base.
Returns:
The id of the shape.
See Also:
EField.addRectangle(double, double, int, int)

deleteObject

public void deleteObject(int id)
Delete an object from the applet.

Parameters:
id - the object identifier
Returns:
true if successful

deleteTestCharges

public void deleteTestCharges()
Deletes the test charges.


deleteCharges

public void deleteCharges()
Deletes the fixed charges.


setDamping

public boolean setDamping(int id,
                          double d)
Sets the color for an object. Currently works for test charges and poles.

Parameters:
id - The ID of the object.
d - The damping coeficient in the rate equation. F_damp=-damping*velocity.
Returns:
True if successful.

setDefault

public void setDefault()
Sets the default conditions. Hide field lines. Hide vector field. Disable charge drag. Do not show test charge velocity. Do not show force on charge.

Overrides:
setDefault in class SApplet

setXRange

public void setXRange(double xmin,
                      double xmax)
Sets the scale using the horizontal axis. The leftmost pixel will be xmin. The rightmost pixel will be xmax. The vertical axis will be rescaled to maintian an aspect ratio of one.

Parameters:
xmin - Minimuum value on x axis.
xmax - Maximum value on x axis.

setYRange

public void setYRange(double ymin,
                      double ymax)

setZColorScale

public void setZColorScale(double colorScale)
Sets the color scale on the vector field.

Parameters:
colorScale -

getXPos

public double getXPos(int id)
Bug-fix to get the x of an object on Netscape and Sun.

Parameters:
id - The id of the object.
Returns:
true if successful

getYPos

public double getYPos(int id)
Bug-fix to get the y of an object on Netscape and Sun.

Parameters:
id - The id of the object.
Returns:
true if successful

setX

public boolean setX(int id,
                    double x)
Sets the x position of an object.

Parameters:
id - The ID of the object.
x - The x coordinate.

setXPos

public boolean setXPos(int id,
                       double x)

setY

public boolean setY(int id,
                    double y)
Sets the y position of an object.

Parameters:
id - The ID of the object.
y - The y coordinate.

setYPos

public boolean setYPos(int id,
                       double y)

setXY

public boolean setXY(int id,
                     double x,
                     double y)
Sets the position of an object.

Parameters:
id - The ID of the object.
x - The x coordinate.
y - The y coordinate.

setDrag

public void setDrag(boolean drag)
Sets drag for all subsequently created charges.

Parameters:
drag - Drag?

setDampOnMousePressed

public void setDampOnMousePressed(boolean damp)
Sets the velocity of an object to zero if it is being dragged.

Parameters:
damp - the velocity?

setDragable

public boolean setDragable(int id,
                           boolean drag)
Make the object with the given id dragable.

Parameters:
id - The id of the object.
drag - Dragable?
Returns:
True if successful.

setVisibility

public boolean setVisibility(int id,
                             boolean show)
Show the visibility of the object.

Returns:
true if successful

setFont

public boolean setFont(int id,
                       java.lang.String family,
                       int style,
                       int size)
change the object's font for any text that is displayed.

Parameters:
id - The id of the object.
family - The font family: Helvetica, Times.
style - The style, 0=plain, 1=bold.
size - The size of the font;
Returns:
True if successful.

setObjectFont

public boolean setObjectFont(int id,
                             java.lang.String family,
                             int style,
                             int size)
Sets the object's font if the object has text that can be displayed.

Parameters:
id - The id of the object.
family - The font family: Helvetica, Times.
style - The style, 0=plain, 1=bold.
size - The size of the font;
Returns:
true if successful.

setFormat

public boolean setFormat(int id,
                         java.lang.String fstr)
Change the object's format for the display of numeric data. Us this method to control the number of significant digits in calculations with text objects. Use Unix printf conventions. For example fstr="%6.3f"

Parameters:
id - The id of the object.
fstr - the format string.
Returns:
True if successful.

setFootPrints

public boolean setFootPrints(int id,
                             int n)
Sets the trail to leave footprints as the charge moves.

Parameters:
id - The id of the object.
n - The number of points to skip between trail footprints or ghost images.
Returns:
True if successful.

setHideCharge

public void setHideCharge(boolean hc)
Hide all charges.

Parameters:
hc - HidCharge parameter.

setLabel

public boolean setLabel(int id,
                        java.lang.String label)
Make the object label.

Parameters:
id - The id of the object.
label - The label string.
Returns:
True if successful.

setCollisionMessage

public void setCollisionMessage(java.lang.String msg)
Display a message in the yellow message box.

Parameters:
msg - Message to display after the animation stops.

setShowFieldLines

public void setShowFieldLines(boolean sfl)
Show the field lines.

Parameters:
sfl - Show field line.

setShowFieldVectors

public void setShowFieldVectors(boolean sfv)
Show the direction field vectors.

Parameters:
sfv - Show field line vectors.

setShowContours

public void setShowContours(boolean sc)
Show the contour lines.

Parameters:
sc - Show contours.

setPointChargeMode

public void setPointChargeMode(boolean pcm)
Sets point charge to produce 1/(r*r) field. Setting this parameter false will produce 1/r field.

Parameters:
pcm - Sets point charge mode

setShowLabels

public void setShowLabels(boolean sl)
Show the contour labels.

Parameters:
sl - Show contour labels?

setAutoRefresh

public void setAutoRefresh(boolean ar)
Repaint whenevers the system parameters are changed.

Overrides:
setAutoRefresh in class SApplet
Parameters:
ar -

setAnimationSlave

public boolean setAnimationSlave(int masterID,
                                 int slaveID)
Force an object to follow another object on the screen.

Parameters:
masterID - The id of the master object.
slaveID - The id of the slave object.
Returns:
true if successful.

set

public boolean set(int id,
                   java.lang.String name,
                   java.lang.String parList)
Change the properies of an object. The first argument is the object identifier. The second argument is the name of the property and the third is a comma-delimited list of parameters. For example, the scale can be added a follows:

set(id, "sale", "xmin=0, xmax=2, autoscalx=false");

Parameters:
id - the identifier of the object
name - the type of property to be created.
parList - a list of parameters
Returns:
true if successful

setBz

public void setBz(double bz)
Sets the z component of the magnetic field.

Parameters:
bz - The magnetic field in the z directon.

setCaption

public void setCaption(java.lang.String c)
Sets the caption.

Parameters:
c - The caption string.

setChargeLabel

public void setChargeLabel(java.lang.String l)
Sets the charge label. See also setLabel to change the label of any object.

Parameters:
l - All subsequent charges will show this label in the middle of the charge.

setChargeMagnitude

public boolean setChargeMagnitude(int id,
                                  double mag)
Sets the magnitude for a charge.

Parameters:
id - The ID of the object.
mag - The magnitude.

setChargeRGB

public void setChargeRGB(int r,
                         int g,
                         int b)
Sets the color for new charges.

Parameters:
r - red.
g - green.
b - blue.

setMass

public boolean setMass(int id,
                       double m)
Sets the mass of an object.

Parameters:
id - The id of the object.
m - The new mass.
Returns:
True if successful.

setConstraintStr

public boolean setConstraintStr(int id,
                                java.lang.String str,
                                double xmin,
                                double xmax)
Constrain the motion of the test charges to a path given my F(x).

Parameters:
str - The function string F(x).
xmin - The minimum value of the range.
xmax - The maximum value of the range.
Returns:
True if successful.

setConstrainX

public boolean setConstrainX(int id,
                             double x,
                             double xmin,
                             double xmax)
Constrain the motion of the test charges to a path of constant x.

Parameters:
x - The x value.
xmin - The minimum value of the range.
xmax - The maximum value of the range.
Returns:
True if successful.

setConstrainR

public boolean setConstrainR(int id,
                             double r,
                             double x,
                             double y)
Constrain the motion of the test charges to a circular path.

Parameters:
r - The r value.
x - The x coordinate of the center
y - The y coordinate of the center
Returns:
True if successful.

setConstrainY

public boolean setConstrainY(int id,
                             double y,
                             double ymin,
                             double ymax)
Constrain the motion of the test charges to a path of constant y.

Parameters:
y - The y value.
ymin - The minimum value of the range.
ymax - The maximum value of the range.
Returns:
True if successful.

setDisplayOffset

public boolean setDisplayOffset(int id,
                                int xOff,
                                int yOff)
Offset the object's position on the screen from its default drawing position.

Parameters:
id - The id of the object.
Returns:
True if successful.

setChargeTrail

public void setChargeTrail(int t)
Sets the animation the default trail length.

Parameters:
t - The default trail points to draw in the animation behind a moving charge.

setRGB

public boolean setRGB(int id,
                      int r,
                      int g,
                      int b)
Sets the color for an object. Currently works for test charges and poles.

Parameters:
id - The ID of the object.
r - red.
g - green.
b - blue.
Returns:
Tue if successful.

setSeriesRGB

public void setSeriesRGB(int id,
                         int r,
                         int g,
                         int b)
Sets the series line and marker color.

Parameters:
id - The series id.
r - red.
g - green.
b - blue.

setOnScreenSize

public boolean setOnScreenSize(int id,
                               int size)
Sets the size for an object.

Parameters:
id - The ID of the object.
Returns:
True if successful.

makeDataConnection

public int makeDataConnection(int sourceID,
                              int listenerID,
                              int seriesID,
                              java.lang.String xStr,
                              java.lang.String yStr)
Make a data connection between a data source, i.e. a charge, and a data listener. Typical data listeners are graphs and spread sheets.

Overrides:
makeDataConnection in class SApplet
Parameters:
sourceID - The source ID.
listenerID - The listener ID.
seriesID - The listener ID series.
xStr - The ordinate to be passed to the data listener.
yStr - The abscissa to be passed to the data listener.
Returns:
An ID that identifies the data connection.

deleteDataConnection

public void deleteDataConnection(int id)
Break the data connection identified by the id.

Overrides:
deleteDataConnection in class SApplet
Parameters:
id - The data connection id.

deleteDataConnections

public void deleteDataConnections()
Break all data connections.

Overrides:
deleteDataConnections in class SApplet

setShowTime

public void setShowTime(boolean st)
Show the simulation time.

Parameters:
st - Show the time?

setShowCoordOnDrag

public void setShowCoordOnDrag(boolean sc)
Show the coordinates on a mouse drag.

Parameters:
sc - Show the coordinates.

setShowVOnDrag

public void setShowVOnDrag(boolean sv)
Show the potential at the mouse postion on a mouse drag.

Parameters:
sv - Show the voltage?

setShowEOnDrag

public void setShowEOnDrag(boolean se)
Show the field at the mouse postion on a mouse drag.

Parameters:
se - Show the field.

setShowEquipotentialOnClick

public void setShowEquipotentialOnClick(boolean sp)
Draw equipotential starting at the mouse click.


setShowEquipotentialOnDoubleClick

public void setShowEquipotentialOnDoubleClick(boolean sp)
Draw equipotential starting at the mouse double click.


setShowFieldLineOnClick

public void setShowFieldLineOnClick(boolean sfl)
Draw a field line starting at the mouse click.

Parameters:
sfl - Enable field line on click.

setShowFieldLineOnDoubleClick

public void setShowFieldLineOnDoubleClick(boolean sfl)
Draw a field line starting at the mouse double click.

Parameters:
sfl - Enable field line on double click.

setShowConstraintPath

public void setShowConstraintPath(int id,
                                  boolean sc)
Show a the constraint function that test particles must follow.

Parameters:
sc - Show the path?

setShowFComponents

public boolean setShowFComponents(int id,
                                  boolean sc)
Enable the charge force vector to show components when it is drawn. Works for test charges and poles.

Parameters:
id - The ID of the charge.
sc - Show the vector?
Returns:
True if successful.

setShowFOnDrag

public boolean setShowFOnDrag(int id,
                              boolean sfm)
Enable the charge to show the force magnitude in the message box.

Parameters:
id - The ID of the charge.
sfm - Show the force magnitude?

setShowFVector

public boolean setShowFVector(int id,
                              boolean sf)
Enable the charge to show the net force vector when it is drawn. Works for test charges and poles.

Parameters:
id - The ID of the charge.
sf - Show the vector?
Returns:
True if successful.

setFieldResolution

public void setFieldResolution(int r)
Sets the field resolution determines how the spacing of the field vectors on the grid. A resoluton of 2 would skip every other grid point when calculating the field vectors.

Parameters:
r - the resolution

setGridSize

public void setGridSize(int n)
Sets the grid size for the evaluation of the potential energy.

Parameters:
n - the size of the grid

setGhost

public boolean setGhost(int id,
                        boolean ghost)
Have the charge draw ghost images as it moves. Use footprints to set the spacing.

Parameters:
id - The id of the object.
ghost - Draw ghost?
Returns:
True if successful.

setShowForce

public void setShowForce(boolean sf)
Show the default to show the force vector on all subsequently created test charges.

Parameters:
sf - Show the force?

setShowVelocity

public void setShowVelocity(boolean sv)
Show the default to show the velocity vector on newly created test charges.

Parameters:
sv - Show the velocity?

setShowVComponents

public boolean setShowVComponents(int id,
                                  boolean svc)
Enable the charge velocity vector to show components when it is drawn. Works for test charges and poles.

Parameters:
id - The ID of the charge.
svc - Show the vector components?
Returns:
True if successful.

setShowVVector

public boolean setShowVVector(int id,
                              boolean sv)
Enable the charge to show the net velocity vector when it is drawn. Works for test charges and poles.

Parameters:
id - The ID of the charge.
sv - Show the velocity vector?

setSketchMode

public int setSketchMode(boolean sketch)
Enable sketching with the mouse.

Parameters:
sketch - true will sketch
Returns:
int the id of the mouse data source

setSticky

public boolean setSticky(int id,
                         boolean isSticky)
Make the object stickey so that collisions stop the animation.

Parameters:
id - The id of the object.
Returns:
True if successful.

setSpeed

public boolean setSpeed(int id,
                        double speed)
Change the speed of a test charge. Direction of motion remains unchanged.

Parameters:
id - The ID of the charge.
speed - Show new speed.
Returns:
True if successful.

setShowCharge

public void setShowCharge(boolean sc)
Display all fixed charges on the screen.

Parameters:
sc - Show the charges on the screen.

setTrail

public boolean setTrail(int id,
                        int pts)
Sets the trail behind a charge. Zero will remove the trail.

Parameters:
id - The ID of the object.
pts - Trail length.
Returns:
True if successful.

setTimeVisibility

public void setTimeVisibility(boolean visible)
Enable the time display in the applet window.


setTimeContinuous

public void setTimeContinuous()
Let the simulation continue forever.

Overrides:
setTimeContinuous in class SApplet

setTimeCycle

public void setTimeCycle(double max)
Cycle the simulation

Overrides:
setTimeCycle in class SApplet
Parameters:
max - Reset the simulation to t=0 when t>=max and repeat the simulation.

setTimeOneShot

public void setTimeOneShot(double max,
                           java.lang.String msg)
Run the simulaiton one time.

Overrides:
setTimeOneShot in class SApplet
Parameters:
max - Reset the simulation to t=0 when t>=max and stop the simulation.
msg -

setTolerance

public void setTolerance(double t)
Sets the tolerance for the animation calculations. Default is 1 part in 1.0e-5.


setTrajectory

public boolean setTrajectory(int id,
                             java.lang.String xStr,
                             java.lang.String yStr)
Sets the trajectory of a pole.

Parameters:
id - The ID of the pole.
xStr - The function x(t).
yStr - The function y(t).
Returns:
True if the functions are valid and the trajectory has been set.

setPotential

public void setPotential(java.lang.String ps,
                         double xmin,
                         double xmax,
                         double ymin,
                         double ymax)
Sets the potential function. Y values are set so as to preserve an aspect ration of 1.

Parameters:
ps - The potential function, f(x,y).
xmin - x minimum
xmax - x maximum
ymin - approximate y minimum
ymax - approximate y maximum

setMaxTime

public void setMaxTime(double max,
                       java.lang.String msg)
Stop the simulation at a predetermined time and display a message for the user.

Parameters:
max - Stop the simulation when t=max and continue simulation.
msg - Display a user message.

pause

public void pause()
Pause the simulation

Overrides:
pause in class SApplet

forward

public void forward()
Resume the simulation with a positive time step.

Overrides:
forward in class SApplet

reverse

public void reverse()
Resume the simulation with a negative time step.

Overrides:
reverse in class SApplet

stepTimeForward

public void stepTimeForward()
Step the simulation one positive time step.

Overrides:
stepTimeForward in class SApplet

stepForward

public void stepForward()

stepTimeBack

public void stepTimeBack()
Step the simulation one negative time step.

Overrides:
stepTimeBack in class SApplet

stepBack

public void stepBack()

reset

public void reset()
Reset the initial conditions at time t=0.

Overrides:
reset in class SApplet


Visit the Davidson College Physlet Site for additional information.