import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.awt.geom.*; /**This class draws the hexagonal path associated to a word. The bounding box is specified just like one specifies the box for a rectangle. The actual path is fit into the box exactly and then scaled down 5% so as to have leave a small border. The current max length of the word is 1000*/ public class hexPath { /**this routine draws the raw path, without any scaling.*/ public static Complex[] rawPath(String W) { Complex[] V=new Complex[1000]; String S=new String(); double pi=Math.PI; double arg1=pi/6+pi/2; double arg2=arg1+2*pi/3; double arg3=arg2+2*pi/3; Complex v1=new Complex(Math.cos(arg1),Math.sin(arg1)); Complex v2=new Complex(Math.cos(arg2),Math.sin(arg2)); Complex v3=new Complex(Math.cos(arg3),Math.sin(arg3)); Complex v4=new Complex(0,0); Complex v5=new Complex(0,0); Complex vv=new Complex(0,0); int n=W.length(); for(int i=0;iV[i].x) mx=V[i].x; if(MxV[i].y) my=V[i].y; if(My0) { Complex[] V=rawPath(W); Complex[] Z=getLocation(V,n); double size=Z[0].x; if(sizeh) bb=h; size=bb/size; size=size*.95; double xx=Z[1].x; double yy=Z[1].y; g.setColor(C); float x1,y1,x2,y2; GeneralPath path=new GeneralPath(); x1=(float)((V[0].x-xx)*size+w/2); y1=(float)((V[0].y-yy)*size+h/2); path.moveTo(x1,y1); for(int i=0;i