EField VERSION 2


Class eField.EField

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----sTools.SApplet
                                           |
                                           +----eField.EField

public class EField
extends SApplet
implements Runnable

This applet plots electric fields given a potential function and point charges. Both fixed charges and moving test charges can be specified using "add" methods. Version 2.3d of EField has been modified to work with JBuilder2 using AWT methods.

Version:
$Revision: 2.0 $, $Date: 1999/01/15 08:00:00 $
Author:
Wolfgang Christian

Constructor Index

 o EField()
 

Method Index

 o addBox(double, double, int, int)
Add a box.
 o addCharge(double, double, double)
Add a fixed charge.
 o addCircle(double, double, int)
Add a filled circle.
 o addLineAnchor(int, double, double)
Add a line from a point(x,y) to an object on the screen.
 o addRectangle(double, double, int, int)
Add a filled rectangle.
 o addShell(double, double, int)
Add a spherical shell.
 o addSpringAnchor(int, double, double)
Add a spring from a point(x,y) to an object on the screen.
 o addTestCharge(double, double, double, double)
Add a test charge.
 o clearFixedCharges()
Clears the fixed charges.
 o clearTestCharges()
Clears the test charges.
 o deleteDataConnection(int)
Break the data connection identified by the id.
 o deleteDataConnections()
Break all data connections.
 o destroy()
 
 o forward()
Resume the simulation with a positive time step.
 o getAppletInfo()
 
 o getParameter(String, String)
 
 o getParameterInfo()
 
 o init()
 
 o jbInit()
 
 o makeDataConnection(int, int, int, String, String)
Make a data connection between a data source, i.e.
 o pause()
Pause the simulation
 o reset()
 
 o reverse()
Resume the simulation with a negative time step.
 o run()
DO NOT SCRIPT! Used by the ODE thread.
 o setAutoRefresh(boolean)
Repaint every time the system parameters are changed.
 o setBz(double)
Set the z component of the magnetic field.
 o setCaption(String)
Set the caption.
 o setChargeLabel(String)
Set the carge label.
 o setChargeMagnitude(int, double)
Set the magnitude for a charge.
 o setChargeRGB(int, int, int)
Set the color for new charges.
 o setChargeTrail(int)
Set the animation the default trail length.
 o setConstraintStr(int, String, double, double)
Constrain the motion of the test charges to a path given my F(x).
 o setConstrainX(int, double, double, double)
Constrain the motion of the test charges to a path of constant x.
 o setConstrainY(int, double, double, double)
Constrain the motion of the test charges to a path of constant y.
 o setDefault()
Sets the default conditions.
 o setDrag(boolean)
Set drag for all subsequent charges.
 o setDragable(int, boolean)
Make the object with the given id dragable.
 o setFootPrints(int, int)
Set the trail to leave footprints as the charge moves.
 o setHideCharge(int)
Hides all charges.
 o setLabel(int, String)
Make the object with the given id dragable.
 o setMaxTime(double, String)
Stop the simulation at a predetermined time and display a message for the user.
 o setNoDrag(int)
Set no drag for all subsequent charges.
 o setOnScreenSize(int, int)
Set the size for an object.
 o setPotential(String, double, double, double, double)
Set the potential function.
 o setRGB(int, int, int, int)
Set the color for an object.
 o setShowCharge(int)
Display all fixed charges on the drawing canvas.
 o setShowConstraintPath(int, boolean)
Show a the constraint function that test particles must follow.
 o setShowContours(int)
Show the contour lines.
 o setShowCoordOnDrag(int)
Show the coordinates on a mouse drag.
 o setShowEOnDrag(int)
Show the field at the mouse postion on a mouse drag.
 o setShowFComponents(int, boolean)
Enable the charge force vector to show components when it is drawn.
 o setShowFieldLineOnClick(int)
Draw a field line starting at the mouse click.
 o setShowFieldLineOnDoubleClick(int)
Draw a field line starting at the mouse double click.
 o setShowFieldLines(int)
