wave3d
Class Wave3d

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

public class Wave3d
extends edu.davidson.tools.SApplet
implements edu.davidson.tools.SStepable

Wave3d animates a 3D wave traveling along the z direction. This program is based on a student project by ASB. It was modified by W. Christian.

Constructor Summary
Wave3d()
           

 

Method Summary
 int addAxes(double x, double y, double z, double s)
          Add axes to the animation.
 int addBox(double l, double w, double h)
          Add a box centered on the origin to the animation.
 int addCircularLeft(double z1, double z2, double a, double ph)
          Add a left circular wave between two points.
 int addCircularRight(double z1, double z2, double a, double ph)
          Add a right circular wave between two points.
 int addFilledRectangle(double z, double w, double h)
          Adds a filled rectangle.
 int addFilledSquare(double z, double s)
          Add a filled square.
 int addGrid(double z1, double length, double width, double p)
          Add a rectangular grid.
 int addLinear(double z1, double z2, double a, double ph, double p)
          Add a sinusoidal wave between two points.
 int addRectangle(double z, double w, double h)
          Add a rectangle centered on the z axis to the animation.
 int addSquare(double z, double s)
          Add a square centered on the z axis to the animation.
 int addText(java.lang.String text, int xpix, int ypix)
          Add text to the animation at the given pixel location.
 int addWavefunction(java.lang.String function, double z1, double z2, double p)
          Add a wavefunction f(z,t).
 void deleteAll()
          Delete all objects from drawing.
 boolean deleteObject(int id)
          Delete an object from the applet.
 void destroy()
          Destroys the applet when the html page is closed.
 void forward()
          Method forward
 java.lang.String getAppletInfo()
          Method getAppletInfo
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
          Gets the applet parameters
 java.lang.String[][] getParameterInfo()
          Method getParameterInfo
 void init()
          Initializes the applet
 void pause()
          Method pause
 boolean setAngles(double t, double a, double p)
          Sets the viewing angles.
 void setDefault()
          Set default values and deletes all data connections.
 void setFixedAlpha(boolean fixed)
          Fix alpha so that it cannot be changed using the mouse.
 void setFixedPhi(boolean fixed)
          Fix Phi so that it cannot be changed using the mouse.
 void setFixedTheta(boolean fixed)
          Fix theta so that it cannot be changed using the mouse.
 boolean setFont(int id, java.lang.String family, int style, int size)
          change the object's font for any text4 that is displayed.
 void setLineDensity(int density)
          Sets the line density for all subsequent drawing.
 void setPixPerUnit(int ppu)
          Sets the pixels per unit.
 boolean setPolarization(int id, double angle)
          Sets the polarization of waves or grid.
 boolean setRGB(int id, int r, int g, int b)
          Sets 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 setVisibility(int id, boolean show)
          Show the visibility of the object.
 boolean setWavelength(int id, double wavelength)
          Set the wavelength.
 boolean setXYFactor(int id, double factor)
          Sets a scale factor for the x-y coordinates of an object.
 boolean setZ(int id, double z)
          Sets the z position of a square or a grid.
 void start()
          Starts the applet when the html page is loaded.
 void step(double dt, double time)
          Steps the animation by dt.
 void stop()
          Stops the applet when the html page is no longer active.

 

Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, cleanupDataConnections, clearAllData, clearData, cyclingClock, deleteDataConnection, deleteDataConnections, formatValue, getClockID, getClockTime, getDataConnectionFromDL, getDataConnectionFromDS, getDataFromDS, getDataListener, getDataListener, getDataSource, getDataSource, getDebugLevel, getID, getRunningID, getSourceData, getSourceVariables, isAutoRefresh, isClockRunning, isValidFunction, makeDataConnection, pausingClock, removeDataListener, removeDataSource, reset, reverse, setAutoRefresh, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setConnectionWindowX, setConnectionWindowY, setDebugLevel, setDt, setExternalClock, setFPS, setRunningID, setRunningID, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stopClock, stoppingClock, updateDataConnection, updateDataConnections

 

Constructor Detail

Wave3d

public Wave3d()
Method Detail

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)
Gets the applet parameters
Parameters:
key -  
def -  
Returns:
 

init

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

getAppletInfo

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

getParameterInfo

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

start

public void start()
Starts the applet when the html page is loaded. Do not script.
Overrides:
start in class java.applet.Applet

forward

public void forward()
Method forward
Overrides:
forward in class edu.davidson.tools.SApplet

stop

public void stop()
Stops the applet when the html page is no longer active. Do not script.
Overrides:
stop in class java.applet.Applet

pause

public void pause()
Method pause
Overrides:
pause in class edu.davidson.tools.SApplet

destroy

public void destroy()
Destroys the applet when the html page is closed. Do not script.
Overrides:
destroy in class edu.davidson.tools.SApplet

step

public void step(double dt,
                 double time)
Steps the animation by dt.
Specified by:
step in interface edu.davidson.tools.SStepable
Parameters:
dt - the time step
time - the current time.

