animator4
Class Animator

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

public class Animator
extends SApplet

Animator is part of the Davidson College Physlets project. It is designed to animate shapes or images on the screen. Objects can move along a predefined trajectory or in response to a force.

The following embedding parameters are defined:

Parameter  Value Description
FPS 10 Frames per second.
dt 0.1 Animation time step per frame.
ShowControls true Show VCR buttons at bottom of applet.
GridUnit 1.0 The grid spacing.  A value of 0 will suppress the grid.
PixPerUnit 10 Conversion factor from pixel units to world units.

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

Object Identifier Variables
images id=addImage(String file,String xStr,String yStr) t, x, y, vx, vy, ax, ay, m
All shapes: circle, rectangle, box, arrow, etc. The id is returned when an object is created using an add method. t, x, y, vx, vy, ax, ay, m
clock id=getClockID() t
ensemble id=getEnsembleID() t, xcm, ycm, px, py , m , ke

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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Animator()
           
 
Method Summary
 int addObject(java.lang.String name, java.lang.String parList)
          Create an object and add it to the Physlet.
 void forward()
          Start the animation.
 double getAnimationTime()
          Get the animation time.
 java.lang.String getAppletInfo()
           
 int getEnsembleID()
          Get the id for the ensemble of objects.
 double getFx(int id)
          Get the x component of the force acting on an object.
 double getFy(int id)
          Get the y component of the force acting an object.
 double getH(int id)
          Get the height of an object.
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 double getVX(int id)
          Get the x component of an object's velocity.
 double getVY(int id)
          Get the y component of an object's velocity.
 double getW(int id)
          Get the width of an object.
 double getX(int id)
          Get the x position of an object.
 double getY(int id)
          Get the y position of an object.
 void init()
           
