// plot_toro.java plot toro ortho with height colors import java.io.*; import java.*; import java.awt.*; import java.awt.event.*; public class plot_toro extends Frame { // mouse and display variables int xm, ym, bm; // mouse position int height = 700; int width = 700; double xmin = -1.0; // typically determined from data double xmax = 1.0; double ymin = -1.0; double ymax = 1.0; double zmin = -1.0; double zmax = 1.0; double tmin = 0.0; double tmax = 6.28318; double pmin = 0.0; double pmax = 6.28318; double qmin = 0.0; double qmax = 6.28318; double amin = 0.0; double amax = 6.28318; double R = 0.5; double r = 0.2; double t = tmin; double p = pmin; double q = qmin; // rotation X Z double a = amin; // rotation Y Z int nx = 10; int ny = 10; int nz = 10; int nt = 16; int np = 16; int nq = 16; int na = 16; double hx = (xmax-xmin)/nx; double hy = (ymax-ymin)/ny; double hz = (zmax-zmin)/nz; double ht = (tmax-tmin)/nt; double hp = (pmax-pmin)/np; double hq = (qmax-qmin)/nq; double ha = (amax-amin)/na; double ya = 0.5; // orthographic typ 0.1 to 0.5 double xs = (0.666*(width-100))/(xmax-xmin); double ys = (0.666*(height-100))/(ymax-ymin); int xp, yp; // computed by toro public plot_toro() { System.out.println("plot_toro.java running"); setTitle("plot_toro"); setSize(width,height); setBackground(Color.white); setForeground(Color.black); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); this.addMouseListener (new mousePressHandler()); do_plot(); } // plot_toro constructor void do_plot() { // set up here // plot repaint(); // wait for mouse events } // end do_program class mousePressHandler extends MouseAdapter { public void mousePressed (MouseEvent e) { xm = e.getX(); ym = e.getY(); bm = e.getButton(); // System.out.println("down xm="+xm+", ym="+ym+", bm="+bm); // debug if(in_rect(width-70, height-20, 30, 20)) { // do something, run requestFocus(); MyThread do_run = new MyThread(); // allocate do_run thread do_run.start(); // terminates } else if(in_rect(width-125, height-20, 40, 20)) { // do something, nextq q = q + hq; requestFocus(); repaint(); } else if(in_rect(width-165, height-20, 40, 20)) { // do something, nexta a = a + ha; requestFocus(); repaint(); } if(in_rect(width-35, height-20, 30, 20)) System.exit(0); } // end mousePressed } // end mousePressHandler boolean in_rect(int x, int y, int w, int h) { return xm>x && xmy && ym