Last modified Jan-02-1998    |   Contents

Inside Jeliot

Here we describe How Jeliot works. The client/server model and networking is descibed mostly in the client/server page.

Beginning of the page

Main window

The main window is shown when you open the Jeliot page with your browser. It includes a text area where you can write your code and a few control buttons.

There are some limitations to the code that can be submitted to Jeliot. Some limitations are due to the restrictions to applets, and some are specific to Jeliot. Because the generated animation is shown as an applet, all of the code must be in one file. No file access is allowed. Restrictions caused by the implementation include that: submitted classes can not extend other classes, and class variables are not initialized. More about the restrictions can be found in the Jeliot User's Manual.

Beginning of the page

Generation of the animation

When the code is sent to the server, it is first parsed. The parser has been constructed using the CUP-tool, and the lexical analyzer used by the parser has been written using the JLex-tool. The grammar used is the LALR(1) grammar given in The Java(tm) Language Specification. If the code received is not syntactically correct, an error message is generated and the client side is notified so that the message can be shown to the user.

When the parsing is succesful, the parse tree is forwarded to the codegenerator. First it extracts all the data structures that can be animated from the code and sends them to the main window at the client side. It then generates the modified version of the user's code by changing the animating data types to Jeliot's own data types and adding the necessary import statements to the beginning of the code. The resulting code is then written to a file at the server-side.

Jeliot has its own datatypes corresponding to the primitive types of Java i.e. byte, short, char, int, long, float, double, and boolean. At present from the reference types only array (one or two dimensional), queue, and stack can be animated. Every variable in the original code is converted to one of the role-classes in Jeliot. For example for int there is a corresponding Rint class etc. These role-classes all have an actor-class counterpart - for int there is Aint etc. So in the code there is an instance of a role-class which knows what to do when an operation is done. Each of the stages where that role is selected to be animated there is an instace of an actor class which in turn knows how to present the variable on that stage, and how to act the operations performed on that variable.

After the code-generation has been finished, the server calls a Java compiler. The compiler used is the regular Java compiler from Sun's JDK 1.0.2 for Linux. After the code has been compiled to byte code, the URL of the resulting class-file is sent to the client side.

When the client receives the URL of the compiled code, it loads the class-file using the default class loader -- and the animation is ready to be run.

Beginning of the page

Animation

When running the animation there is one stage where the animation is shown. New stages can be added and the code can be shown with the control panel. Each of the stages has a setup panel, where the properties for the animated variables can be set.

The heart of the Jeliot animator is the Director class. To the user the director is shown via an instance of the DirectorGUI class, later called Control panel. When the code is being run the active code line is shown in the window, unless the Trace on/off has been set to off. In the control panel there are also Run/Pause button for running or pausing the animation, Step-button for running the animation one line of the code at a time, Rewind-button for restarting the animation, RunTo-button for running the animation to a certain point in the code,NewStage-button for opening a new stage, and a slidebar to control the speed of the animation.

The animation is run on the stages in parallel. Each stage can be positioned anywhere on the screen, its size can be altered, and the actors can be chosen and configured independently from the other stages. Each stage has setup-button for changing the appearance of the actors on that stage,close-button for closing that stage, and a help-button to open the on-line help.

The messages sent during the animation are illustrated in the figure below. When the user's program is being executed and an operation to a variable that can be animated is found, a message consisting of the ID of the variable and the operation itself, is (1) sent to the Director by that variable's role-instance. The Director in turn (2) multicasts the message to all the stages. Each stage then (3) finds out if that particular role is being acted on that stage, and if a proper actor is found the message is given to the actor acting the role on the stage. When the operation in question has been carried out, or acted, on the stage (4) a notification is sent to an instace of DirectorsAssistant. When all the stages have sent the notification, the DirectorsAssistant (5) informs the Director, and the control is then returned to the class executing the user's code.

Beginning of the page


Previous | Next | Contents