bfield
Class BField

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 bybfield.BField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class BField
extends SApplet

Class BField

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
 
Constructor Summary
BField()
          Constructor 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)
          Creates an object and adds it to the Physlet.
 int addWire(double x, double y, double current)
          Add add a Wire.
 void clearSeries(int s)
          Clears the data from a series.
 void deleteSeries(int s)
          Deletes a series from the graph
 int getAppletCount()
          Counts the number of applets on a page.
 java.lang.String getAppletInfo()
          Gets information about this applet.
 double getBx(double x, double y)
          Gets the x component of the B field at a point.
 double getBy(double x, double y)
          Gets the y component of the B field at a point.
 int getGraphID()
          Gets the series ID for the graph object.
 java.lang.String[][] getParameterInfo()
          Gets information about the embedding parameters.
 double getXPos(int id)
          Gets X position of an object.
 double getYPos(int id)
          Gets X position of an object.
 void reset()
          Resets the applet and clears the field lines.
 boolean setAnimationSlave(int masterID, int slaveID)
          Forces an object to follow another object on the screen.
 void setAutoRefresh(boolean ar)
          Automatically repaints the Physlet every time a parameter is changed.
 void setBFunctions(java.lang.String bx, java.lang.String by, double xmin, double xmax, double ymin, double ymax)
          Sets an external magnetic field.
 boolean setConstraint(int id, int constraintID)
          Sets a motion constraint on an object.
 boolean setCurrent(int id, double c)
          Changes the current of a wire or loop after it has been created.
 void setDefault()
          Removes the wires and coils and resets the applet into a predfined state.
 void setDefaultLabel(java.lang.String str)
          Sets the default label that will be drawn inside a wire.
 void setDefaultRGB(int r, int g, int b)
          Sets the default red, green, and blue color values for all subsequent wires and coils.
 boolean setDisplayOffset(int id, int xOff, int yOff)
          Offsets the object's position on the screen from its default drawing position.
 boolean setDragable(int id, boolean drag)
          Changes the drag property of an object.
 boolean setFont(int id, java.lang.String family, int style, int size)
          Sets the object's font for text that is associated with the object.
 boolean setFormat(int id, java.lang.String fstr)
          Changes the object's format for the display of numeric data.
 void setHideWire(boolean hw)
          Sets the default visibility for wires and coils.
 boolean setLabel(int id, java.lang.String str)
          Changes the label property of a wire or loop after it has been created.
 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 setOptionDrag(int id, boolean isDrag)
          Deprecated.  
 boolean setRadius(int id, double r)
          Changes the radius of a loop after it has been created.
 boolean setResizable(int id, boolean isResizable)
          Makes an object resizable.
 boolean setRGB(int id, int r, int g, int b)
          Sets the red, green, and blue color values for a wire or coil that has already been created.
 void setSeriesRGB(int id, int r, int g, int b)
          Set the series line and marker color.
 void setSeriesStyle(int id, boolean conPts, int m)
          Sets the series style for the graph object.
 void setShowBOnDrag(boolean sb)
          Enables a the user to read the magnetic field magnitude by click-dragging the mouse.
 void setShowControls(boolean sc)
          Enables interactive controls.
 void setShowCoordOnDrag(boolean sc)
          Enables a the user to read coordinates by click-dragging the mouse.
 boolean setShowFComponents(int id, boolean showComponents)
          Enables a wire to show the force vector components.
 void setShowFieldLineOnClick(boolean sfl)
          Enables the user to click in order to draw a magnetic field line.
 void setShowFieldLineOnDoubleClick(boolean sfl)
          Enables the user to double click in order to draw a magnetic field line.
 void setShowFieldVectors(boolean sfv)
          Shows the vector field.
 boolean setShowForce(int id, boolean showForce)
          Shows the force on a wire in the message box when the object is clicked.
 boolean setShowFVector(int id, boolean showForce)
          Shows the net force vector on a wire.
 boolean setShowInfo(int id, boolean showInfo)
          Enables an object to show information such as the current.
 int setSketchMode(boolean sketch)
          Enables sketching with the mouse.
 boolean setVisibility(int id, boolean v)
          Sets an objects visibility.
 boolean setXPos(int id, double x)
          Sets x position of an object.
 boolean setXY(int id, double x, double y)
          Sets position of an object.
 boolean setY(int id, double y)
          Sets the y postion of an object.
 boolean setYPos(int id, double y)
          Sets Y position of an object.
 boolean swapZOrder(int id1, int id2)
          Swaps the drawing order on the screen.
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, checkAppletNames, cleanupDataConnections, clearAllData, clearData, deleteDataConnection, deleteDataConnections, formatValue, forward, getAppletName, getClockID, getClockTime, getDataFromDS, getDataListener, getDataSource, getDataSource, getDebugLevel, getID, getSourceData, getSourceVariables, isClockRunning, isValidFunction, makeDataConnection, pause, removeDataListener, removeDataSource, reverse, sendDataToListener, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setConnectionWindowX, setConnectionWindowY, setDebugLevel, setDt, setExternalClock, setFPS, setIndependentClock, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stop, stopClock, updateDataConnection, updateDataConnections
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, 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
 

Constructor Detail

BField

public BField()
Constructor BField

Method Detail

getAppletInfo

public java.lang.String getAppletInfo()
Gets information about this applet.

Returns:
the information string

getParameterInfo

public java.lang.String[][] getParameterInfo()
Gets information about the embedding parameters.

Returns:
the parameter information

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:
BField.addCoil(double, double, double), BField.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. A cross section of the coil is drawn.

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:
BField.addWire(double, double, double), BField.setBFunctions(java.lang.String, java.lang.String, double, double, double, double)

addObject

public int addObject(java.lang.String name,
                     java.lang.String parList)
Creates an object and adds 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.

setAnimationSlave

public boolean setAnimationSlave(int masterID,
                                 int slaveID)
Forces 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.

getBx

public double getBx(double x,
                    double y)
Gets the x component of the B field at a point.

Parameters:
x - The x coordinate.
y - The y coordinate.
Returns:
double the x component of B

getBy

public double getBy(double x,
                    double y)
Gets the y component of the B field at a point.

Parameters:
x - The x coordinate.
y - The y coordinate.
Returns:
double the y component of B

getGraphID

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

Returns:
the id

setSeriesRGB

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

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

setSeriesStyle

public void setSeriesStyle(int id,
                           boolean conPts,
                           int m)
Sets the series style for the graph 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)
Deletes a series from the graph

Parameters:
s -

clearSeries

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

Parameters:
s -

setAutoRefresh

public void setAutoRefresh(boolean ar)
Automatically repaints the Physlet every time a parameter is 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)
Sets an external magnetic field. The field generated by this function is added to the field generated by 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:
BField.addWire(double, double, double), BField.addCoil(double, double, double)

setDefault

public void setDefault()
Removes the wires and coils and resets the applet into a predfined state.

Overrides:
setDefault in class SApplet

reset

public void reset()
Resets the applet and clears the field lines.

Overrides:
reset in class SApplet

setShowFieldLineOnClick

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

Parameters:
sfl - Boolean value.

setShowFieldLineOnDoubleClick

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

Parameters:
sfl - Boolean value.

setShowFieldVectors

public void setShowFieldVectors(boolean sfv)
Shows the vector 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)
Sets 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.
Returns:
true if successful; false otherwise

setLabel

public boolean setLabel(int id,
                        java.lang.String str)
Changes 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.
Returns:
true if successful; false otherwise

setDisplayOffset

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

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

setDragable

public boolean setDragable(int id,
                           boolean drag)
Changes the drag property of an object. 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)
Changes 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)
Sets the object's font for text that is associated with the object.

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.

setOptionDrag

