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 |
x- double x position
of the center in world units |
|
box |
x- double x position
of the center in world units |
|
caption A fixed text string followed by an optional calculation. |
x- double x position
of the left side of the text in world units Text objects are often slaved to other objects. |
|
circle |
x- double x position
of the center in world units |
|
cursor |
x- double x position
of the center in world units |
|
constraint |
xmin- double The
minimum x value. A constraint, by itself,
will have no effect. It must
be attached to a dragable object using the setConstraint method. |
|
image |
x- double x position
of the center in world units 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. |
|
rectangle |
x- double x position
of the center in world units |
|
shell |
x- double x position
of the center in world units |
|
text A fixed text string. |
x- double x position
of the left side of the text in world units Text objects are often slaved to other objects. |