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

EField
public EField()

getParameter
public String getParameter(String key,
String def)

init
public void init()
- Overrides:
- init in class Applet

jbInit
public void jbInit() throws Exception

start
public void start()
- Overrides:
- start in class Applet

stop
public void stop()
- Overrides:
- stop in class Applet

destroy
public void destroy()
- Overrides:
- destroy in class SApplet

getAppletInfo
public String getAppletInfo()
- Overrides:
- getAppletInfo in class Applet

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

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.

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.

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.

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.

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.

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.

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.

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.

clearTestCharges
public void clearTestCharges()
- Clears the test charges.

clearFixedCharges
public void clearFixedCharges()
- Clears the fixed charges.

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.

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.

setYRange
public void setYRange(double ymin,
double ymax)

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.

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.

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

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?

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.

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

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?

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.

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.

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.

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.

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

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

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

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

setChargeMagnitude
public boolean setChargeMagnitude(int id,
double mag)
- Set 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)
- Set the color for new charges.
- Parameters:
- r - red.
- g - green.
- b - blue.

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.

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.

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.

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.

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.

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.

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

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

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

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.

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.

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.

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.

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.

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.

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

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?

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.

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.

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?

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?

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.

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.

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.

setTimeContinous
public void setTimeContinous()
- Let the simulation continue forever.

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

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

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.

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

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.

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

pause
public void pause()
- Pause the simulation

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

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

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

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

reset
public void reset()