public boolean setOptionDrag(int id,
                             boolean isDrag)
Deprecated.  

Changes the option drag property of a coil after it has been created. Enables a user to click-drag on a coil in order to change a loop's radius.

Parameters:
id - The id for the wire or loop.
isDrag - The new current.
Returns:
true if successful; false otherwise
See Also:
setResizable

setResizable

public boolean setResizable(int id,
                            boolean isResizable)
Makes 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.
isResizable -
Returns:
true if successful.

setCurrent

public boolean setCurrent(int id,
                          double c)
Changes 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.
Returns:
true if successful; false otherwise

setConstraint

public boolean setConstraint(int id,
                             int constraintID)
Sets a motion constraint on an object.

Parameters:
id - the ID of the object.
constraintID - the ID of the constraint.
Returns:
true if successful.

setRadius

public boolean setRadius(int id,
                         double r)
Changes 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.
Returns:
true if successful; false otherwise

setShowFVector

public boolean setShowFVector(int id,
                              boolean showForce)
Shows the net force vector on 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.
showForce - Boolean value.
Returns:
true if successful; false otherwise

setShowForce

public boolean setShowForce(int id,
                            boolean showForce)
Shows the force on a wire in the message box when the object is clicked.

Parameters:
id -
showForce -
Returns:
true if successful; false otherwise

setShowFComponents

public boolean setShowFComponents(int id,
                                  boolean showComponents)
Enables 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.
Returns:
true if successful; false otherwise

setShowInfo

public boolean setShowInfo(int id,
                           boolean showInfo)
Enables 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.
Returns:
true if successful; false otherwise

setVisibility

public boolean setVisibility(int id,
                             boolean v)
Sets an objects visibility. Wires will not be drawn but will still create a field.

Parameters:
id - the id for the wire or loop.
v - true if visible
Returns:
true if successful; false otherwise

setXY

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

Parameters:
id - The ID of the object.
x - The x coordinate.
y - The y coordinate.
Returns:
true if successful; false otherwise

setXPos

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

Parameters:
id - The ID of the object.
x - The x coordinate.
Returns:
true if successful; false otherwise

getXPos

public double getXPos(int id)
Gets X position of an object.

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

setYPos

public boolean setYPos(int id,
                       double y)
Sets Y position of an object.

Parameters:
id - The ID of the object.
y - The y coordinate.
Returns:
true if successful; false otherwise

setY

public boolean setY(int id,
                    double y)
Sets the y postion of an object. Same as setYPos.

Parameters:
id -
y -
Returns:
y

getYPos

public double getYPos(int id)
Gets X position of an object.

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

setShowCoordOnDrag

public void setShowCoordOnDrag(boolean sc)
Enables a the user to read coordinates by click-dragging the mouse.

Parameters:
sc - Boolean value.

setSketchMode

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

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

setShowBOnDrag

public void setShowBOnDrag(boolean sb)
Enables a the user to read the magnetic field magnitude by click-dragging the mouse.

Parameters:
sb - Boolean value.

setShowControls

public void setShowControls(boolean sc)
Enables interactive controls. Useful for testing but usually false for scripted problems.

Parameters:
sc - Boolean value.

setHideWire

public void setHideWire(boolean hw)
Sets the default visibility for wires and coils. Should be set before the add methods are called.

Parameters:
hw - Boolean value.

setDefaultRGB

public void setDefaultRGB(int r,
                          int g,
                          int b)
Sets 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)
Sets the default label that will be drawn inside a wire. Labels should be single characters. All subsequent wires will carry this label.

Parameters:
str - the label

swapZOrder

public boolean swapZOrder(int id1,
                          int id2)
Swaps the drawing order on the screen.

Parameters:
id1 - the first id of a screen object
id2 - the second id of a screen object
Returns:
true if successful

getAppletCount

public int getAppletCount()
Counts the number of applets on a page.

Returns:
the number of applets


Visit the Davidson College Physlet Site for additional information.