03.08.2013 Views

PTOLEMY II - CiteSeerX

PTOLEMY II - CiteSeerX

PTOLEMY II - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Custom Applets<br />

Finally, the values of the director and Clock actor parameters are coupled to these top-level parameters<br />

by the lines<br />

director.stopTime.setExpression("stopTime");<br />

clock.period.setExpression("clockPeriod");<br />

The expressions being set here can be much more elaborate. The expression language is documented in<br />

the Data Package chapter. Here, the expressions each contain a single variable reference, referring to<br />

the top-level parameters by name.<br />

In order for the top-level parameters to appear in the controls of an applet, we must configure the<br />

HTML file as shown in figure 8.9. The line<br />

<br />

accomplish the objective. The result of invoking the appletviewer on the HTML file in figure 8.9 is<br />

shown in figure 8.10.<br />

8.3.6 Adding Custom Actors<br />

The intent of Ptolemy <strong>II</strong> is to have a reasonably rich set of actors in the actor libraries. However, it<br />

is anticipated that model builders will often need to define their own, custom actors. This is relatively<br />

easy to do, as discussed in the Designing Actors chapter. By convention, when a specialized actor is<br />

created for a particular applet or application, we store that actor in the same directory with the applet or<br />

application, rather than in the actor libraries. The actor libraries are for generic, reusable actors.<br />

8.3.7 Using Jar Files<br />

A jar file is a Java Archive File that contains multiple .class files. Applets that are being downloaded<br />

over the net will start up more quickly if all the relevant Java .class files are collected together<br />

into one or more jar files. This dramatically reduces the number of HTTP transactions.<br />

Models in the Ptolemy <strong>II</strong> demo directories typically use three separate jar files:<br />

ptolemy/ptsupport.jar — A jar file containing classes from ptolemy.kernel, ptolemy.actor and<br />

other packages, see $PT<strong>II</strong>/ptolemy/makefile for a complete list;<br />

<br />

\<br />

\<br />

\<br />

No Java Plug-in support for applet, see<br />

http://java.sun.com/products/plugin/<br />

<br />

FIGURE 8.9. The HTML that displays model parameters for the applet user to control. This file can be<br />

found in $PT<strong>II</strong>/doc/tutorial/TutorialApplet3.htm<br />

242 Ptolemy <strong>II</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!