Show the field lines.
 o setShowFieldVectors(int)
Show the direction field vectors.
 o setShowFOnDrag(int, boolean)
Enable the charge to show the force magnitude in the message box.
 o setShowForce(int)
Show the default to show the force vector on newly created test charges.
 o setShowFVector(int, boolean)
Enable the charge to show the net force vector when it is drawn.
 o setShowLabels(int)
Show the contour labels.
 o setShowTime(int)
Show the simulation time.
 o setShowVComponents(int, boolean)
Enable the charge velocity vector to show components when it is drawn.
 o setShowVelocity(int)
Show the default to show the velocity vector on newly created test charges.
 o setShowVOnDrag(int)
Show the potential at the mouse postion on a mouse drag.
 o setShowVVector(int, boolean)
Enable the charge to show the net velocity vector when it is drawn.
 o setSpeed(int, double)
Change the speed of a test charge.
 o setTimeContinous()
Let the simulation continue forever.
 o setTimeCycle(double)
Cycle the simulation
 o setTolerance(double)
Set the tolerance for the animation calculations.
 o setTrail(int, int)
Set the trail behind a charge.
 o setTrajectory(int, String, String)
Set the trajectory of a pole.
 o setXRange(double, double)
Set the scale using the horizontal axis.
 o setXY(int, double, double)
Set position of an object.
 o setYRange(double, double)
 
 o start()
 
 o stepBack()
Step the simulation one negative time step.
 o stepForward()
Step the simulation one positive time step.
 o stop()
 

Constructors

 o EField

 public EField()

Methods

 o getParameter

 public String getParameter(String key,
                            String def)

 o init

 public void init()
Overrides:
init in class Applet

 o jbInit

 public void jbInit() throws Exception

 o start

 public void start()
Overrides:
start in class Applet

 o stop

 public void stop()
Overrides:
stop in class Applet

 o destroy

 public void destroy()
Overrides:
destroy in class SApplet

 o getAppletInfo

 public String getAppletInfo()
Overrides:
getAppletInfo in class Applet

 o getParameterInfo

 public String[][] getParameterInfo()
Overrides:
getParameterInfo in class Applet

 o addTestCharge

 public synchronized int addTestCharge(double x,
                                       double y,
                                       double vx,
                                       double vy)
Add a test charge. A test charge moves with F=E but does not effect the potentials or fields.
Parameters:
x - The x position.
y - The xy position.
vx - The x velocity.
vy - The y velocity.
Returns:
s int An ID that identifies the charge.

 o addCharge

 public synchronized int addCharge(double x,
                                   double y,
                                   double m)
Add a fixed charge. A fixed charge does not move but does effect the field and the potential at the test charges.
Parameters:
x - The x position.
y - The y position.
m - The magnitude of the charge.
Returns:
s int An ID that identifies the charge.

 o addRectangle

 public synchronized int addRectangle(double x,
                                      double y,
                                      int width,
                                      int height)
Add a filled rectangle.
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:
s int An ID that identifies the rectangle.

 o addBox

 public synchronized int addBox(double x,
                                double y,
                                int width,
                                int height)
Add a box.
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:
s int An ID that identifies the box.

 o addLineAnchor

 public synchronized int addLineAnchor(int id,
                                       double x,
                                       double y)
Add a line from a point(x,y) to an object on the screen.
Parameters:
ID - The ID of the object on the screen.
x - The x position.
y - The y position.
Returns:
s int An ID that identifies the anchor.

 o addSpringAnchor

 public synchronized int addSpringAnchor(int id,
                                         double x,
                                         double y)
Add a spring from a point(x,y) to an object on the screen.
Parameters:
ID - The ID of the object on the screen.
x - The x position.
y - The y position.
Returns:
s int An ID that identifies the anchor.

 o addCircle

 public synchronized int addCircle(double x,
                                   double y,
                                   int radius)
