bfield
Class BField

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--edu.davidson.tools.SApplet
                                |
                                +--bfield.BField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class BField
extends SApplet

See Also:
Serialized Form

Fields inherited from class edu.davidson.tools.SApplet
clock, dataConnections, dataListeners, dataSources, lock
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
BField()
           
 
Method Summary
 int addCoil(double x, double y, double current)
          Add add a single coil.
 int addObject(java.lang.String name, java.lang.String parList)
          Create an object and add it to the Physlet.
 int addWire(double x, double y, double current)
          Add add a Wire.
 void destroy()
          Destroy all threads and cleanup the applet.
 java.lang.String getAppletInfo()
           
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 void init()
           
 boolean setAnimationSlave(int masterID, int slaveID)
          Force an object to follow another object on the screen.
 void setAutoRefresh(boolean ar)
          Repaint every time the system parameters are changed.
 void setBFunctions(java.lang.String bx, java.lang.String by, double xmin, double xmax, double ymin, double ymax)
          Set an external magnetic field.
 boolean setCurrent(int id, double c)
          Change the current of a wire or loop after it has been created.
 void setDefault()
          Clear all the wires and coils and set the applet into a predfined state.
 void setDefaultLabel(java.lang.String str)
          Set the default label that will be drawn inside a wire.
 void setDefaultRGB(int r, int g, int b)
          Set the default red, green, and blue color values for all subsequent wires and coils.
 boolean setDisplayOffset(int id, int xOff, int yOff)
          Offset the object's position on the screen from its default drawing position.
 boolean setDragable(int id, boolean drag)
          Change the drag property of a wire or loop after it has been created.
 boolean setFont(int id, java.lang.String family, int style, int size)
          change the object's font for any text that is displayed.
 boolean setFormat(int id, java.lang.String fstr)
          Change the object's format for the display of numeric data.
 void setHideWire(boolean hw)
          wires and coils will be created as hidden objects by default.
 boolean setLabel(int id, java.lang.String str)
          Change the label property of a wire or loop after it has been created.
 boolean setRadius(int id, double r)
          Change the radius of a loop after it has been created.
 boolean setResizable(int id, boolean isResizable)
          Make an object resizable.
 boolean setRGB(int id, int r, int g, int b)
          Set the red, green, and blue color values for a wire or coil that has already been created.
 void setShowBOnDrag(boolean sb)
          Enable a the user to read the magnetic field magnitude by click-dragging the mouse.
 void setShowControls(boolean sc)
          Enable interactive controls.
 void setShowCoordOnDrag(boolean sc)
          Enable a the user to read coordinates by click-dragging the mouse.
 boolean setShowFComponents(int id, boolean showComponents)
          Enable a wire to show the force vector components.
 void setShowFieldLineOnClick(boolean sfl)
          Enable the user to click in order to draw a magnetic field line.
 void setShowFieldLineOnDoubleClick(boolean sfl)
          Enable the user to double click in order to draw a magnetic field line.
 void setShowFieldVectors(boolean sfv)
          Show the direction field.
 boolean setShowForce(int id, boolean showForce)
           
 boolean setShowFVector(int id, boolean showForce)
          Enable a wire to show the net force vector.
 boolean setShowInfo(int id, boolean showInfo)
          Enable an object to show information such as the current.
 boolean setVisibility(int id, boolean v)
          Hide an object from the user.
 void start()
          Start the applet.
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, cleanupDataConnections, clearAllData, clearData, deleteDataConnection, deleteDataConnections, forward, getClockID, getDataConnectionFromDL, getDataConnectionFromDS, getDataFromDS, getDataListener, getDataListener, getDataSource, getDataSource, getID, getRunningID, getSourceData, getSourceVariables, isAutoRefresh, isClockRunning, makeDataConnection, pause, removeDataListener, removeDataSource, reset, reverse, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setDt, setFPS, setRunningID, setRunningID, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stopClock, updateDataConnection, updateDataConnections, useMasterClock
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFont, setLayout, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, 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, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BField

public BField()
Method Detail

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)

init

public void init()
Overrides:
init in class java.applet.Applet

getAppletInfo

public java.lang.String getAppletInfo()
Overrides:
getAppletInfo in class java.applet.Applet

getParameterInfo

public java.lang.String[][] getParameterInfo()
Overrides:
getParameterInfo in class java.applet.Applet

addWire

public int addWire(double x,
                   double y,
                   double current)
Add add a Wire.
Parameters:
x - The x position.
y - The y position.
current - The current.
Returns:
The id for the object that was created. Can be used later to set object properties.
See Also:
addCoil(double, double, double), setBFunctions(java.lang.String, java.lang.String, double, double, double, double)

addCoil

public int addCoil(double x,
                   double y,
                   double current)
Add add a single coil. Will be drawn as a cross section.
Parameters:
x - The x position.
y - The y position.
current - The current.
Returns:
The id for the object that was created. Can be used later to set object properties.
See Also:
addWire(double, double, double), setBFunctions(java.lang.String, java.lang.String, double, double, double, double)

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");

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

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.

setAutoRefresh

public void setAutoRefresh(boolean ar)
Repaint every time the system parameters are changed.
Overrides:
setAutoRefresh in class SApplet
Parameters:
ar - Automatic repaint?

