CS 4773 Object Oriented Systems


JOTSA

JOTSA stands for Java On Time Synchronous Animation

What JOTSA Does

JOTSA provides tools and a simple user interface for doing animation.

How JOTSA works


The major pieces of JOTSA


Current Status of JOTSA


Specifying objects to be displayed


How to display an object


A Simple JOTSA Example

/*
   < Applet code = "jtest1.simple"
           width = 200 height = 200 >
   & lt /applet >
 */

package jtest1;

import java.awt.*;
import java.awt.image.*;
import java.applet.*;
import jotsa.*;

public class simple extends JotsaAnimationApplet {
   Button doit;
   JotsaAnimationObject obj;
   Color C = new Color(255,0,0);
   int start_x = 20;
   int start_y = 10;
   int end_x = 120;
   int end_y = 120;
   int start_size = 20;
   int end_size = 30;
   int move_time = 5000;

   public void init() {
      JotsaInitImages(bounds().width,bounds().height);
      JotsaWriteBackgroundString("A simple JOTSA example",20,100,Color.blue);
      setLayout(new BorderLayout());
      add("South",doit = new Button("Do It"));
      obj = new JotsaAnimationObject(start_x,start_y,1,1,this);
      obj.set_fill_centered_oval(start_size,start_size,C);
      obj.path_create_along_line(start_x,start_y,end_x,end_y);
      obj.set_size_linear(start_size,end_size);
   }

   public boolean action(Event e,Object arg) {
      if ("Do It".equals(arg)) {
         System.out.println("Do It Pushed");
         doit.setLabel("Move It");
         JotsaRemoveAllObjects();
         obj.deactivate();
         obj.times_set(move_time);
         JotsaInsertObject(obj);
         repaint(1);
         return true;
      }  
      if ("Move It".equals(arg)) {
         System.out.println("Move It Pushed");
         doit.setLabel("Do It");
         obj.activate_delay();
         JotsaForceRedisplay();
         return true;
      }
      return super.action(e,arg);
   }
}
Click Here to run this applet.

The JOTSA Lists

JOTSA actually needs to keep several lists of objects to be displayed.

Vectors in Java

A vector is an ordered collection of arbitrary objects. Click Here for Vector documentation.

Time in JOTSA

JOTSA uses a time which is related to real time so that the animation looks the same on fast and very fast machines.

On machines that are too slow to keep up with the animation, the objects still move at the correct rate, but they move less smoothly.

Properties of JOTSA virtual time:


The virtual time object

The virtual time object keeps track of the following: Calculation of current virtual time from real time:

       long real_time_now;
       long virtual_time_now;

       real_time_now = new Date().getTime();
       virtual_time_now = virtual_time_saved +
          (long)((timenow - real_time_saved)*time_rate);
This essentially calculates a straight line though the saved point with the correct slope.

To stop time:

To restart time: To change the rate: To increment the virtual time while the time is stopped: To make the time run backwards:

Contolling paint

In the traditional java applet: This has several problems: How JOTSA differs

JOTSA timing details


The JotsaAnimationObject

This is the object corresponding to a single object to be displayed:

Currently supported objects

Note that this list in increasing weekly

Some methods from JotsaAnimationObjectList

The following methods set the object to be drawn to be an oval. There are similar methods for filled oval, rectangle, and filled rectangle. public void set_draw_oval(int width, int height, Color C);

public void set_draw_centered_oval(int width, int height, Color C);

public void set_draw_centered_oval_string(int width, int height, String str, Color C);

public void set_draw_centered_oval_string(int width, int height, int fsize, String str, Color C);

public void set_draw_centered_oval_string(int width, int height, String str, Color C1, Color C2);

public void set_draw_centered_oval_string(int width, int height, int fsize, String str, Color C1, Color C2);

public void set_draw_centered_oval_string(int width, int height, String fname, int fstyle, int fsize, String str, Color C1, Color C2);


There are seveal methods for drawing strings. The following is the most general. It allows for the setting of the font, and causes several lines of text to be displayed.

public void set_draw_strings(String str, String fname, int fstyle, int fsize, Color C1, Color C2, int high_start, int high_num);


You can also display an image, say from a GIF file using

public void set_image(Image im);