Add a filled circle.
Parameters:
x - The x position.
y - The y position.
width - The radius of the shell in pixels.
Returns:
s int An ID that identifies the circle.

 o addShell

 public synchronized int addShell(double x,
                                  double y,
                                  int radius)
Add a spherical shell.
Parameters:
x - The x position.
y - The y position.
width - The radius of the shell in pixels.
Returns:
s int An ID that identifies the box.

 o clearTestCharges

 public void clearTestCharges()
Clears the test charges.

 o clearFixedCharges

 public void clearFixedCharges()
Clears the fixed charges.

 o 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.

 o setXRange

 public void setXRange(double xmin,
                       double xmax)
Set 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.

 o setYRange

 public void setYRange(double ymin,
                       double ymax)

 o setXY

 public boolean setXY(int id,
                      double x,
                      double y)
Set position of an object.
Parameters:
id - The ID of the object.
x - The x coordinate.
y - The y coordinate.

 o setNoDrag

 public void setNoDrag(int nd)
Set no drag for all subsequent charges.
Parameters:
nd - NoDrag parameter; nd=0 turns drag off, nd=1 turns drag on.

 o setDrag

 public void setDrag(boolean drag)
Set drag for all subsequent charges.
Parameters:
drag - Drag?

 o setDragable

 public void setDragable(int id,
                         boolean drag)
Make the object with the given id dragable.
Parameters:
id - The id of the object.
drag - Dragable?

 o setFootPrints

 public void setFootPrints(int id,
                           int n)
Set 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.

 o setHideCharge

 public void setHideCharge(int hc)
Hides all charges.
Parameters:
hc - HidCharge parameter; hc=0 turns off, hc=1 turns on.

 o setLabel

 public void setLabel(int id,
                      String label)
Make the object with the given id dragable.
Parameters:
id - The id of the object.
drag - Dragable?

 o setShowFieldLines

 public void setShowFieldLines(int sfl)
Show the field lines.
Parameters:
sfl - Show field line parameter; sfl=0 turns field lines off, sfl=1 turns field lines on.

 o setShowFieldVectors

 public void setShowFieldVectors(int sfv)
Show the direction field vectors.
Parameters:
sfv - Show field line vectors; sfv=0 turns field vectors off, sfv=1 turns field vectors on.

 o setShowContours

 public void setShowContours(int sc)
Show the contour lines.
Parameters:
sc - Show contour parameter; sc=0 turns contours lines off, sc=1 turns contour lines on.

 o setShowLabels

 public void setShowLabels(int sl)
Show the contour labels.
Parameters:
sl - Show labels parameter; sl=0 turns labels off, sl=1 turns labels on.

 o setAutoRefresh

 public void setAutoRefresh(boolean autoRefresh)
Repaint every time the system parameters are changed.
Parameters:
autoRefresh - Automatic repaint?

 o setBz

 public void setBz(double bz)
Set the z component of the magnetic field.
Parameters:
bz - The magnetic field in the z directon.

 o setCaption

 public void setCaption(String c)
Set the caption.
Parameters:
c - The caption string.

 o setChargeLabel

 public void setChargeLabel(String l)
Set the carge label.
Parameters:
l - All subsequent will show this label in the middle of the charge.

 o setChargeMagnitude

 public boolean setChargeMagnitude(int id,
                                   double mag)
Set the magnitude for a charge.
Parameters:
id - The ID of the object.
mag - The magnitude.

 o setChargeRGB

 public void setChargeRGB(int r,
                          int g,
                          int b)
