Ripple AddObject Method

Almost all Physlets support one or more add methods designed to create an object and add it to the applet.  The addObject method with the following signature

addObject(String name, String attributes)

These objects usually, but not always, have an on-screen representation.  The first argument is the name of the object to be added, and the second is a comma-delimited list of parameters.  A lens can be added using the following JavaScript statement:

document.physletname.addObject("source", "x=0,y=0.5,r=5,amp=1,phase=0");.

The addObject method is very forgiving since not all parameters need to be specified.  Default values are overridden only if the parameter appears in the list.  Incorrect and unsupported parameters do not affect the applet and are ignored.

Name

Attributes

arrow
An arrow.

x- double x position of the center in world units
y- double y position of the center in world units
h- double horizontal component
s- int size of the arrow head
v- double vertical component

box
A hollow rectangle.

x- double x position of the center in world units
y- double y position of the center in world units
h- int height in pixels
w- int width in pixels

caption

A fixed text string followed by an optional calculation.

x- double x position of the left side of the text in world units
y- double y position of the top of the text in world units
text- string static text.

Text objects are often slaved to other objects. 

circle
A filled circle.

x- double x position of the center in world units
y- double y position of the center in world units.
r- int radius in pixels

cursor
A hollow circle wit crosshairs

x- double x position of the center in world units
y- double y position of the center in world units.
r- int radius in pixels

constraint

xmin- double The minimum x value.
xmax- double The maximum x value.
ymin- double The minimum y value.
ymax- double
The maximum y value.

A constraint, by itself, will have no effect.  It must be attached to a dragable object using the setConstraint method.

image 
A gif image

x- double x position of the center in world units
y- double y position of the center in world units.
gif- String a gif image
file- String same as gif

A Physlet will search for images in the directory containing the jar files and in the directory containing the html file.  Both directories work from a server, but the html directory search will fail in IE if the html file is located on local hard drive.

You may use subdirectories to organize images.
addObject("image","file=mechanics/car.gif");

rectangle
A filled rectangle.

 

x- double x position of the center in world units
y- double y position of the center in world units
h- int height in pixels
w- int width in pixels

shell  
A hollow circle.

x- double x position of the center in world units
y- double y position of the center in world units
r- int radius in pixels

text

A fixed text string.

x- double x position of the left side of the text in world units
y- double y position of the top of the text in world units
text- string static text.

Text objects are often slaved to other objects.