setBFunctions

public void setBFunctions(java.lang.String bx,
                          java.lang.String by,
                          double xmin,
                          double xmax,
                          double ymin,
                          double ymax)
Set an external magnetic field. The field generated by this function is added to the field generated by the fixed wires.
Parameters:
bx - Bx(x,y)
by - By(x,y)
xmin - The x minimum value.
xmax - The x maximum value.
ymin - The y minimum value.
ymax - The y maximum value.
See Also:
addWire(double, double, double), addCoil(double, double, double)

setDefault

public void setDefault()
Clear all the wires and coils and set the applet into a predfined state.
Overrides:
setDefault in class SApplet

setShowFieldLineOnClick

public void setShowFieldLineOnClick(boolean sfl)
Enable the user to click in order to draw a magnetic field line. CAUTION: May be subject to numerical error if field lines are drawn too close to wire where the radius of curvature is large.
Parameters:
sfl - Boolean value.

setShowFieldLineOnDoubleClick

public void setShowFieldLineOnDoubleClick(boolean sfl)
Enable the user to double click in order to draw a magnetic field line. CAUTION: May be subject to numerical error if field lines are drawn too close to wire where the radius of curvature is large.
Parameters:
sfl - Boolean value.

setShowFieldVectors

public void setShowFieldVectors(boolean sfv)
Show the direction field. Arrows are of unit length. Color is used to represent magnitude.
Parameters:
sfv - Boolean value.

setRGB

public boolean setRGB(int id,
                      int r,
                      int g,
                      int b)
Set the red, green, and blue color values for a wire or coil that has already been created. Color values must be in the range 0..255.
Parameters:
id - The id for the wire or loop.
r - red.
g - green.
b - blue.

setLabel

public boolean setLabel(int id,
                        java.lang.String str)
Change the label property of a wire or loop after it has been created. Labels are usually single character identifies. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - The id for the wire or loop.
str - The new label.

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.
xoff - The x offset.
yoff - The y offset.
Returns:
True if successful.

setDragable

public boolean setDragable(int id,
                           boolean drag)
Change the drag property of a wire or loop after it has been created. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - the object identifier
drag - true if dragable
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.

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.

setResizable

public boolean setResizable(int id,
                            boolean isResizable)
Make an object resizable. Only coils are resizbale in this applet. Enables a user to click-drag on a coil in order to change a loop's radius.
Parameters:
id - the object identifier.
resizable - property
Returns:
true if successful.

setCurrent

public boolean setCurrent(int id,
                          double c)
Change the current of a wire or loop after it has been created. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - The id for the wire or loop.
c - The new current.

setRadius

public boolean setRadius(int id,
                         double r)
Change the radius of a loop after it has been created. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - The id for the wire or loop.
r - The new radius.

setShowFVector

public boolean setShowFVector(int id,
                              boolean showForce)
Enable a wire to show the net force vector. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - The id for the wire or loop.
showForce - Boolean value.

setShowForce

public boolean setShowForce(int id,
                            boolean showForce)

setShowFComponents

public boolean setShowFComponents(int id,
                                  boolean showComponents)
Enable a wire to show the force vector components. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - The id for the wire or loop.
showComponents - Boolean value.

setShowInfo

public boolean setShowInfo(int id,
                           boolean showInfo)
Enable an object to show information such as the current. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - The id for the wire or loop.
showInfo - Boolean value.

setVisibility

public boolean setVisibility(int id,
                             boolean v)
Hide an object from the user. Object will not be drawn but will still create a field if it is a wire. Use the id returned by the add methods to identify the object you wish to change.
Parameters:
id - the id for the wire or loop.
v - true if visible

setShowCoordOnDrag

public void setShowCoordOnDrag(boolean sc)
Enable a the user to read coordinates by click-dragging the mouse.
Parameters:
sc - Boolean value.

setShowBOnDrag

public void setShowBOnDrag(boolean sb)
Enable a the user to read the magnetic field magnitude by click-dragging the mouse.
Parameters:
sb - Boolean value.

setShowControls

public void setShowControls(boolean sc)
Enable interactive controls. Useful for testing but usually false for scripted problems.
Parameters:
sc - Boolean value.

setHideWire

public void setHideWire(boolean hw)
wires and coils will be created as hidden objects by default. Eliminates screen flash if objects are first created and then hidden. Should be set before the add methods are called.
Parameters:
hw - Boolean value.

setDefaultRGB

public void setDefaultRGB(int r,
                          int g,
                          int b)
Set the default red, green, and blue color values for all subsequent wires and coils. Color values must be in the range 0..255. The default is to color code the direction of currcent flow.
Parameters:
r - red.
g - green.
b - blue.

setDefaultLabel

public void setDefaultLabel(java.lang.String str)
Set the default label that will be drawn inside a wire. Should be a single character. All subsequent wires will carry this label.
Parameters:
str - The label

start

public void start()
Start the applet. Do not script.
Overrides:
start in class java.applet.Applet

destroy

public void destroy()
Destroy all threads and cleanup the applet. Do not script.
Overrides:
destroy in class SApplet

Copyright Wolfgang Christian

Visit the Davidson CollegePhyslets Page