Set the color for new charges.
Parameters:
r - red.
g - green.
b - blue.

 o setConstraintStr

 public boolean setConstraintStr(int id,
                                 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.

 o 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.

 o 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.

 o setChargeTrail

 public void setChargeTrail(int t)
Set the animation the default trail length.
Parameters:
t - The default trail points to draw in the animation behind a moving charge.

 o setRGB

 public boolean setRGB(int id,
                       int r,
                       int g,
                       int b)
Set 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.

 o setOnScreenSize

 public boolean setOnScreenSize(int id,
                                int size)
Set the size for an object.
Parameters:
id - The ID of the object.
r - red.
g - green.
b - blue.

 o makeDataConnection

 public int makeDataConnection(int sourceID,
                               int listenerID,
                               int seriesID,
                               String xStr,
                               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.
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:
s int An ID that identifies the data connection.
Overrides:
makeDataConnection in class SApplet

 o deleteDataConnection

 public void deleteDataConnection(int id)
Break the data connection identified by the id.
Parameters:
id - The data connection id.
Overrides:
deleteDataConnection in class SApplet

 o deleteDataConnections

 public void deleteDataConnections()
Break all data connections.
Overrides:
deleteDataConnections in class SApplet

 o setShowTime

 public void setShowTime(int st)
Show the simulation time.
Parameters:
st - Show the time; st=0 turns time off, st=1 turns time on.

 o setShowCoordOnDrag

 public void setShowCoordOnDrag(int sc)
Show the coordinates on a mouse drag.
Parameters:
sc - Show the coordinates; sc=0 turns off, sc=1 turns on.

 o setShowVOnDrag

 public void setShowVOnDrag(int sv)
Show the potential at the mouse postion on a mouse drag.
Parameters:
sv - Show the voltage; sv=0 turns off, sv=1 turns on.

 o setShowEOnDrag

 public void setShowEOnDrag(int se)
Show the field at the mouse postion on a mouse drag.
Parameters:
se - Show the field; se=0 turns off, se=1 turns on.

 o setShowFieldLineOnClick

 public void setShowFieldLineOnClick(int sfl)
Draw a field line starting at the mouse click.
Parameters:
sfl - Enable field line on click; sfl=0 turns off, sfl=1 turns on.

 o setShowFieldLineOnDoubleClick

 public void setShowFieldLineOnDoubleClick(int sfl)
Draw a field line starting at the mouse double click.
Parameters:
sfl - Enable field line on double click; sfl=0 turns off, sfl=1 turns on.

 o setShowConstraintPath

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

 o 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.
sf - Show the vector?

 o 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?

 o 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?

 o setShowForce

 public void setShowForce(int sf)
Show the default to show the force vector on newly created test charges.
Parameters:
sf - Show the force: sf=0 turns off, sf=1 turns on.

 o setShowVelocity

 public void setShowVelocity(int sv)
Show the default to show the velocity vector on newly created test charges.
Parameters:
sv - Show the velocity: sv=0 turns off, sv=1 turns on.

 o 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?

 o 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?

 o 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.
sv - Show new speed.

 o setShowCharge

 public void setShowCharge(int sc)
Display all fixed charges on the drawing canvas.
Parameters:
sc - Show the charges: sc=0 turns off, sc=1 turns on.

 o setTrail

 public boolean setTrail(int id,
                         int pts)
Set the trail behind a charge. Zero will remove the trail.
Parameters:
id - The ID of the object.
pts - Trail length.

 o setTimeContinous

 public void setTimeContinous()
Let the simulation continue forever.

 o setTimeCycle

 public void setTimeCycle(double max)
Cycle the simulation
Parameters:
max - Reset the simulation to t=0 when t=max and continue simulation.

 o setTolerance

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

 o setTrajectory

 public boolean setTrajectory(int id,
                              String xStr,
                              String yStr)
Set the trajectory of a pole.
Parameters:
id - The ID of the pole.
xStr - The function x(t).
yStr - The function y(t).
Returns:
s boolean True if the functions are valid and the trajectory has been set.

 o setPotential

 public void setPotential(String ps,
                          double xmin,
                          double xmax,
                          double ymin,
                          double ymax)
Set 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

 o setMaxTime

 public void setMaxTime(double max,
                        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.

 o run

 public void run()
DO NOT SCRIPT! Used by the ODE thread.

 o pause

 public void pause()
Pause the simulation

 o forward

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

 o reverse

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

 o stepForward

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

 o stepBack

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

 o reset

 public void reset()