Inclusion of Active Figures in Eprints

An `active figure' is a figure that can be modified in response to user input. For example, a figure might show a calculation or a fit to data using a certain arbitrarily chosen set of parameters. An active figure would allow a reader to input a different set of parameters and would then redraw itself accordingly.

It is not yet possible to have active figures in the standard ps or pdf text formats. However, it is completely straightward to create an active version of a figure as a java applet. And, it is easy to package this applet with an eprint, so that it can be stored at the eprint archive arXiv.org. In this form, the active figure can be retrieved with the paper and run while the paper is being read. A recent paper hep-ph/0101342, by James Wells and myself, illustrates how this can be done.

This page gives some basic materials for the creation of active figures. The java implementation in these files is rather primitive. If you can improve upon it, please send me the results. Address this and other correspondence to mpeskin@slac.stanford.edu


A java applet plotter: Pplotter.java

Here is a simple applet plotter: Pplotter.java. You will also need the class plotStream.java, which is the format for data input to the Pplotter. Pplotter is an abstract class which extends the class Applet. To instantiate a class derived from Pplotter, it is necessary to define the two methods:

A curve or continuous line is fed into the Pplotter through a plotStream class. A plotStream class has the public methods: The Pplotter class has the following public methods. Many of these emulate similar methods of the Topdrawer graphics program. If you wish to plot in a specific color, this is best done by calling the standard java Graphics method, e.g.: g.setColor(Color.blue); . However, the method switchColor is useful when you overlay many plots with different parameter values.


A simple two-parameter linear fitter: LinearFit.java

Here is a simple linear fitter: LinearFit.java The fitter is based on a two-parameter relation: x_i = A_ik p_k, for k = 0,1, i = 0, ..., Ndata-1. (Note that java arrays start indexing at 0.) The fitter has a method fit() that fills the following variables of the fitter class:

LinearFit is an abstract class which extends the class Pplotter. To instantiate a class derived from LinearFit, it is necessary to define the the method: LinearFit also has graphics functions that arise because it is defined as an extension of Pplotter. The public methods of the LinearFit class are:

Construction of the applet in hep-ph/0101342

The applet in hep-ph/0101342 is built using the class hierarchy: Applet -> Pplotter -> LinearFit -> STFit -> STapplet. The applet is accessed through the html file stapplet.html. The latter three files can be obtained here:

STfit.java adds the methods specific to the particular physics analysis done in the paper. STapplet.java adds the GUI. For an explanation of how to write GUI's in java, see any book on java. You might not learn anything else from this book, but you will see many examples of graphics and user interface components built from the java abstract windowing toolkit (awt). The GUI is written in Java 1.1. I recommend that you not write your applet in Java 2, since many browsers and even whole operating systems (e.g. Macintosh) do not yet support Java 2.

How to submit an active figure to arXiv.org

Finally, here are instructions for submitting an active figure to the eprint archive. I will use "yymmddd" to represent the paper number and "xapplet.class" to refer to the applet.


M. E. Peskin

SLAC