static void main(java.lang.String[] args)
           
 void pause()
          Pause the animation.
 void reset()
          Clear data from all dataConnections and reset the animation time to 0.
 void reverse()
          Reverse the direction of the time step in the animation.
 boolean setAnimationSlave(int masterID, int slaveID)
          Force an object to follow another object on the screen.
 void setAnimationTime(double time)
          Set the animation time.
 void setAutoRefresh(boolean auto)
          Force the applet to repaint whenever any object changes its properties.
 boolean setBouncy(int id, boolean bounce)
          Make the object bouncy.
 int setCaption(java.lang.String s)
          Add a caption to the applet.
 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 setConstrainX(int id, double x, double min, double max)
          Constrain the motion of the test charges to a path of constant x.
 boolean setConstrainY(int id, double y, double min, double max)
          Constrain the motion of the test charges to a path of constant y.
 boolean setCoordinateOffset(int id, int xOff, int yOff)
          Offset the object's coordinates on the screen.
 void setDampOnMousePressed(boolean damp)
          Set the velocity of an object to zero if it is being dragged.
 void setDefault()
          Set default values and deletes all data connections.
 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 canDrag)
          Make the object with the given id dragable.
 boolean setFont(int id, java.lang.String family, int style, int size)
          change the object's font for any text4 that is displayed.
 boolean setFootPrints(int id, int n)
          Set the trail to leave footprints as the charge moves.
 boolean setForce(int id, java.lang.String fxStr, java.lang.String fyStr, double x0, double y0, double vx0, double vy0)
          Set the Force on a particle.
 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 setGridUnit(double gu)
          Set the grid spacing in world, i.e., not pixel, units.
 boolean setH(int id, double h)
          Change the height of an object.
 boolean setLabel(int id, java.lang.String label)
          Make the object label.
 boolean setMass(int id, double m)
          Set the mass of an object.
 void setMessage(java.lang.String msg)
          Display a message in the yellow message box.
 void setOneShot(double min, double max, java.lang.String msg)
          Set the applet to run for a fixed interval, stop, and display a message.
 boolean setOnScreenSize(int id, int size)
          Set a size parameter for an object.
 boolean setPaintBeforeGrid(int id, boolean before)
          Have the object draw itself before the grid is drawn.
 void setPixPerUnit(int pu)
          Set the pixels per unit.
 boolean setReferenceFrame(int id)
          Set the reference frame.
 boolean setResizable(int id, boolean isResizable)
          Make an object resizable.
 boolean setRGB(int id, int r, int g, int b)
          Set the color of an object.
 void setShapeRGB(int r, int g, int b)
          Set the red, green, and blue color values for all subsequent drawing.
 boolean setShowAComponents(int id, boolean show)
          Have the object show its acceleration components.
 boolean setShowAVector(int id, boolean show)
          Have the object show its acceleration vector.
 boolean setShowConstraintPath(int id, boolean sc)
          Show the objects trajectory constraint if it exists.
 boolean setShowCoordinates(int id, boolean show)
          Have the object show its coordinates on screen.
 boolean setShowFComponents(int id, boolean show)
          Have the object show its force components.
 boolean setShowFVector(int id, boolean show)
          Have the object show its force vector.
 boolean setShowVComponents(int id, boolean show)
          Have the object show its velocity components.
 boolean setShowVVector(int id, boolean show)
          Have the object show its velocity vector.
 int setSketchMode(boolean sketch)
          Enable sketching with the mouse.
 boolean setSpeed(int id, double speed)
          Change the speed of an object.
 boolean setSticky(int id, boolean sticky)
          Make the object sticky.
 void setTimeContinuous()
          Let the animation time increase indefinitely.
 void setTimeCycle(double max)
          Set a time loop for the animation from 0 to max.
 void setTimeDisplay(boolean show)
          Enable the time display in the applet window.
 void setTimeInterval(double min, double max)
          Set a time loop for the animation.
 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 tol)
          Set the tolerance of the ODE solver.
 boolean setTrail(int id, int n)
          Enable an object to display its path as it moves.
 boolean setTrajectory(int id, java.lang.String xStr, java.lang.String yStr)
          Set the trajectory of an object on the screen.
 boolean setVisibility(int id, boolean show)
          Show the visibility of the object.
 boolean setVX(int id, double vx)
          Change the x component of the speed of an object.
 boolean setVY(int id, double vy)
          Change the y component of an object's velocity.
 boolean setW(int id, double w)
          Change the width of an object.
 boolean setX(int id, double x)
          Change the x of an object.
 boolean setXY(int id, double x, double y)
          Change the x and y of an object.
 boolean setY(int id, double y)
          Change the y of an object.
 void shiftPixOrigin(int xo, int yo)
          Shift the origin for all drawing.
 void start()
           
 void stepBack()
           
 void stepForward()
           
 void stepTimeBack()
          Step the time backward by dt.
 void stepTimeForward()
          Step the time by dt.
 void stop()
           
 boolean swapZOrder(int id1, int id2)
          Swap the drawing order on the screen.
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, cleanupDataConnections, clearAllData, clearData, deleteDataConnection, deleteDataConnections, destroy, getClockID, getClockTime, getDataConnectionFromDL, getDataConnectionFromDS, getDataFromDS, getDataListener, getDataListener, getDataSource, getDataSource, getID, getRunningID, getSourceData, getSourceVariables, isAutoRefresh, isClockRunning, makeDataConnection, removeDataListener, removeDataSource, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setDt, setExternalClock, setFPS, setRunningID, setRunningID, startClock, stepClock, stepTime, stopClock, updateDataConnection, updateDataConnections
 
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
 
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, 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, setCursor, 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

Animator

public Animator()
Method Detail

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:
double id of the object

forward

public void forward()
Start the animation.
Overrides:
forward in class SApplet

getAnimationTime

public double getAnimationTime()
Get the animation time.
Returns:
The time displayed inside the applet.

getAppletInfo

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

getEnsembleID

public int getEnsembleID()
Get the id for the ensemble of objects. This id can be used to access the ensemble as a data source.
Returns:
int The id of the ensemble containing all objects on the screen. Used as a data source.

getFx

public double getFx(int id)
Get the x component of the force acting on an object.
Parameters:
id - The id of the object.

getFy

public double getFy(int id)
Get the y component of the force acting an object.
Parameters:
id - The id of the object.

getH

public double getH(int id)
Get the height of an object.
Parameters:
id - the object identifier
Returns:
the height

getParameter

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

getParameterInfo

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

getVX

public double getVX(int id)
Get the x component of an object's velocity.
Parameters:
id - The id of the object.
Returns:
the x component of an object's velocity.

getVY

public double getVY(int id)
Get the y component of an object's velocity.
Parameters:
id - The id of the object.
Returns:
the velocity component

getW

public double getW(int id)
Get the width of an object.
Parameters:
id - The id of the object.
Returns:
the width

getX

public double getX(int id)
Get the x position of an object.
Parameters:
id - The id of the object.

getY

public double getY(int id)
Get the y position of an object.
Parameters:
id - the object identifier
Returns:
the y position

init

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

main

public static void main(java.lang.String[] args)

pause

public void pause()
Pause the animation.
Overrides:
pause in class SApplet

reset

public void reset()
Clear data from all dataConnections and reset the animation time to 0.
Overrides:
reset in class SApplet
See Also:
setAnimationTime(double)

reverse

public void reverse()
Reverse the direction of the time step in the animation.
Overrides:
reverse in class SApplet

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.

setAnimationTime

public void setAnimationTime(double time)
Set the animation time.
Parameters:
time - The new time displayed inside the applet.

setAutoRefresh

public void setAutoRefresh(boolean auto)
Force the applet to repaint whenever any object changes its properties. Default is true. Set this value to false at the beginning of long scripts and then reset to true to avoid flashing.
Overrides:
setAutoRefresh in class SApplet
Parameters:
auto - The id of the object.

setBouncy

public boolean setBouncy(int id,
                         boolean bounce)
Make the object bouncy. A dynamic object will bounce off of bouncy objects.
Parameters:
id - of the object.
true - if bouncy
Returns:
true if successful.

setCaption

public int setCaption(java.lang.String s)
Add a caption to the applet.
Parameters:
The - caption.
Returns:
The id of the caption.

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.

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.

setConstrainX

public boolean setConstrainX(int id,
                             double x,
                             double min,
                             double max)
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.

setConstrainY

public boolean setConstrainY(int id,
                             double y,
                             double min,
                             double max)
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.

setCoordinateOffset

public boolean setCoordinateOffset(int id,
                                   int xOff,
                                   int yOff)
Offset the object's coordinates on the screen.
Parameters:
id - The id of the object.
xoff - The x offset.
yoff - The y offset.
Returns:
True if successful.

setDampOnMousePressed

public void setDampOnMousePressed(boolean damp)
Set the velocity of an object to zero if it is being dragged.
Parameters:
damp - the velocity?

setDefault

public void setDefault()
Set default values and deletes all data connections. pixPerUnit= PARAM value. gridUnit= PARAM value. time=0. shapeTrail=0. pixelOrigin=(0,0). caption=null. timeDisplay=tue;
Overrides:
setDefault in class SApplet

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 canDrag)
Make the object with the given id dragable.
Parameters:
id - of the object.
canDrag - Is the object dragable?
Returns:
true if successful false otherwise

setFont

public boolean setFont(int id,
                       java.lang.String family,
                       int style,
                       int size)
change the object's font for any text4 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.

setFootPrints

public boolean 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 or ghost images.
Returns:
boolean True if successful.

setForce

public boolean setForce(int id,
                        java.lang.String fxStr,
                        java.lang.String fyStr,
                        double x0,
                        double y0,
                        double vx0,
                        double vy0)
Set the Force on a particle.
Parameters:
id - The ID of the pole.
fxStr - A function of t, x, y, vx, vy, ax, ay, m.
fyStr - A function of t, x, y, vx, vy, ax, ay, m.
x0 - The initial value for x.
y0 - The initial value for y.
vx0 - The initial value for vx.
vy0 - The initial value for vy.
Returns:
True if the functions are valid and the trajectory has been set.

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.

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.

setGridUnit

public void setGridUnit(double gu)
Set the grid spacing in world, i.e., not pixel, units. Zero will suppress the drawing of the grid.
Parameters:
gu - grid unit.

setH

public boolean setH(int id,
                    double h)
Change the height of an object.
Parameters:
id - the object identifier
h - new height
Returns:
true if successful

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

setMass

