import java.lang.Thread; import java.awt.*; public class polyAnim extends Thread { boolean liveFlag; nCanvas pic; Button ssb; double a,b; double x0,y0,x1,y1; double x,y,xnew,ynew; public void getNumbers(){ poly.getNumbers(); this.a=poly.a; this.b=poly.b; this.x0=poly.x0; this.y0=poly.y0; this.x1=poly.x1; this.y1=poly.y1; } public polyAnim(){ this.pic=poly.pic; this.ssb=poly.ssButton; getNumbers(); pic.eraseBuff(); pic.update(pic.getGraphics()); pic.screen(x0,y0,x1,y1); liveFlag=false; } public void myStart(){ liveFlag=false; ssb.setLabel("stop"); getNumbers(); pic.eraseBuff(); pic.update(pic.getGraphics()); pic.screen(x0,y0,x1,y1); prepare(); liveFlag=true; start(); } public void myStop(){ liveFlag=false; ssb.setLabel("start"); while(this.isAlive()){} } public void prepare(){ x=0.0; y=0.0; // pass first 1000 points for(int i=0;i<1000;i++){ xnew=fx(x,y); ynew=fy(x,y); x=xnew; y=ynew; } } public void run(){ while(liveFlag){ pic.drawPoint(x,y); xnew=fx(x,y); ynew=fy(x,y); x=xnew; y=ynew; } } ////// Polynomial map ////// public double fx (double x, double y){ return(b*x + a - y*y); } public double fy(double x,double y){ return(x); } }