/* Movie digitizer */ import java.awt.*; import java.applet.*; public class digflow extends Applet { public MediaTracker tracker, trackerBg; public Image offScreenImage; public Image theBox, theBack; public boolean copyRight = false; public boolean digiflag = true, plotflag = false; public char cr = '\r', lf = '\n'; // cr works on the Mac, but not on Unix or Windows public String theImageName = "p01.jpg"; public int numPict = 1; public int xdigi[] = new int[100], ydigi[] = new int[100]; public double yi[] = new double[100]; public void init() { super.init(); offScreenImage = createImage(500,360); //{{INIT_CONTROLS setLayout(null); resize(620,360); textArea1 = new java.awt.TextArea(); textArea1.reshape(500,0,120,360); textArea1.setFont(new Font("Courier", Font.PLAIN, 10)); add(textArea1); //}} trackerBg = new MediaTracker(this); theBack = this.getImage(getCodeBase(),"bg.jpg"); trackerBg.addImage(theBack,0); try { trackerBg.waitForID(0); } catch (InterruptedException e) { } getNextImage(theImageName); repaint(); } public void update(Graphics g){ Graphics offg = offScreenImage.getGraphics(); paint(offg); g.drawImage(offScreenImage, 0, 0, this); } public void getNextImage(String theName){ tracker= new MediaTracker(this); theBox = this.getImage(getCodeBase(),theName); tracker.addImage(theBox,0); try { tracker.waitForID(0); } catch (InterruptedException e) { } } public void paint(Graphics g){ g.setColor(Color.white); g.fillRect(0,0,500,360); g.drawImage(theBack,0,0,theBack.getWidth(this),theBack.getHeight(this),this); if (digiflag) { g.fillRect(0,0,350,360); g.drawImage(theBox,0,0,theBox.getWidth(this),theBox.getHeight(this),this); } // labels: active ones are red, passive are gray g.setFont(new Font("Helvetica", Font.BOLD, 14)); g.setColor(Color.blue); g.drawString("Undo Pt.",433,121); g.setColor(Color.darkGray); if (plotflag && digiflag) g.setColor(Color.red); g.drawString("Plot y(x)",433,88); if (digiflag) { g.setColor(Color.red); g.drawString("Digitize",433,22); g.setColor(Color.darkGray); g.drawString("Plot h(t)",433,55); } else { g.setColor(Color.darkGray); g.drawString("Digitize",433,22); g.setColor(Color.red); g.drawString("Plot h(t)",433,55); } // data points g.setColor(Color.red); if (plotflag && digiflag) { for (int i=1; i 423 && yy < 133 && yy > 101 && numPict > 1) { numPict--; if (numPict < 10) { theImageName = "p0"+numPict+".jpg"; } else { theImageName = "p"+numPict+".jpg"; } getNextImage(theImageName); repaint(); } if (xx > 423 && yy < 100 && yy > 68) { plotflag = !plotflag; repaint(); } if (xx > 423 && yy < 33 && yy > 2) { digiflag = true; repaint(); } if (xx > 423 && yy < 66 && yy > 35) { digiflag = false; repaint(); } } }