import java.applet.*; import java.util.*; import java.awt.*; interface timerObject { public void do_update(); } class Point2d5 { float x, y; Point2d5() { x = 0f; y = 0f; } Point2d5(float x0, float y0) { x = x0; y = y0; } } /* ---------------------------------------------------------------------------- */ class DrawSpirolat5 extends Canvas implements timerObject { float splistang[] = { 18f, 18f, 20f, 20f, 22.5f, 22.5f, 22.5f,25.714f,25.714f, 30f, 30f, 30f, 30f, 36f, 36f, 36f, 36f, 36f, 40f, 45f, 45f, 45f, 45f, 45f, 54f, 54f, 60f, 60f, 60f, 60f, 60f, 72f, 72f, 72f, 75f, 75f, 75f, 84f, 84f, 90f, 90f, 90f, 90f, 90f, 90f, 96f, 100f, 100f, 105f, 108f, 108f, 108f, 120f, 120f, 120f, 126f, 132f, 132f, 135f }; int spliststep[] = { 4, 5, 3, 6, 2, 4, 8, 2, 4, 2, 3, 4, 6, 1, 2, 3, 4, 7, 6, 1, 2, 3, 4, 6, 4, 5, 2, 4, 5, 7, 8, 2, 4, 6, 4, 6, 8, 3, 5, 3, 5, 6, 7, 9, 10, 10, 3, 6, 8, 2, 3, 6, 4, 8, 10, 10, 5, 10, 6 }; int splistrepeat[] = { 5, 4, 3, 3, 8, 4, 2, 7, 7, 6, 4, 3, 2, 5, 5, 5, 5, 5, 3, 8, 4, 8, 2, 4, 5, 4, 3, 3, 3, 3, 3, 5, 5, 5, 6, 4, 3, 5, 3, 4, 4, 2, 4, 4, 2, 3, 3, 3, 3, 5, 5, 5, 3, 3, 3, 2, 3, 3, 4 }; String splistrevs[] = new String[520]; int splistrevnum,splistrevmax; int splistmax, splistnum; float tklist[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; int tklistmax, tklistnum; float widsang[] = { 18f, 20f, 22.5f, 25.714f, 30f, 36f, 40f, 45f, 180f }; float widsmax[] = { 0.32f, 0.36f, 0.41f, 0.48f, 0.57f, 0.72f, 0.83f, 0.99f, 0.99f }; boolean drwlistf[] = { true, false }; boolean drwlistc[] = { true, true }; boolean drwliste[] = { true, true }; int drwlistmax, drwlistnum; float tangle; int nsteps, nrepeat; double widfact; String nlefts; boolean clrepeat, clstep, drwfill, drwcenter, drwedges; boolean firstime, isready; boolean showdata; Color BackColor; int stptime, drwtime, clrtime; public DrawSpirolat5() { /* set initial values */ splistmax = splistang.length - 1; splistnum = 0; tklistmax = 3; tklistnum = 0; drwlistmax = 0; drwlistnum = 0; splistrevnum = 0; splistrevmax = 0; tangle = (float)splistang[splistnum]; nsteps = spliststep[splistnum]; nrepeat = splistrepeat[splistnum]; buildrevs(nsteps); } public void do_update() { if (isready) { /* inc to next set of values */ drwlistnum = drwlistnum + 1; if (drwlistnum > drwlistmax) { drwlistnum = 0; tklistnum = tklistnum + 1; if ((splistrevnum > 0) && (tklistnum > 1)) tklistnum = tklistmax + 1; if (tklistnum > tklistmax) { tklistnum = 0; splistrevnum = splistrevnum + 1; if (splistrevnum > splistrevmax) { splistnum = splistnum + 1; if (splistnum > splistmax) splistnum = 0; tangle = (float)splistang[splistnum]; nsteps = spliststep[splistnum]; nrepeat = splistrepeat[splistnum]; buildrevs(nsteps); splistrevnum = 0; } } } isready = false; repaint(); } } public void paint(Graphics g) { float walllen = 10; int numlines = 0; int irepeat, istep; int count = 0, ncount = 0; int into,inti; int docont = 0; int npts = 0; float xmin = 10000, ymin = 10000, xmax = -10000, ymax = -10000; float totalangle = 0; float itotalangle; int iturn, niturn; int nlen; float xdim, ydim, pscale; float xtrans, ytrans; int i = 0; int j = 0; int pxpt = 0, pypt = 0, clxpt = 0, clypt = 0; int pxtrans, pytrans; int ilxpt = 0, ilypt = 0, olxpt = 0, olypt = 0; String cstep, ctemp; Point2d5 pt1 = new Point2d5(0,0), pt2 = new Point2d5(0,0); Point2d5 fpt1 = new Point2d5(0,0); Point2d5 fipt = new Point2d5(0,0), fopt = new Point2d5(0,0); Point2d5 ipt1 = new Point2d5(0,0), opt1 = new Point2d5(0,0); Point2d5 ipt2 = new Point2d5(0,0), opt2 = new Point2d5(0,0); Point2d5 ipt3 = new Point2d5(0,0), opt3 = new Point2d5(0,0); Point2d5 ipt4 = new Point2d5(0,0), opt4 = new Point2d5(0,0); float cdist; Point2d5 cpts[] = new Point2d5[250]; Point2d5 ipts[] = new Point2d5[250]; Point2d5 opts[] = new Point2d5[250]; int polyx[] = new int[4]; int polyy[] = new int[4]; /* System.out.println("next"); */ tangle = (float)splistang[splistnum]; nsteps = spliststep[splistnum]; nrepeat = splistrepeat[splistnum]; nlefts = splistrevs[splistrevnum]; widfact = tklist[tklistnum]; drwfill = drwlistf[drwlistnum]; drwcenter = drwlistc[drwlistnum]; drwedges = drwliste[drwlistnum]; float wfact = (float)widfact/2; pt1 = new Point2d5(0,0); numlines = 0; npts=0; ctemp = "0,"+nlefts; for (irepeat = 1; irepeat <= nrepeat; irepeat++) { nlen = 10; count = 1; for (istep = 1; istep <= nsteps; istep++) { /* check for left turn */ cstep = ","+String.valueOf(istep); iturn = -1; if (ctemp.indexOf(cstep) > 0) iturn = 1; /* inc angle */ totalangle = totalangle + (float)((180.0 - tangle) * iturn); pt2 = Polar(pt1.x, pt1.y, totalangle, (float)nlen); /* first inside/outside point */ if (numlines==0) { cstep = ","+String.valueOf(2); niturn = -1; if (ctemp.indexOf(cstep) > 0) niturn = 1; itotalangle = totalangle - 90; if (niturn==1) itotalangle = totalangle + 90; fpt1 = pt1; ipt1 = Polar(fpt1.x,fpt1.y,itotalangle,(walllen * wfact)); opt1 = Polar(fpt1.x,fpt1.y,(itotalangle+180),(walllen * wfact)); npts = npts + 1; cpts[npts] = pt1; if (niturn==1) { ipt2 = ipt1; ipt1 = opt1; opt1 = ipt2; } fipt = ipt1; fopt = opt1; } /* distance to next point */ cdist = Distance(fpt1,pt2); /* check for last point */ if ((numlines == ((nrepeat*nsteps)-1)) && (cdist > 0.1)) { /* edges on current line */ ipt2 = Polar(ipt1.x,ipt1.y,totalangle,(nlen*5)); opt2 = Polar(opt1.x,opt1.y,totalangle,(nlen*5)); itotalangle = totalangle; ipt3 = pt2; ipt4 = Polar(ipt3.x,ipt3.y,(itotalangle+90),(nlen*5)); opt3 = pt2; opt4 = Polar(opt3.x,opt3.y,(itotalangle-90),(nlen*5)); /* compute intersection */ ipt2 = xyint(ipt1,ipt2,ipt3,ipt4); opt2 = xyint(opt1,opt2,opt3,opt4); } /* check for not last point */ if ((numlines != ((nrepeat*nsteps)-1)) || (cdist < 0.1)) { /* edges on current line */ ipt2 = Polar(ipt1.x,ipt1.y,totalangle,(nlen*5)); opt2 = Polar(opt1.x,opt1.y,totalangle,(nlen*5)); /* edges on next line */ ncount = count+1; if (ncount > nsteps) ncount=1; cstep = ","+String.valueOf(ncount); niturn = -1; if (ctemp.indexOf(cstep) > 0) niturn = 1; itotalangle = (totalangle + ((180 - tangle) * niturn)); ipt3 = Polar(pt2.x,pt2.y,(itotalangle-90),(walllen*wfact)); ipt4 = Polar(ipt3.x,ipt3.y,itotalangle,(nlen*5)); opt3 = Polar(pt2.x,pt2.y,(itotalangle+90),(walllen*wfact)); opt4 = Polar(opt3.x,opt3.y,(itotalangle+180),(nlen*5)); /* compute intersection */ ipt2 = xyint(ipt1,ipt2,ipt3,ipt4); opt2 = xyint(opt1,opt2,opt3,opt4); /* check for intersection on outside edge */ opt3 = Polar(opt2.x,opt2.y,itotalangle,(nlen*5)); into = ifint(ipt1,ipt2,opt2,opt3); /* check for intersection on inside edge */ ipt3 = Polar(ipt2.x,ipt2.y,itotalangle,(nlen*5)); inti = ifint(ipt2,ipt3,opt1,opt2); /* check intersections - flip inside and outside */ if ((into == 1) || (inti == 1)) { /* edges on current line */ ipt2 = Polar(ipt1.x,ipt1.y,totalangle,(nlen*5)); opt2 = Polar(opt1.x,opt1.y,totalangle,(nlen*5)); /* edges on next line */ ncount = count+1; if (ncount > nsteps) ncount=1; cstep = ","+String.valueOf(ncount); niturn = -1; if (ctemp.indexOf(cstep) > 0) niturn = 1; itotalangle = totalangle+((180-tangle)*niturn); ipt3 = Polar(pt2.x,pt2.y,(itotalangle+90),(walllen*wfact)); ipt4 = Polar(ipt3.x,ipt3.y,(itotalangle+180),(nlen*5)); opt3 = Polar(pt2.x,pt2.y,(itotalangle-90),(walllen*wfact)); opt4 = Polar(opt3.x,opt3.y,itotalangle,(nlen*5)); /* compute intersection */ ipt2 = xyint(ipt1,ipt2,ipt3,ipt4); opt2 = xyint(opt1,opt2,opt3,opt4); } } /* check if closed */ if (cdist < 0.1) { if (widfact < 1.0) { fipt = ipt2; fopt = opt2; } docont = 1; } npts = npts + 1; ipts[npts] = ipt2; opts[npts] = opt2; cpts[npts] = pt2; /* min/max */ if (pt2.x > xmax) xmax = pt2.x; if (pt2.x < xmin) xmin = pt2.x; if (pt2.y > ymax) ymax = pt2.y; if (pt2.y < ymin) ymin = pt2.y; if (ipt2.x > xmax) xmax = ipt2.x; if (ipt2.x < xmin) xmin = ipt2.x; if (ipt2.y > ymax) ymax = ipt2.y; if (ipt2.y < ymin) ymin = ipt2.y; if (opt2.x > xmax) xmax = opt2.x; if (opt2.x < xmin) xmin = opt2.x; if (opt2.y > ymax) ymax = opt2.y; if (opt2.y < ymin) ymin = opt2.y; nlen = nlen + 10; ipt1 = ipt2; opt1 = opt2; pt1 = pt2; numlines = numlines+1; /* check for points */ if ((npts == 249) || (docont == 1)) { istep = nsteps + 1; irepeat = nrepeat + 1; } count = count + 1; } } /* set first point */ ipts[1] = fipt; opts[1] = fopt; /* compute scale to canvas size */ xdim = xmax - xmin; ydim = ymax - ymin; pscale = Math.min((size().width-80) / xdim, (size().height-80) / ydim); xtrans = (float) (0 - xmin); ytrans = (float) (0 - ymin); pxtrans = (((size().width-80) - (int)(xdim * pscale))/2)+40; pytrans = (((size().height-80) - (int)(ydim * pscale))/2)+40; int numpixels = (int)((widfact*10) * pscale); int maxpixels = (int)(10 * pscale); /* System.out.println(splistnum+" "+tklistnum+" "+drwlistnum+" "+numpixels+" "+maxpixels); */ /* set thickness */ if (tklistnum == 0) { tklist[1] = (float)(16.0/maxpixels); float maxwid = tklist[1]; for (i = 0; i < widsang.length; i++) { if (tangle <= widsang[i]) { maxwid = widsmax[i]; i = widsang.length + 1; } } tklist[2] = (float)(tklist[1]+((maxwid-tklist[1])/2)); tklist[3] = (float)maxwid; drwlistnum = drwlistmax; System.out.println(splistnum+"/"+tklist[1]+" "+tklist[2]+" "+tklist[3]+" "+tklist[4]); } if (tklistnum > 0) { /* clear screen */ if (drwlistnum == 0) { g.setColor(BackColor); g.fillRect(0,0,size().width,size().height); firstime = false; } /* draw spirolateral */ if (showdata) { g.setColor(Color.black); g.setFont( new Font("TimesRoman",Font.BOLD, 14)); g.drawString("Angle: "+String.valueOf(tangle)+ " Steps: "+String.valueOf(nsteps)+ " Repeats: "+String.valueOf(nrepeat)+ " Reverse at: "+nlefts, (int)(size().width*0.05), (int)(size().height*(0.05))); } g.setColor(Color.black); g.setFont( new Font("TimesRoman",Font.BOLD, 18)); g.drawString("< ? >", (int)(size().width*0.05), (int)(size().height*(0.95))); /* angle */ g.drawArc((int)(size().width*0.85), (int)(size().height*(0.90)), 40,40,0,180); g.drawLine((int)((size().width*0.85)+0), (int)((size().height*(0.90))+20), (int)((size().width*0.85)+40), (int)((size().height*(0.90))+20) ); opt4 = Polar((int)((size().width*0.85)+20), (int)((size().height*0.90)+20),-tangle,20f); g.drawLine((int)((size().width*0.85)+20), (int)((size().height*0.90)+20), (int)opt4.x,(int)opt4.y); if (drwlistnum == 0) { g.setColor(Color.black); for (i = 1; i <= npts; i++) { pxpt = Math.round( (((cpts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((cpts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(clxpt,clypt,pxpt,pypt); clxpt = pxpt; clypt = pypt; pxpt = Math.round( (((ipts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((ipts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(ilxpt,ilypt,pxpt,pypt); ilxpt = pxpt; ilypt = pypt; pxpt = Math.round( (((opts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((opts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(olxpt,olypt,pxpt,pypt); olxpt = pxpt; olypt = pypt; try { Thread.sleep(stptime); } catch (InterruptedException e) {} } g.setColor(Color.black); for (i = 1; i <= npts; i++) { polyx[3] = Math.round( (((ipts[i].x+xtrans)*pscale)+pxtrans) ); polyy[3] = Math.round( (((ipts[i].y+ytrans)*pscale)+pytrans) ); polyx[2] = Math.round( (((opts[i].x+xtrans)*pscale)+pxtrans) ); polyy[2] = Math.round( (((opts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.fillPolygon(polyx, polyy, 4); polyx[0] = polyx[3]; polyy[0] = polyy[3]; polyx[1] = polyx[2]; polyy[1] = polyy[2]; try { Thread.sleep(stptime); } catch (InterruptedException e) {} } g.setColor(BackColor); for (j = 1; j <= 2; j++) { for (i = 1; i <= npts; i++) { pxpt = Math.round( (((cpts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((cpts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(clxpt,clypt,pxpt,pypt); clxpt = pxpt; clypt = pypt; try { Thread.sleep(stptime); } catch (InterruptedException e) {} }} /* draw edges */ if (splistrevnum == 0) { for (j = 1; j <= 2; j++) { for (i = 1; i <= npts; i++) { pxpt = Math.round( (((ipts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((ipts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(ilxpt,ilypt,pxpt,pypt); ilxpt = pxpt; ilypt = pypt; pxpt = Math.round( (((opts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((opts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(olxpt,olypt,pxpt,pypt); olxpt = pxpt; olypt = pypt; try { Thread.sleep(stptime); } catch (InterruptedException e) {} }} } /* at end of drawing */ try { Thread.sleep(drwtime); } catch (InterruptedException e) {} } /* erase */ g.setColor(BackColor); for (i = 1; i <= npts; i++) { polyx[3] = Math.round( (((ipts[i].x+xtrans)*pscale)+pxtrans) ); polyy[3] = Math.round( (((ipts[i].y+ytrans)*pscale)+pytrans) ); polyx[2] = Math.round( (((opts[i].x+xtrans)*pscale)+pxtrans) ); polyy[2] = Math.round( (((opts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.fillPolygon(polyx, polyy, 4); polyx[0] = polyx[3]; polyy[0] = polyy[3]; polyx[1] = polyx[2]; polyy[1] = polyy[2]; /* edges */ pxpt = Math.round( (((ipts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((ipts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(ilxpt,ilypt,pxpt,pypt); ilxpt = pxpt; ilypt = pypt; pxpt = Math.round( (((opts[i].x+xtrans)*pscale)+pxtrans) ); pypt = Math.round( (((opts[i].y+ytrans)*pscale)+pytrans) ); if (i != 1) g.drawLine(olxpt,olypt,pxpt,pypt); olxpt = pxpt; olypt = pypt; try { Thread.sleep(clrtime); } catch (InterruptedException e) {} } g.setColor(BackColor); g.fillRect(0,0,size().width,size().height); } isready = true; } /* ---------------------------------------------------------------------------- */ public float Distance(Point2d5 p1, Point2d5 p2) { return (float)Math.sqrt((float)Math.pow(p1.x-p2.x,2)+(float)Math.pow(p1.y-p2.y,2)); } /* ---------------------------------------------------------------------------- */ public Point2d5 Polar(float xpt, float ypt, float ang, float dist) { return (new Point2d5( (float) (xpt + (dist * Math.cos((double)ang * (3.14156/180)))), (float) (ypt + (dist * Math.sin((double)ang * (3.14156/180)))))); } /* ---------------------------------------------------------------------------- */ public Point2d5 xyint(Point2d5 p1, Point2d5 p2, Point2d5 p3, Point2d5 p4) { double a, b, e, c, d, f; double xk, yk, xl, yl, xm, ym, xn, yn; /* first, check to see if the segments intersect by parameterization on s and t; if s and t are both between [0,1], then the segments intersect */ xk = (double)p1.x; yk = (double)p1.y; xl = (double)p2.x; yl = (double)p2.y; xm = (double)p3.x; ym = (double)p3.y; xn = (double)p4.x; yn = (double)p4.y; /* check to see if the segments have any endpoints in common. If they do, then return the endpoints as the intersection point */ if ((xk==xm) && (yk==ym)) { return (new Point2d5((float)xk, (float)yk)); } if ((xk==xn) && (yk==yn)) { return (new Point2d5((float)xk, (float)yk)); } if ((xl==xm) && (yl==ym)) { return (new Point2d5((float)xl, (float)yl)); } if ((xl==xn) && (yl==yn)) { return (new Point2d5((float)xl, (float)yl)); } /* check to see if they intersect */ a = -(yl-yk); b = xl-xk; c = -(yn-ym); d = xn-xm; e = -(a*xk)-(b*yk); f = -(c*xm)-(d*ym); /* they intersect, so compute the intersection point using ax+by+e = 0 and cx+dy+f = 0 */ return (new Point2d5((float)(-(e*d-b*f)/(a*d-c*b)), (float)(-(a*f-c*e)/(a*d-c*b)))); } /* ---------------------------------------------------------------------------- */ public int ifint(Point2d5 p1, Point2d5 p2, Point2d5 p3, Point2d5 p4) { double xk, yk, xl, yl, xm, ym, xn, yn; double s, t; /* first, check to see if the segments intersect by parameterization on s and t; if s and t are both between [0,1], then the segments intersect */ xk = (double)p1.x; yk = (double)p1.y; xl = (double)p2.x; yl = (double)p2.y; xm = (double)p3.x; ym = (double)p3.y; xn = (double)p4.x; yn = (double)p4.y; s = (double)(((xn-xm)*(ym-yk)-(yn-ym)*(xm-xk))/((xn-xm)*(yl-yk)-(yn-ym)*(xl-xk))); t = (double)(((xl-xk)*(ym-yk)-(yl-yk)*(xm-xk))/((xn-xm)*(yl-yk)-(yn-ym)*(xl-xk))); if (((s < 1) && (s > 0)) && ((t < 1) && (t > 0))) return 1; return 0; } /* ---------------------------------------------------------------------------- */ public float testdist() { float walllen = 10; int irepeat, istep; float totalangle = 0; int iturn, niturn; int nlen; String cstep, ctemp; Point2d5 pt1 = new Point2d5(0,0), pt2 = new Point2d5(0,0); Point2d5 fpt1 = new Point2d5(0,0); float cdist = 0f; ctemp = "0,"+nlefts; for (irepeat = 1; irepeat <= nrepeat; irepeat++) { nlen = 1; for (istep = 1; istep <= nsteps; istep++) { /* check for left turn */ cstep = ","+String.valueOf(istep); iturn = -1; if (ctemp.indexOf(cstep) > 0) iturn = 1; /* inc angle */ totalangle = totalangle + (float)((180.0 - tangle) * iturn); pt2 = Polar(pt1.x, pt1.y, totalangle, (float)nlen); /* distance to next point */ cdist = Distance(fpt1,pt2); nlen = nlen + 1; pt1 = pt2; } } return cdist; } /* ---------------------------------------------------------------------------- */ public void buildrevs(int maxpos) { int revlist[] = { 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; int numlefts; float cdist; int revpos = 1; int curpos = 1; int nrevs = 0; String revstr; splistrevmax = 0; splistrevs[0] = "0,0,0"; while ((curpos < 2) && (maxpos > 1)) { if (revlist[maxpos] != maxpos) { } numlefts = 0; nrevs = nrevs + 1; revstr = ""; for (int j=1; j < revlist.length; j++) { if (revlist[j] > 0) { if (j > 1) revstr = revstr + ","; revstr = revstr + String.valueOf(revlist[j]); numlefts = numlefts + 1; } } nlefts = revstr; cdist = (testdist()*100); if (((int)cdist == 0) && (numlefts != maxpos)) { splistrevmax = splistrevmax + 1; splistrevs[splistrevmax] = revstr; } System.out.println(splistrevmax+"/"+revstr+"--"+cdist); curpos = revlist[revpos]; if (curpos < maxpos) { revpos = revpos + 1; revlist[revpos] = curpos + 1; } else { revlist[revpos] = 0; if (revpos > 1) { revpos = revpos - 1; curpos = revlist[revpos]; revlist[revpos] = curpos + 1; } } curpos = revlist[1]; } } /* ---------------------------------------------------------------------------- */ } class myTimer extends Thread { int time; timerObject timer_object; public myTimer(timerObject to, int t) { timer_object = to; time = t; } public void run() { while (true) { try { sleep(time); } catch (InterruptedException e) {} timer_object.do_update(); } } } /* ---------------------------------------------------------------------------- */ /* class PopupFrame extends Frame { public boolean handleEvent(Event evt) { if( evt.id == Event.WINDOW_DESTROY) dispose(); return super.handleEvent(evt); } } */ /* ---------------------------------------------------------------------------- */ public class sprolat5 extends Applet { DrawSpirolat5 pict = new DrawSpirolat5(); myTimer mytimer = new myTimer(pict, 1200); Panel opt1, opt2, opt3, optn, opts; String line1, line2, line3; public void init() { /* brown Color(156,123,75) */ /* light Color(221,206,178) */ Color ColorBeige = new Color(221,206,178); this.setBackground(ColorBeige); pict.BackColor = ColorBeige; pict.setBackground(ColorBeige); pict.firstime = true; pict.isready = true; pict.showdata = false; pict.stptime = 40; pict.drwtime = 1500; pict.clrtime = 40; /* pict.notes[0] = getAudioClip(getCodeBase(), "cnote.au"); pict.notes[1] = getAudioClip(getCodeBase(), "dnote.au"); pict.notes[2] = getAudioClip(getCodeBase(), "enote.au"); pict.notes[3] = getAudioClip(getCodeBase(), "fnote.au"); pict.notes[4] = getAudioClip(getCodeBase(), "gnote.au"); pict.notes[5] = getAudioClip(getCodeBase(), "anote.au"); pict.notes[6] = getAudioClip(getCodeBase(), "bnote.au"); pict.notes[7] = getAudioClip(getCodeBase(), "c1note.au"); */ setLayout(new BorderLayout() ); add("Center", pict); mytimer.start(); } public void Stop() { mytimer.stop(); } public void repaint() { } public boolean mouseDown(Event evt, int x, int y) { System.out.println("Down: " + x + ", " + y); /* based on ? at 48,468 (500,500) [18 1 18 1 18] */ if (x > 39 && x < 57 && y > 459 && y < 477) { if (pict.showdata) { pict.showdata = false; System.out.println("ShowData "+pict.showdata); return true; } pict.showdata = true; System.out.println("ShowData "+pict.showdata); return true; } if (x > 59 && x < 77 && y > 459 && y < 477) { pict.splistnum = pict.splistnum + 1; pict.tklistnum = 0; pict.drwlistnum = -1; System.out.println("Right"); } if (x > 20 && x < 38 && y > 459 && y < 477) { System.out.println("Left"); pict.splistnum = pict.splistnum - 1; if (pict.splistnum < 0) pict.splistnum = 1; pict.tklistnum = 0; pict.drwlistnum = -1; } /* if ( (y < pict.size().height/2) ){ line1 = "Angle: "+String.valueOf(pict.tangle); line2 = "Steps: "+String.valueOf(pict.nsteps); line3 = "Repeat: "+String.valueOf(pict.nrepeat); PopupFrame f = new PopupFrame(); f.resize(50,10); f.add("North", new Label(line1, Label.LEFT)); f.show(); } */ return true; } } /* ---------------------------------------------------------------------------- */