public boolean setMass(int id,
                       double m)
Set the mass of an object.
Parameters:
id - The id of the object.
m - The new mass.
Returns:
True if successful.

setMessage

public void setMessage(java.lang.String msg)
Display a message in the yellow message box.
Parameters:
msg - Message to display after the animation stops.

setOneShot

public void setOneShot(double min,
                       double max,
                       java.lang.String msg)
Set the applet to run for a fixed interval, stop, and display a message.
Parameters:
min - The starting time value for the loop
max - The ending time for the loop.
msg - Message to display after the animation stops.
See Also:
setTimeContinuous(), setTimeInterval(double, double)

setOnScreenSize

public boolean setOnScreenSize(int id,
                               int size)
Set a size parameter for an object. The effect of this parameter varies, or has no effect, depending on the object. For example, the size of a spring determines the number of coild and the size of a box determines the width of the walls.
Parameters:
id - The ID of the object.
size - The size of the object.
Returns:
boolean Returns true if successful.

setPaintBeforeGrid

public boolean setPaintBeforeGrid(int id,
                                  boolean before)
Have the object draw itself before the grid is drawn.
Parameters:
id - The id of the object.
before - Paint before grid?
Returns:
True if successful.

setPixPerUnit

public void setPixPerUnit(int pu)
Set the pixels per unit. This sets the scale for the animation.
Parameters:
pu - pixels per unit.

setReferenceFrame

public boolean setReferenceFrame(int id)
Set the reference frame. The new reference frame is the frame in which the object with id is stationary.
Parameters:
id - the object from which the motion will be observed return true if successful

setResizable

public boolean setResizable(int id,
                            boolean isResizable)
Make an object resizable.
Parameters:
id - the ID of the object.
resizable - property
Returns:
true if successful.

setRGB

public boolean setRGB(int id,
                      int r,
                      int g,
                      int b)
Set the color of an object.
Parameters:
id - The id of the object.
r - red
g - green
b - blue
Returns:
True if successful.

setShapeRGB

public void setShapeRGB(int r,
                        int g,
                        int b)
Set the red, green, and blue color values for all subsequent drawing. Color values must be in the range 0..255.
Parameters:
r - red.
g - green.
b - blue.

setShowAComponents

public boolean setShowAComponents(int id,
                                  boolean show)
Have the object show its acceleration components.
Parameters:
id - The id of the object.
show - Show the acceleration?
Returns:
True if successful.

setShowAVector

public boolean setShowAVector(int id,
                              boolean show)
Have the object show its acceleration vector.
Parameters:
id - The id of the object.
show - Show the acceleration?
Returns:
True if successful.

setShowConstraintPath

public boolean setShowConstraintPath(int id,
                                     boolean sc)
Show the objects trajectory constraint if it exists.
Parameters:
sc - Show the path?

setShowCoordinates

public boolean setShowCoordinates(int id,
                                  boolean show)
Have the object show its coordinates on screen.
Parameters:
id - The id of the object.
show - Show the coordinates?
Returns:
True if successful.

setShowFComponents

public boolean setShowFComponents(int id,
                                  boolean show)
Have the object show its force components.
Parameters:
id - The id of the object.
show - Show the force?
Returns:
True if successful.

setShowFVector

public boolean setShowFVector(int id,
                              boolean show)
Have the object show its force vector.
Parameters:
id - The id of the object.
show - Show the force?
Returns:
True if successful.

setShowVComponents

public boolean setShowVComponents(int id,
                                  boolean show)
Have the object show its velocity components.
Parameters:
id - The id of the object.
show - Show the velocity?
Returns:
True if successful.

setShowVVector

public boolean setShowVVector(int id,
                              boolean show)
Have the object show its velocity vector.
Parameters:
id - The id of the object.
show - Show the velocity?
Returns:
True if successful.

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

setSpeed

public boolean setSpeed(int id,
                        double speed)
Change the speed of an object. Direction of motion remains unchanged.
Parameters:
id - The id of the object.
speed - new speed
Returns:
true if successful

setSticky

public boolean setSticky(int id,
                         boolean sticky)
