// July 2002, java applet by Oliver Knill for the CCP project // Green's Theorem and the Planimeter by Oliver Knill and Dale Winter // Harvard University, Nov 15, 2002. See // http://math.duke.edu/education/ccp/materials/mvcalc/green // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License of the Free Software Foundation for // details. Compile with // javac instrument.java comment.java wheel.java curve.java planimeter.java import java.applet.*; import java.awt.*; public class planimeter extends Applet { static final long serialVersionUID = -1L; instrument planimeter1; wheel wheel1; curve curve1; comment comment1; double sum1=0; // integral value boolean active1=false; // went over start point int curve_choice=0; // the chosen curve boolean change=false; // only erase curve if change=true boolean found=false; // line integral has been found? boolean counting=false; // line integral in progress public void init() { planimeter1 = new instrument(500,500); wheel1 = new wheel(500,500); curve1 = new curve(500,500); comment1 = new comment(500,500); } public void paint(Graphics g) { planimeter1.paint(g); planimeter1.update(g); repaint(); } public void update(Graphics g) { sum1=wheel1.update(g,active1); planimeter1.update(g); counting=wheel1.sum_counting(); curve1.menu(g,change,curve_choice); if (change) { curve1.erase(g); change=false; } if (counting || Math.abs(sum1)<1) { comment1.update(g,sum1); } curve1.update(g,active1,curve_choice); } public boolean mouseDrag(Event event,int x,int y) { planimeter1.set_pointer(x,y); wheel1.read_pointer(x,y); if ((Math.abs(x-430)<5) && (Math.abs(y-200)<5)) { active1=true; } repaint(); return true; } public boolean mouseDown(Event event,int x,int y) { planimeter1.set_pointer(x,y); wheel1.read_pointer(x,y); if ((Math.abs(y-150)<25) && (Math.abs(x)<50)) { curve_choice=1; change=true; found=false; } if ((Math.abs(y-200)<25) && (Math.abs(x)<50)) { curve_choice=2; change=true; found=false; } if ((Math.abs(y-250)<25) && (Math.abs(x)<50)) { curve_choice=3; change=true; found=false; } if ((Math.abs(y-300)<25) && (Math.abs(x)<50)) { curve_choice=4; change=true; found=false; } if ((Math.abs(y-350)<25) && (Math.abs(x)<50)) { curve_choice=5; change=true; found=false; } if ((Math.abs(y-400)<25) && (Math.abs(x)<50)) { curve_choice=6; change=true; found=false; } repaint(); return true; } }