/* Movie digitizer */ import java.awt.*; import java.applet.*; public class digitize extends Applet { public MediaTracker tracker, trackerBg; public Image offScreenImage; public Image theBox, theBack; public boolean copyRight = false; public boolean digiflag = true, plotflag = false, twocart = false; public char cr = '\n'; public String theImageName = "elasll01.jpg"; public int numPict = 1; public int xdigi1[] = new int[100], ydigi1[] = new int[100]; public int xdigi2[] = new int[100], ydigi2[] = new int[100]; public double xi1[] = new double[100]; public double xi2[] = new double[100]; public void init() { super.init(); offScreenImage = createImage(500,360); //{{INIT_CONTROLS setLayout(null); resize(680,360); textArea1 = new java.awt.TextArea(); textArea1.reshape(500,0,180,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 x(t)",433,55); g.setFont(new Font("Helvetica", Font.BOLD, 18)); if (numPict < 23) { if (twocart) { g.setColor(Color.green); g.drawString("Click on cart 2",100,200); } else { g.setColor(Color.red); g.drawString("Click on cart 1",100,200); } } else { g.setColor(Color.black); g.drawString("Digitization Finished",100,200); } } else { g.setColor(Color.darkGray); g.drawString("Digitize",433,22); g.setColor(Color.red); g.drawString("Plot x(t)",433,55); } // data points g.setColor(Color.red); if (plotflag && digiflag) { g.setColor(Color.red); for (int i=1; i 423 && yy < 133 && yy > 101 && numPict > 1) { numPict--; twocart = false; if (numPict < 10) { theImageName = "elasll0"+numPict+".jpg"; } else { theImageName = "elasll"+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(); } } }