setFixedTheta

public void setFixedTheta(boolean fixed)
Fix theta so that it cannot be changed using the mouse.
Parameters:
fixed - true will disable

setFixedAlpha

public void setFixedAlpha(boolean fixed)
Fix alpha so that it cannot be changed using the mouse.
Parameters:
fixed - true will disable

setFixedPhi

public void setFixedPhi(boolean fixed)
Fix Phi so that it cannot be changed using the mouse.
Parameters:
fixed - true will disable

setAngles

public boolean setAngles(double t,
                         double a,
                         double p)
Sets the viewing angles.
Parameters:
t - the z axis angle
a - the x axis angle
p - the y axis angle
Returns:
 

setPixPerUnit

public void setPixPerUnit(int ppu)
Sets the pixels per unit.
Parameters:
ppu -  

setWavelength

public boolean setWavelength(int id,
                             double wavelength)
Set the wavelength.
Parameters:
id -  
wavelength -  
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.

setLineDensity

public void setLineDensity(int density)
Sets the line density for all subsequent drawing. The density determines the number of pixels between lines in traveling waves and on grids. The default is 10.
Parameters:
density - line density

setRGB

public boolean setRGB(int id,
                      int r,
                      int g,
                      int b)
Sets the color of an object.
Parameters:
id - The id of the object.
r - red
g - green
b - blue
Returns:
true if successful; false otherwise

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.

setVisibility

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

setZ

public boolean setZ(int id,
                    double z)
Sets the z position of a square or a grid.
Parameters:
id - the object
z - the new position along z
Returns:
true if successful; false otherwise

setPolarization

public boolean setPolarization(int id,
                               double angle)
Sets the polarization of waves or grid.
Parameters:
id - the object
angle -  
Returns:
true if successful; false otherwise

setXYFactor

public boolean setXYFactor(int id,
                           double factor)
Sets a scale factor for the x-y coordinates of an object. Can be used to adjust the wave amplitude.
Parameters:
id - the object
angle -  
Returns:
true if successful; false otherwise

deleteObject

public boolean deleteObject(int id)
Delete an object from the applet.
Parameters:
id - the object identifier
Returns:
true if successful

addText

public int addText(java.lang.String text,
                   int xpix,
                   int ypix)
Add text to the animation at the given pixel location.
Parameters:
text -  
xpix -  
ypix -  
Returns:
id of the object

addAxes

public int addAxes(double x,
                   double y,
                   double z,
                   double s)
Add axes to the animation.
Parameters:
x -  
y -  
z -  
s -  
Returns:
the id of the object.

addSquare

public int addSquare(double z,
                     double s)
Add a square centered on the z axis to the animation.
Parameters:
z - the position
s - the side
Returns:
the id of the object.

addRectangle

public int addRectangle(double z,
                        double w,
                        double h)
Add a rectangle centered on the z axis to the animation.
Parameters:
z - the position
w - the width along x
h - the height along y
Returns:
the id of the object.

addBox

public int addBox(double l,
                  double w,
                  double h)
Add a box centered on the origin to the animation.
Parameters:
l - the length
w - the width
h - the height
Returns:
the id of the object.

addFilledSquare

public int addFilledSquare(double z,
                           double s)
Add a filled square.
Parameters:
z - the position
s - the size
Returns:
the id of the object.

addFilledRectangle

public int addFilledRectangle(double z,
                              double w,
                              double h)
Adds a filled rectangle.
Parameters:
z - the position
s - the size
Returns:
the id of the object.

addLinear

public int addLinear(double z1,
                     double z2,
                     double a,
                     double ph,
                     double p)
Add a sinusoidal wave between two points.
Parameters:
z1 - the starting point
z2 - the ending point
a - the amplitude
ph - the phase
p - the polzarization angle
Returns:
the id of the object.

addCircularRight

public int addCircularRight(double z1,
                            double z2,
                            double a,
                            double ph)
Add a right circular wave between two points.
Parameters:
z1 - the starting point
z2 - the ending point
a - the amplitude
ph - the phase
Returns:
the id of the object.

addCircularLeft

public int addCircularLeft(double z1,
                           double z2,
                           double a,
                           double ph)
Add a left circular wave between two points.
Parameters:
z1 - the starting point
z2 - the ending point
a - the amplitude
ph - the phase
Returns:
 

addGrid

public int addGrid(double z1,
                   double length,
                   double width,
                   double p)
Add a rectangular grid. Grids are designed to represent polarizers.
Parameters:
z1 - the position
length -  
width -  
p - the orientation angle
Returns:
 

addWavefunction

public int addWavefunction(java.lang.String function,
                           double z1,
                           double z2,
                           double p)
Add a wavefunction f(z,t).
Parameters:
function - the function
z1 - the starting point
z2 - the ending point
p - the polarization angle
Returns:
 

deleteAll

public void deleteAll()
Delete all objects from drawing.

setDefault

public void setDefault()
Set default values and deletes all data connections.
Overrides:
setDefault in class edu.davidson.tools.SApplet