Make the object sticky. A sticky object will stop the clock upon a collision with another sticky object. The sticky object must be moving under the action of forces. Objects that have trajectories will not stick.
Parameters:
id - of the object.
sticky - Sticky?
Returns:
true if successful.

setTimeContinuous

public void setTimeContinuous()
Let the animation time increase indefinitely. May overflow for very long times.
Overrides:
setTimeContinuous in class SApplet
See Also:
setTimeOneShot(double, java.lang.String), setTimeInterval(double, double), setOneShot(double, double, java.lang.String)

setTimeCycle

public void setTimeCycle(double max)
Set a time loop for the animation from 0 to max. Animation will run continuously.
Overrides:
setTimeCycle in class SApplet
Parameters:
max - The ending time for the loop.
See Also:
setTimeContinuous(), setOneShot(double, double, java.lang.String), setTimeInterval(double, double)

setTimeDisplay

public void setTimeDisplay(boolean show)
Enable the time display in the applet window.
Parameters:
show - boolean Show the time?

setTimeInterval

public void setTimeInterval(double min,
                            double max)
Set a time loop for the animation. Animation will run continuously.
Parameters:
min - The starting time value for the loop
max - The ending time for the loop.
See Also:
setTimeContinuous(), setOneShot(double, double, java.lang.String)

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.
string - the message to be displayed on the screen when the max time is reached.

setTimeVisibility

public void setTimeVisibility(boolean visible)
Enable the time display in the applet window.
Parameters:
boolean - Show the time?

setTolerance

public void setTolerance(double tol)
Set the tolerance of the ODE solver. Default is on part in 1.0e-8.
Parameters:
tol - the tolerance

setTrail

public boolean setTrail(int id,
                        int n)
Enable an object to display its path as it moves. Not all objects can show their path.
Parameters:
id - The id of the object.
n - Number of points in trail. n=0 disables the trail.
Returns:
boolean True if successful.

setTrajectory

public boolean setTrajectory(int id,
                             java.lang.String xStr,
                             java.lang.String yStr)
Set the trajectory of an object on the screen.
Parameters:
id - The ID of the thing.
xStr - The function x(t).
yStr - The function y(t).
Returns:
boolean True if the functions are valid and the trajectory has been set.

setVisibility

public boolean setVisibility(int id,
                             boolean show)
Show the visibility of the object.
Parameters:
show - true will show object on screen
Returns:
true if successful false otherwise

setVX

public boolean setVX(int id,
                     double vx)
Change the x component of the speed of an object.
Parameters:
id - The id of the object.
vx - new vx
Returns:
true if successful

setVY

public boolean setVY(int id,
                     double vy)
Change the y component of an object's velocity.
Parameters:
id - The id of the object.
speed - new vy
Returns:
true if successful

setW

public boolean setW(int id,
                    double w)
Change the width of an object.
Parameters:
id - the object identifier
w - new width
Returns:
true if successful

setX

public boolean setX(int id,
                    double x)
Change the x of an object.
Parameters:
id - The id of the object.
x - new x value
Returns:
true if successful

setXY

public boolean setXY(int id,
                     double x,
                     double y)
Change the x and y of an object.
Parameters:
id - The id of the object.
x - new x value
y - new y value
Returns:
true if successful

setY

public boolean setY(int id,
                    double y)
Change the y of an object.
Parameters:
id - The id of the object.
y - new postion
Returns:
true if successful

shiftPixOrigin

public void shiftPixOrigin(int xo,
                           int yo)
Shift the origin for all drawing. Shift is specified in pixels.
Parameters:
xo - x pixel shift.
yo - y pixel shift.

start

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

stepBack

public void stepBack()

stepForward

public void stepForward()

stepTimeBack

public void stepTimeBack()
Step the time backward by dt.
Overrides:
stepTimeBack in class SApplet
See Also:
SApplet.setDt(double)

stepTimeForward

public void stepTimeForward()
Step the time by dt.
Overrides:
stepTimeForward in class SApplet
See Also:
SApplet.setDt(double)

stop

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

swapZOrder

public boolean swapZOrder(int id1,
                          int id2)
Swap 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.

Copyright Wolfgang Christian

Visit the Davidson CollegePhyslets Page