Almost all Physlets support one or more add methods
designed to create an object and add it to the applet. These objects usually, but not always,
have an on-screen representation. For
example, both Animator and EField support addCircle methods that are invoked
using the following JavaScript statements
document.animator.addCircle(int
diameter, String xStr,String yStr)
and
document.efield.addCircle(double
x, double y, int radius ),
respectively.
Notice that the signatures, that is, the parameters, of
these two method are different. Animator
version 1 was designed to move simple geometric shapes along predefined
trajectories that were passed to the object's constructor. EField version 1, on the other hand, was
designed plot electric fields for fixed charges so its constructor required only
fixed position coordinates. Hence,
animator was passed two functions strings and EField was passed two numbers. Both applets were designed to run on 90
MHz computers with relatively slow Java virtual machines. Since each applet only had a half dozen
methods, it was not difficult to remember the correct signature. But computer hardware and software
advances have made it possible to add a great deal of functionality and the
capabilities of these two applets have slowly converged. Each applet now supports dozens of
methods and although many of the methods names are the same, the method
signatures are, unfortunately, still different to maintain backward
compatibility.
In order to bring some order to this method madness,
version 4 of Animator and EField, along with all newly written Physlets, have
adopted a more uniform convention for adding objects. Both applets now support an addObject
method with the following signature
document.physletname.addObject(String name, String list)
The first argument is the name of the object to be added
and the second is a comma-delimited list of parameters. A circle can now be added to either applet using the
following statement
document.physletname. addObject ("circle",
"x = 0, y = -1.0, r = 10");
Furthermore, the new method is more forgiving since not all
parameters need be specified. The default values are overridden only if they
appear in the list. Incorrect
or unsupported parameters have no effect and are ignored.
Users of old scripts should note that although the original
add methods are still included in version 4 for backward compatibility, they
have been depreciated. In
addition, there have been structural changes in the tools package. The original STools.jar and
SGraphics.jar have been combined into a single archive called STools4.jar. Consequently, archive and
code properties that are specified when an applet is embedded should now read
archive="Animator4_.jar,STools4.jar"
code="animator4.Animator.class"
and
archive="EField4_.jar,STools4.jar"
code="eField4.EField.class".
As before, all jar files need to be specified and listed the same order in every archive tag on a page for inter-applet communication to work on all browsers.
The table below lists the name and the associated
parameters for version 4 of the EField and Animator Physlets. Consult the on-line documentation for information about other
Physlets.
|
Name |
Parameters |
Animator |
EField |
|
arrow |
|
|
|
|
box |
|
|
|
|
circle |
|
|
|
|
caption |
|
|
|
|
charge |
|
|
|
|
connectorline |
|
|
|
|
connectorspring |
|
|
|
|
cursor |
|
|
|
|
exshell |
|
|
|
|
image |
|
|
|
|
line |
|
|
|
|
polyshape |
|
|
|
|
rectangle |
|
|
|
|
relshape |
|
|
|
|
shell |
|
|
|
|
testcharge |
|
|
|
|
text |
|
|
|