import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class test1 extends Applet { ControlCanvas C; HorizontalCanvas H; VerticalCanvas V; FlowCanvas F; Manager M; Animator A; public void init() { M=new Manager(); A=new Animator(); setBackground(Color.black); H=new HorizontalCanvas(); V=new VerticalCanvas(); F=new FlowCanvas(); C=new ControlCanvas(); C.resize(250,250); H.resize(250,250); V.resize(250,250); F.resize(250,250); F.setBackground(Color.black); V.setBackground(Color.black); H.setBackground(Color.black); C.setBackground(Color.black); add(F); add(H); add(V); add(C); M.F=F; M.H=H; M.V=V; M.C=C; M.A=A; F.M=M; C.M=M; V.M=M; H.M=M; A.M=M; try {A.start();} catch(Exception e) {} A.suspend(); M.F.shift=0; } } class Manager { HorizontalCanvas H; VerticalCanvas V; FlowCanvas F; ControlCanvas C; Animator A; Manager() {} } class DBCanvas extends Canvas { Manager M; public void update(Graphics g) { Graphics g2; Image offscreen = null; offscreen = createImage(size().width, size().height); g2 = offscreen.getGraphics(); paint(g2); g.drawImage(offscreen, 0, 0, this); g2.dispose(); offscreen.flush(); } } class ControlCanvas extends DBCanvas implements MouseListener,MouseMotionListener { ListenSquare[] L=new ListenSquare[20]; Palette P; int opt1,opt2,opt3; int history; String[] S=new String[6]; ControlCanvas() { addMouseListener(this); addMouseMotionListener(this); L[1]=new ListenSquare(40,0,40,40); L[1].C=new Color(50,100,255); L[2]=new ListenSquare(0,40,40,40); L[2].C=new Color(50,100,255); L[3]=new ListenSquare(0,80,40,40); L[3].C=Color.yellow; L[4]=new ListenSquare(80,0,40,40); L[4].C=Color.yellow; L[5]=new ListenSquare(40,80,40,40); L[5].C=Color.red; L[15]=new ListenSquare(45,85,30,30); L[15].C=new Color(200,0,0); L[6]=new ListenSquare(40,40,40,40); L[6].C=Color.red; L[16]=new ListenSquare(45,45,30,30); L[16].C=new Color(200,0,0); L[7]=new ListenSquare(80,40,40,40); L[7].C=Color.red; L[17]=new ListenSquare(85,45,30,30); L[17].C=new Color(200,0,0); L[8]=new ListenSquare(0,0,40,40); L[8].C=Color.yellow; L[9]=new ListenSquare(80,80,40,40); L[9].C=Color.white; P=new Palette(128,0,24); opt1=1; opt2=0; opt3=0; history=-1; S[1]="Rich: Applet 43"; S[2]=""; S[3]="Move the mouse over any part"; S[4]="of the screen and this region will"; S[5]="explain how it operates."; } public void paint(Graphics g) { //squares for(int i=1;i<=9;++i) L[i].render(g); if(opt1==1) L[15].render(g); if(opt2==1) L[16].render(g); if(opt3==1) L[17].render(g); P.render(g); //button decorations g.setColor(Color.yellow); g.fillRect(50,18,20,5); g.fillRect(10,58,20,5); g.fillRect(18,50,5,20); g.setColor(Color.blue); g.fillRect(0,126,249,122); g.setColor(Color.white); g.setFont(new Font("Helvetica",Font.PLAIN,15)); g.drawString(S[1],8,150); g.drawString(S[2],8,170); g.drawString(S[3],8,190); g.drawString(S[4],8,210); g.drawString(S[5],8,230); } public void mouseDragged(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) { M.C.S[1]="Rich: Applet 43"; M.C.S[2]=""; M.C.S[3]="Move the mouse over any part"; M.C.S[4]="of the screen and this region will"; M.C.S[5]="explain how it operates."; M.C.repaint(); } public void mouseClicked(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int test=0; for(int i=1;i<=9;++i) { if(L[i].inside(p)==1) test=i; } if((test==1)&&(M.F.SIZE>3)) { --M.F.SIZE; M.V.setup(M.F.SIZE); M.V.repaint(); M.H.setup(M.F.SIZE); M.H.repaint(); M.F.setup(M.F.SIZE); M.F.repaint(); } if((test==2)&&(M.F.SIZE<12)) { ++M.F.SIZE; M.V.setup(M.F.SIZE); M.V.repaint(); M.H.setup(M.F.SIZE); M.H.repaint(); M.F.setup(M.F.SIZE); M.F.repaint(); } if(test==3) { M.F.per=1; if(opt1==0) M.F.permute(1); if(opt1==1) M.A.resume(); } if(test==4) { M.F.per=2; if(opt1==0) M.F.permute(2); if(opt1==1) M.A.resume(); } if(test==5) { opt1=1-opt1; opt2=opt2*opt1; M.F.shift=0; M.A.suspend(); } if(test==6) { opt2=1-opt2; if(opt2==1) opt1=opt2; } if(test==7) { opt3=1-opt3; } if(test==8) { M.F.per=3; if(opt1==0) { M.F.permute(1); M.F.permute(2); } if(opt1==1) M.A.resume(); } if(test==9) { M.F.reset(); } M.F.repaint(); P.select(p); L[9].C=P.R.C; repaint(); } public void mouseMoved(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int test=0; for(int i=1;i<=9;++i) { if(L[i].inside(p)==1) test=i; } if(P.inside(p)==1) test=10; if((history!=test)&&(test==0)) { history=test; S[1]="Rich: Applet 43"; S[2]=""; S[3]="Move the mouse over any part"; S[4]="of the screen and this region will"; S[5]="explain how it operates."; repaint(); } if((history!=test)&&(test==1)) { history=test; S[2]="This button decreases the number"; S[3]="of squares in the windows."; S[4]="The minimum number is 3x3."; S[1]=""; S[5]=""; repaint(); } if((history!=test)&&(test==2)) { history=test; S[2]="This button increases the number"; S[3]="of squares in the windows."; S[4]="The maximum number is 12x12."; S[1]=""; S[5]=""; repaint(); } if((history!=test)&&(test==3)) { history=test; S[1]="This button permutes the squares "; S[2]="in the top left window according to"; S[3]="the arrows at top-right Make or"; S[4]="change the arrows by clicking or"; S[5]="dragging on the blue squares."; repaint(); } if((history!=test)&&(test==4)) { history=test; S[1]="This button permutes the squares"; S[2]="in the top left window according to"; S[3]="the arrows at bottom-left Make or"; S[4]="change the arrows by clicking or"; S[5]="dragging on the blue squares."; repaint(); } if((history!=test)&&(test==5)) { history=test; S[1]="This button toggles the"; S[2]="animation option."; S[3]=""; S[4]=""; S[5]=""; repaint(); } if((history!=test)&&(test==6)) { history=test; S[1]="This button toggles the"; S[2]="continuous loop option."; S[3]=""; S[4]=""; S[5]=""; repaint(); } if((history!=test)&&(test==7)) { history=test; S[1]="This button toggles the painting"; S[2]="option. When it is on, the squares"; S[3]="in the top left window transfer"; S[4]="their colors to each other as they"; S[5]="move. This lets you see the cycles."; repaint(); } if((history!=test)&&(test==8)) { history=test; S[1]="This button does the bottom-left"; S[2]="permutation followed by the"; S[3]="top-right one. You select these"; S[4]="permutations by click/dragging"; S[5]="the mouse over the blue squares."; repaint(); } if((history!=test)&&(test==9)) { history=test; S[1]="This button repaints the entire top"; S[2]="left window, and also records the"; S[3]="selected color. You can change"; S[4]="the color by clicking on the color"; S[5]="selector (the top-right region.)"; repaint(); } if((history!=test)&&(test==10)) { history=test; S[1]="This is the color selector. Initial"; S[2]="color is white. Change colors by"; S[3]="clicking. Once you select a color"; S[4]="you can paint squares in the top"; S[5]="left window by clicking on them."; repaint(); } } } class HorizontalCanvas extends DBCanvas implements MouseListener, MouseMotionListener { ListenSquare[][] L=new ListenSquare[16][16]; int SIZE; int[] move=new int[16]; HorizontalCanvas() { addMouseListener(this); addMouseMotionListener(this); setup(8); } void setup(int s) { SIZE=s; double d=(int)(250/s); double pad=250-d*s; pad=.5*pad; for(int i=1;i<=s;++i) { move[i]=0; for(int j=1;j<=s;++j) { L[i][j]=new ListenSquare(pad+d*i-d,pad+d*j-d,d,d); L[i][j].i=i; L[i][j].j=j; L[i][j].C=Color.blue; } } } public void paint(Graphics g) { Color C1 =Color.blue; Color C2 =Color.black; Color C3 =Color.yellow; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { L[i][j].render(g,C1,C2); } } g.setColor(C3); int base=(1+SIZE)/2; int offset=125/SIZE; int x1=0; int y1=0; int x2=0; int y2=0; int[] X={0,0,0}; int[] Y={0,0,0}; g.translate(offset,offset); for(int k=1;k<=SIZE;++k) { if(move[k]==0) { x1=(int)(L[base][k].x1); y1=(int)(L[base][k].y1); g.fillRect(x1-1,y1-4,2,8); } if(move[k]<0) { x1=(int)(L[base][k].x1); y1=(int)(L[base][k].y1); x2=(int)(L[base+move[k]][k].x1); y2=(int)(L[base+move[k]][k].y1); g.fillRect(x2,y2-3,x1-x2,6); X[0]=x2+4;X[1]=x2-4;X[2]=x2+4; Y[0]=y2-8;Y[1]=y2;Y[2]=y2+8; g.fillPolygon(X,Y,3); g.drawPolygon(X,Y,3); } if(move[k]>0) { x1=(int)(L[base][k].x1); y1=(int)(L[base][k].y1); x2=(int)(L[base+move[k]][k].x1); y2=(int)(L[base+move[k]][k].y1); g.fillRect(x1,y2-3,x2-x1,6); X[0]=x2-4;X[1]=x2+4;X[2]=x2-4; Y[0]=y2-8;Y[1]=y2;Y[2]=y2+8; g.fillPolygon(X,Y,3); g.drawPolygon(X,Y,3); } } } public void mouseEntered(MouseEvent e) { M.C.S[1]="This window controls 1 of the 2"; M.C.S[2]="permutations. You select the it by"; M.C.S[3]="by click/dragging the mouse over"; M.C.S[4]="the blue squares. The yellow"; M.C.S[5]="arrows encode the permutation."; M.C.repaint(); } public void mousePressed(MouseEvent e) {} public void mouseMoved(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseExited(MouseEvent e) { M.C.S[1]="Rich: Applet 43"; M.C.S[2]=""; M.C.S[3]="Move the mouse over any part"; M.C.S[4]="of the screen and this region will"; M.C.S[5]="explain how it operates."; M.C.repaint(); } public void mouseClicked(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int ii=0; int jj=0; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { if(L[i][j].inside(p)==1) {ii=i;jj=j;} } } int base=(1+SIZE)/2; if(jj>0) move[jj]=ii-base; repaint(); } public void mouseDragged(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int ii=0; int jj=0; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { if(L[i][j].inside(p)==1) {ii=i;jj=j;} } } int base=(1+SIZE)/2; if(jj>0) move[jj]=ii-base; repaint(); } } class VerticalCanvas extends DBCanvas implements MouseListener,MouseMotionListener { ListenSquare[][] L=new ListenSquare[16][16]; int SIZE; int[] move=new int[16]; VerticalCanvas() { addMouseListener(this); addMouseMotionListener(this); setup(8); } void setup(int s) { SIZE=s; double d=(int)(250/s); double pad=250-d*s; pad=.5*pad; for(int i=1;i<=s;++i) { move[i]=0; for(int j=1;j<=s;++j) { L[i][j]=new ListenSquare(pad+d*i-d,pad+d*j-d,d,d); L[i][j].i=i; L[i][j].j=j; } } } public void paint(Graphics g) { Color C1 =Color.blue; Color C2 =Color.black; Color C3 =Color.yellow; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { L[i][j].render(g,C1,C2); } } g.setColor(C3); int base=(1+SIZE)/2; int offset=125/SIZE; int x1=0; int y1=0; int x2=0; int y2=0; int[] X={0,0,0}; int[] Y={0,0,0}; g.translate(offset,offset); for(int k=1;k<=SIZE;++k) { if(move[k]==0) { x1=(int)(L[k][base].x1); y1=(int)(L[k][base].y1); g.fillRect(x1-4,y1-1,8,2); } if(move[k]<0) { x1=(int)(L[k][base].x1); y1=(int)(L[k][base].y1); x2=(int)(L[k][base+move[k]].x1); y2=(int)(L[k][base+move[k]].y1); g.fillRect(x2-3,y2,6,y1-y2); X[0]=x2-8;X[1]=x2;X[2]=x2+8; Y[0]=y2+4;Y[1]=y2-4;Y[2]=y2+4; g.fillPolygon(X,Y,3); g.drawPolygon(X,Y,3); } if(move[k]>0) { x1=(int)(L[k][base].x1); y1=(int)(L[k][base].y1); x2=(int)(L[k][base+move[k]].x1); y2=(int)(L[k][base+move[k]].y1); g.fillRect(x2-3,y1,6,y2-y1); X[0]=x2-8;X[1]=x2;X[2]=x2+8; Y[0]=y2-4;Y[1]=y2+4;Y[2]=y2-4; g.fillPolygon(X,Y,3); g.drawPolygon(X,Y,3); } } } public void mousePressed(MouseEvent e) {} public void mouseMoved(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) { M.C.S[1]="This window controls 1 of the 2"; M.C.S[2]="permutations. You select the it by"; M.C.S[3]="by click/dragging the mouse over"; M.C.S[4]="the blue squares. The yellow"; M.C.S[5]="arrows encode the permutation."; M.C.repaint(); } public void mouseExited(MouseEvent e) { M.C.S[1]="Rich: Applet 43"; M.C.S[2]=""; M.C.S[3]="Move the mouse over any part"; M.C.S[4]="of the screen and this region will"; M.C.S[5]="explain how it operates."; M.C.repaint(); } public void mouseClicked(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int ii=0; int jj=0; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { if(L[i][j].inside(p)==1) {ii=i;jj=j;} } } int base=(1+SIZE)/2; if(ii>0) move[ii]=jj-base; repaint(); } public void mouseDragged(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int ii=0; int jj=0; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { if(L[i][j].inside(p)==1) {ii=i;jj=j;} } } int base=(1+SIZE)/2; if(ii>0) move[ii]=jj-base; repaint(); } } class FlowCanvas extends DBCanvas implements MouseListener,MouseMotionListener { ListenSquare[][] L=new ListenSquare[16][16]; RankedColor[][] pattern=new RankedColor[16][16]; int SIZE; int per; double shift; FlowCanvas() { addMouseListener(this); addMouseMotionListener(this); setup(8); per=0; } void setup(int s) { SIZE=s; double d=(int)(250/s); double pad=250-d*s; pad=.5*pad; for(int i=1;i<=s;++i) { for(int j=1;j<=s;++j) { L[i][j]=new ListenSquare(pad+d*i-d,pad+d*j-d,d,d); L[i][j].i=i; L[i][j].j=j; L[i][j].C=Color.white; L[i][j].R=new RankedColor(255,255,255,1); pattern[i][j]=new RankedColor(255,255,255,1); L[i][j].wrap=(int)(d*s); } } } void reset() { for(int i=1;i<=M.F.SIZE;++i) { for(int j=1;j<=M.F.SIZE;++j) { pattern[i][j]=M.C.P.R; L[i][j].R=M.C.P.R; } } repaint(); } void evolve() { if(per<=2) { shift=shift+.05; repaint(); if((shift>.99)&&(shift<1.01)) permute(per); if(shift>1) { shift=0; if(M.C.opt2==0) M.A.suspend(); } } if(per==3) { shift=shift+.05; repaint(); if((shift>.99)&&(shift<1.01)) permute(1); if((shift>1.99)&&(shift<2.01)) permute(2); if(shift>2) { shift=0; if(M.C.opt2==0) M.A.suspend(); } } } void permute(int p) { if(p==1) { for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { L[i][j].j=mod(L[i][j].j+M.V.move[L[i][j].i],SIZE); } } } if(p==2) { for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { L[i][j].i=mod(L[i][j].i+M.H.move[L[i][j].j],SIZE); } } } if(M.C.opt3==1) { for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { if(L[i][j].R.j=3)&&(shift<1)) { for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { s2=s1*shift*M.V.move[L[i][j].i]; g.translate(0,(int)(s2)); L[i][j].render(g,M); g.translate(0,(int)(-s2)); } } } if((per>=3)&&(shift>=1)) { for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { s2=s1*(shift-1)*M.H.move[L[i][j].j]; g.translate((int)(s2),0); L[i][j].render(g,M); g.translate((int)(-s2),0); } } } } public void mouseEntered(MouseEvent e) { M.C.S[1]="This window contains the squares"; M.C.S[2]="which are permuted using the other"; M.C.S[3]="controls. You can paint these"; M.C.S[4]="squares by selecting a color and"; M.C.S[5]="then clicking on them."; M.C.repaint(); } public void mouseMoved(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseExited(MouseEvent e) { M.C.S[1]="Rich: Applet 43"; M.C.S[2]=""; M.C.S[3]="Move the mouse over any part"; M.C.S[4]="of the screen and this region will"; M.C.S[5]="explain how it operates."; M.C.repaint(); } public void mouseClicked(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int a=0; int b=0; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { if(L[L[i][j].i][L[i][j].j].inside(p)==1) {a=i;b=j;} } } if(a*b>0) { L[a][b].R=M.C.P.R; pattern[a][b]=M.C.P.R; } repaint(); } public void mouseDragged(MouseEvent e) { e.consume(); Point p=new Point(); p.x=e.getX(); p.y=e.getY(); int a=0; int b=0; for(int i=1;i<=SIZE;++i) { for(int j=1;j<=SIZE;++j) { if(L[L[i][j].i][L[i][j].j].inside(p)==1) {a=i;b=j;} } } if(a*b>0) { L[a][b].R=M.C.P.R; pattern[a][b]=M.C.P.R; } repaint(); } } class ListenSquare { double x1,x2; double y1,y2; int state; int type; Color C; RankedColor R; int i,j; int wrap; ListenSquare(double x1,double y1,double x2,double y2) { this.x1=x1; this.x2=x2; this.y1=y1; this.y2=y2; this.state=0; this.type=0; } int inside(Point p) { int val; val=1; if(p.x<=this.x1) val=0; if(p.x>this.x1+this.x2) val=0; if(p.y<=this.y1) val=0; if(p.y>this.y1+this.y2) val=0; return(val); } void render(Graphics g,Manager M) { int xx1,yy1,xx2,yy2; xx1=(int)(M.F.L[i][j].x1); yy1=(int)(M.F.L[i][j].y1); xx2=(int)(int)(this.x2); yy2=(int)(int)(this.y2); g.setColor(R.C); g.fillRect(xx1,yy1,xx2,yy2); g.fillRect(xx1,yy1-wrap,xx2,yy2); g.fillRect(xx1,yy1+wrap,xx2,yy2); g.fillRect(xx1-wrap,yy1,xx2,yy2); g.fillRect(xx1+wrap,yy1,xx2,yy2); g.setColor(Color.black); g.drawRect(xx1,yy1,xx2,yy2); g.drawRect(xx1,yy1-wrap,xx2,yy2); g.drawRect(xx1,yy1+wrap,xx2,yy2); g.drawRect(xx1+wrap,yy1,xx2,yy2); g.drawRect(xx1-wrap,yy1,xx2,yy2); } void render(Graphics g) { int xx1,yy1,xx2,yy2; xx1=(int)(x1); yy1=(int)(y1); xx2=(int)(int)(this.x2); yy2=(int)(int)(this.y2); g.setColor(C); g.fillRect(xx1,yy1,xx2,yy2); g.fillRect(xx1,yy1-wrap,xx2,yy2); g.fillRect(xx1,yy1+wrap,xx2,yy2); g.fillRect(xx1-wrap,yy1,xx2,yy2); g.fillRect(xx1+wrap,yy1,xx2,yy2); g.setColor(Color.black); g.drawRect(xx1,yy1,xx2,yy2); g.drawRect(xx1,yy1-wrap,xx2,yy2); g.drawRect(xx1,yy1+wrap,xx2,yy2); g.drawRect(xx1+wrap,yy1,xx2,yy2); g.drawRect(xx1-wrap,yy1,xx2,yy2); } void render(Graphics g,Color C1,Color C2) { int xx1,yy1,xx2,yy2; xx1=(int)(this.x1); yy1=(int)(this.y1); xx2=(int)(int)(this.x2); yy2=(int)(int)(this.y2); g.setColor(C1); g.fillRect(xx1,yy1,xx2,yy2); g.setColor(C2); g.drawRect(xx1,yy1,xx2,yy2); } } class RankedColor { int j; Color C; RankedColor(int x,int y,int z,int j) { this.C=new Color(x,y,z); this.j=j; } } class Palette { ListenSquare[][] L=new ListenSquare[15][15]; double x,y,w; RankedColor R; Palette(double x,double y,double w) { this.x=x; this.y=y; this.w=w; for(int i=0;i<=5;++i) { for(int j=0;j<=5;++j) { L[i][j]=new ListenSquare(x+i*w,y+j*w,w,w); L[i][j].R=new RankedColor(0,0,0,1); } R=new RankedColor(255,255,255,1); } L[0][0].R=new RankedColor(255,255,255,1); L[0][1].R=new RankedColor(210,210,210,2); L[0][2].R=new RankedColor(170,170,170,3); L[0][3].R=new RankedColor(140,140,140,4); L[0][4].R=new RankedColor(110,110,110,5); L[1][0].R=new RankedColor(255,0,0,6); L[1][1].R=new RankedColor(200,0,0,7); L[1][2].R=new RankedColor(150,0,0,8); L[1][3].R=new RankedColor(255,0,255,9); L[1][4].R=new RankedColor(200,0,200,10); L[2][0].R=new RankedColor(255,255,0,11); L[2][1].R=new RankedColor(200,200,0,12); L[2][2].R=new RankedColor(255,150,0,13); L[2][3].R=new RankedColor(200,150,0,14); L[2][4].R=new RankedColor(200,100,50,15); L[3][0].R=new RankedColor(0,255,0,16); L[3][1].R=new RankedColor(0,200,0,17); L[3][2].R=new RankedColor(0,150,0,18); L[3][3].R=new RankedColor(0,255,255,19); L[3][4].R=new RankedColor(0,200,200,20); L[4][0].R=new RankedColor(100,100,255,21); L[4][1].R=new RankedColor(60,60,230,22); L[4][2].R=new RankedColor(30,30,180,23); L[4][3].R=new RankedColor(150,80,255,24); L[4][4].R=new RankedColor(110,50,200,25); } void select(Point p) { for(int i=0;i<=4;++i) { for(int j=0;j<=4;++j) { if(L[i][j].inside(p)==1) {R=L[i][j].R;} } } } int inside(Point p) { int test=0; for(int i=0;i<=4;++i) { for(int j=0;j<=4;++j) { if(L[i][j].inside(p)==1) test=1; } } return(test); } void render(Graphics g) { for(int i=0;i<=4;++i) { for(int j=0;j<=4;++j) { L[i][j].render(g,L[i][j].R.C,Color.black); } } } } class Animator extends Thread { Manager M; public void run() { while(true) { M.F.evolve(); try {sleep(20);} catch(Exception e) {} } } }