Matti Kononen - mkononen@cc.joensuu.fi
InterJSP, JSPButtons and ButtonSpy applets communicate with JavaSketchpad applets (Nick Jackiw, Key Curriculum Press) using interface JSP_ExternIO. They provide a JavaSketch designer to create multi-applet web pages with easy and flexible (but limited) inter-applet communication features. In order to use these applets you need a copy of a JavaSketchpad archive (for example JSPDR3.ZIP) into which you copy the files from the archive JSP_IAC.ZIP. The package JSPDR3_IAC1.ZIP contains all classes from JSPDR3.ZIP and all other classes described in this document.
Each applet in a page can be given an unique name. If you intend to use an applett for inter-applet communication it's obligatory to name it uniquely since distinct applets are separated and recognized by names.
This is valid for naming measurements and parameters in JSP constructions as well.
An example:
#CODEBASE = "JSP"
#ARCHIVES = "JSPDR3_IAC1.ZIP"
#WIDTH = 500
#HEIGHT= 500
#ALIGN=Left
#NAME="AppletName"
We advice that only capital letters (or alteratively small letters) are used in all CODEBASE and ARCHIVE parameters (file or directory names) in all applets placed on the same Web page.
All these applets inherit two basic features from an abstract Java class JSPFinder. The features are automatic connection and a debugging window. Automatic connection is set on and off by an applet parameter AutoConnect. If its value=1 (default), the applet waits for initializing and connects automatically to JSP applets whose names are given later. With value=0 user will be given a Connect button that triggers connection procedure.
User can read applets messages by setting value=1 for parameter MessageFrame. Default value is 0 with no debugging window. Normally you won't need this window unless you want to watch the connection procedure.
Syntax for strings and floating point numbers used in these applets is similar to the syntax in JavaSketpad. For closer information see JavaSketchpad Construction Grammar.
InterJSP applet reads a measurement value of a JSP applet and transmits it into a parameter value of another JSP. In the parameter Transmit of the InterJSP you give a sequence
string_1, string_2, string_3, string_4;
where string_2 is the unique name of the measurement in the applet named string_1. And string_4 is the unique name of the parameter in the applet named string_3. Note that you cannot omit any commas or semicolon in the sequence. There can be arbitarily many of these sequences with different names of JSPs, parameters or measurements.
JSP grammar doesn't know sequence buttons, buttons that trigger a sequence of different actions. JSPButtons applet creates such sequence buttons.
JSPButtons has four parameters for setting layout: Rows, Columns, Hgap and Vgap. User can use either parameter Rows or Columns, not both, to tell the applet in how many rows or column the sequence buttons will be placed. Parameters Hgap and Vgap allocate the horizontal and vertical gap between buttons. All of these arguments must be non-negative, and both Rows and Columns may not be zero.
Parameter Buttons describes the sequences of buttons. It has following syntax:
SequenceName : JSPName (ButtonName, Delay{, ButtonName, Delay}) {JSPName (ButtonName, Delay{, ButtonName, Delay})};
where strings SequenceName, JSPName and ButtonName denote the title of this sequence button, the name of the JSP in which the buttons are contructed and the unique name of the ActionButton you want into the sequence. Delay is the delay to be waited after pressing this button and before pressing next button. It can be positive or negative floating point number. Positive values denote the delay in seconds. Negative values order the program to wait and finish current animation before pressing the next button. Brackets ('{' and '}') have the meaning that the expressions placed inside them is repeated arbitrary many (including zero) times, with different ~Names, of course. There can be arbitrary many sequence button constructions and each sequence can have several buttons from several distinct JSPs.
Applet ButtonSpy is not very usefull in contructing JavaSketches. It's main purpose is to provide a teacher a way to check, which ActionButtons in the sketch have been pressed. Implementation of this applet isn't particularly sophisticated or efficient, but it works if there's no need to spy more than two or three buttons.
This applet takes three obligatory parameters: JSP, Output and Buttons. JSP is the name of the JSP applet containing the buttons to be watched, Output is the name of the form field where names of the buttons will be written and Buttons contains comma-separated strings, the unique names of the buttons. The applet takes also two optional parameters: Delay and Times. Delay is the delay in milliseconds, within which the use of same button is not reported. Integer Times denotes how many times activation of one button is reported. If its value is negative, activation of a button reported allways. If its value is N ( 0), then activation of a button is reported N times. This is usefull if you want to know whether a button is pressed and you are not interested in how many times it's pressed. When an action of a button is reported N times, the thread watching that button will stop and save the processor time.
ButtonSpy applet writes its output into a field of an HTML form. Therefore the ButtonSpy applets tag requires an extra tag: MAYSCRIPT. Omitting this tag will cause the applet not to work at all. Furthermore, unlike other applets, one ButtonSpy applet is capable to watch buttons in one JSP applet only.