Chapter 18: Version 4 Physlets


Drag the wire and observer the voltage in the Faraday Physlet..

This chapter provides a quick overview of additional Physlets that implement inter-applet communication and portions of the addObject scripting syntax described in this book.   These examples are not examples of pedagogy;  they are proof-of-concept scripts that can be used to check the basic functionality of each applet.  Copy these examples to your local hard drive and modify them to suit your local curricular requirements

Please be aware that not all methods are available and that there are minor inconsistencies among the method names and parameter signatures. These Physlets are, after all, upgrades of older versions.  Consult the on-line documentation to determine if the method that you are using is supported by the Physlet.  For example, the Faraday Physlet shown above allows the user to specify the magnetic field as a function of  x position and time, B(x,t).  Consequently, the setTrajectory method has a parameter signature that takes one integer and one string

document.faraday.setTrajectory(id,xStr);

rather than the signature used by Animator and EField.

document.animator.setTrajectory(id,xStr,yStr);

Upgrading from older versions

Physlets are based a common class library that we refer to as Science Tools for Java Programmers. This library is distributed as a Java Archive file, STools4.jar.  The new library has extended functionality and different organization from previous STools packages.  Version 4 Physlets have been recompiled to to use this new archive.

Only minor changes need to be made to scripts in order to incorporate the new package.

  1. You do not need to change a script in any way if the script accesses a Physlet packaged in a single jar file containing all the resources necessary to run.  For example, a script that uses just Animator.jar or EField.jar does not need to be changed.  These archives already contain the new tools.  You should, of course, update the necessary jar file if you are mirroring it on your local server.
  2. If a script uses multiple jar files for inter-applet communication, the archive attribute must be modified to use version 4 or the new tools and the new applets.
  3. You cannot mix-and-match applets that use version 4 of STools and previous version of STools.

For example, Animator and DataGraph applets can be embedded on the same page and communicate using data connections if their archive attributes are written as follows:

archive="Animator4_.jar,DataGraph4_.jar,STools4.jar"

instead of the old

archive="Animator_.jar,DataGraph_.jar,SGraphics.jar,STools.jar"

Finally, we should explain our notation. We usually break up Physlet jar files to remove common class libraries. Almost all Physlets require numerical methods and graphics toolkits from STools4.jar. Rather than including this library with every Physlet, we prefer to provide Physlet jar files without this common library. These abbreviated jar files have an underscore appended archive name.

Animator4.jar -> Animator4_.jar, STools4.jar
DataGraph4.jar -> DataGraph4_.jar, STools4.jar
DataTable4.jar -> DataTable4_.jar, STools4.jar

When multiple applets are run on a page we recommend that the archive list for each applet be extended to include all the jar files for the entire page.  Otherwise, inter-applet communication will fail on some browsers.   For example, if a page contains both Animator and EField Physlets, the archive tag for both applets should be coded as follows.

    archive="Animator_.jar,DataGraph_.jar,EField4_.jar,SGraphics.jar,STools.jar"

Embedding a Physlet by specifying multiple jar files should not increase download time, since jar files are only downloaded once no matter how many times they appear on a page.

Additional Physlets: