import java.awt.*; /** Program: NextWave81 Purpose: @author: Paul Garrett, garrett@math.umn.edu @version: 81, Sun Jan 26 14:53:56 CST 1997 */ public class NextWave81 extends java.applet.Applet implements Runnable { Thread theThread; int[][] thePoints; int theTime; final int numberSubintervals = 100; final int totalTime = 400; final int xIncrement = 4; int[] xs, thePosition, previousPosition; boolean queryMouseDown; boolean queryRun; // true if clicked to go int theIndex; // of point picked-up by mouse final int xinc = 2; final int yinc = 5; // size of handles, now invisible, though Color bgColor; // background Color fgColor; // foreground Image offScreenImage; // for double-buffering Graphics offScreenGraphics; // ditto Button firstButton, secondButton, thirdButton; /* Above are all the instance variables.... */ public void init() { theTime = 1; firstButton = new Button("Run"); add(firstButton); thirdButton = new Button("Smooth"); add(thirdButton); queryMouseDown = false; queryRun = false; xs = new int[numberSubintervals]; // thePosition = new int[numberSubintervals+1]; // the y's are init'd to 0's // previousPosition = new int[numberSubintervals+1]; // the y's are init'd to 0's for (int i=0; i 1) { thePoints[theTime -1][theIndex-1] = 150 - y; // Edit this } repaint(); } return true; } public boolean mouseUp(Event e, int x, int y) { if (queryMouseDown) { queryMouseDown = false; repaint(); } return true; } public boolean mouseDown(Event e, int x, int y) { for (int i=1; i< numberSubintervals; i++) { if ((Math.abs(x-(50 + i * xIncrement)) <= xinc) && (Math.abs(y-(150 - thePoints[theTime][i])) <= yinc)) { queryMouseDown = true; theIndex = i; } } return true; } } // the end