A simple JOTSA applet will do the following:
public void paint(Graphics g) {
JotsaPaintStart();
JotsaDisplayCanvases();
JotsaPaintEnd();
}
This takes care of all popups and scaled windows.
A popup jotsa creates an additional canvas with a few buttons such as hide and remove.
Scaled windows will consist of a
You can overide eith of these:
public boolean JotsaHandleCanvasEvent(Event e, JotsaCanvas canv); public boolean JotsaHandleCanvasEvent(Event e);The first gives you the Canvas from which the event occurred.
The default
JotsaHandleCanvasEvent(Event e, JotsaCanvas canv)just calls
JotsaHandleCanvasEvent(e)and returns if this returned true; Otherwise it returns false. The default
JotsaHandleCanvasEvent(Event e)just returns false.
If your JotsaHandleCanvasEvent handles the event it should return true, otherwise it should return super.handleEvent(e);
/*
< Applet code = "jtest1.simple"
width = 200 height = 200 >
< /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() {
super.init();
setLayout(new BorderLayout());
add("South",doit = new Button("Do It"));
add("Center",JotsaDefaultCanvas);
validate();
JotsaInitImages();
JotsaWriteBackgroundString("A simple JOTSA example",20,100,Color.blue);
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);
}
}
package jtest2;
import java.awt.*;
import java.awt.image.*;
import java.applet.*;
import jotsa.*;
public class example extends JotsaAnimationApplet {
...
public void init() {
super.init();
width = bounds().width;
selected = -1;
height = setup_layout();
System.out.println("Height is "+height);
JotsaInitImages();
...
private int setup_layout() {
setLayout(new BorderLayout());
Panel p = new Panel();
Panel q = new Panel();
...
add("Center",JotsaDefaultCanvas);
add("South",p);
validate();
...
}
public boolean JotsaHandleCanvasEvent(Event e, JotsaCanvas canv) {
int move_time;
int level;
if (e.id == Event.MOUSE_DOWN) {
change_to_canvas(canv);
...