import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.geom.*; import java.math.*; /**This class is a graphical interface that allows the user to control the box configuration. The configuration shows the complete graph on 5 vertices, arranged in a way that suggests the triangular bipyramid. One can click on the vertices to change the sizes of the boxes. Also, one can click on the edges to turn on and off the interactions between the corresponding vertices. This class plays no role in our proof, except that it serves as a sanity check.**/ public class ConfigurationControl { int x,y; int[][] on1=new int[5][5]; int[] active=new int[5]; int[][] size=new int[2][5]; ListenSquare OFF,OUTLINE,DYADIC,INFO; SelectInteger SIZE; ControlPanel SELECT; public ConfigurationControl(int xx,int yy) { this.x=xx; this.y=yy; for(int i=0;i<5;++i) { for(int j=0;j<5;++j) { on1[i][j]=1; } } active[0]=1; active[1]=1; active[2]=1; active[3]=1; OFF=new ListenSquare(x-84,y-10,20,20,null); OFF.on=0; OUTLINE=new ListenSquare(x-86,y-12,24,24,null); OUTLINE.on=1; DYADIC=new ListenSquare(x+88,y+98,34,24,null); DYADIC.on=0; SIZE=new SelectInteger(x,y+105,30,15,4,0,10,1); INFO=new ListenSquare(x,y-100,12,12,null); for(int i=0;i<5;++i) size[0][i]=4; for(int i=0;i<5;++i) size[1][i]=1; setPanels(); } public void setPanels() { Color[] C0={new Color(0,0,0),Color.white,Color.yellow,Color.white,Color.red}; String[] SelectString={"regular","confiner","select"}; int[] SelectState={1,0}; SELECT=new ControlPanel(C0,SelectString,SelectState,2); SELECT.INFO_LIVE=1; } public void render(Graphics2D g) { g.setColor(Color.black); g.fillRect(x-90,y-130,230,260); g.setColor(new Color(255,0,255)); g.drawRect(x-90,y-130,230,260); g.setColor(Color.white); g.setFont(new Font("Helvetica",Font.PLAIN,10)); g.drawString("CONFIGURATION CONTROL",x-84,y-115); g.setColor(new Color(50,100,255)); g.drawString("mouse ZXC",x+64,y-115); INFO.infoRenderLive(g); drawEdges(g); drawVertices(g); drawButtons(g); drawSizer(g); } public void drawButtons(Graphics2D g) { OFF.render(g,Color.blue); OUTLINE.render(g,Color.blue); DYADIC.render(g,Color.blue,Color.yellow); g.setColor(Color.white); g.drawString("box size",x,y+95); g.drawString("dyadic",x+90,y+95); g.drawString("reset",x-86,y-35); g.drawString("bonds",x-86,y-20); SELECT.render(g,x+30,y-100,90); SIZE.render(g,Color.blue,Color.white,Color.white); } /**Controls the sizes of the boxes in the configuration**/ public void drawSizer(Graphics2D g) { g.setFont(new Font("Helvetica",Font.PLAIN,24)); int choice=SELECT.mode; for(int i=0;i<4;++i) { g.setColor(Color.white); if(i==0) g.setColor(Color.black); if(i==3) g.setColor(Color.black); Complex z=makePoint(i); Integer k=new Integer(size[choice][i]); String S=k.toString(); int offset=6; if(k>9) offset=12; g.drawString(S,(int)(z.x-offset),(int)(z.y+9)); } } /**Draws edges of the graph**/ public void drawEdges(Graphics2D g) { Color[] C={new Color(0,0,100),new Color(255,255,0)}; GeneralPath gp=new GeneralPath(); for(int i=0;i<4;++i) { for(int j=i+1;j<4;++j) { gp.reset(); Complex z1=makePoint(i); Complex z2=makePoint(j); gp.moveTo((float)(z1.x),(float)(z1.y)); gp.lineTo((float)(z2.x),(float)(z2.y)); if(on1[i][j]==0) g.setColor(new Color(0,0,150)); if(on1[i][j]==1) g.setColor(new Color(255,50,250)); g.fill(gp); g.setStroke(new BasicStroke(3)); g.draw(gp); } } for(int i=0;i<4;++i) { for(int j=i+1;j<4;++j) { gp.reset(); Complex z1=makePoint(i); Complex z2=makePoint(j); gp.moveTo((float)(z1.x),(float)(z1.y)); gp.lineTo((float)(z2.x),(float)(z2.y)); if(on1[i][j]==0) g.setColor(new Color(0,0,150)); if(on1[i][j]==1) g.setColor(new Color(255,50,250)); g.fill(gp); g.setStroke(new BasicStroke(3)); g.draw(gp); } } for(int i=0;i<4;++i) { gp.reset(); Complex z1=makePoint(i); Complex z2=makePoint2(i); gp.moveTo((float)(z1.x),(float)(z1.y)); gp.lineTo((float)(z2.x),(float)(z2.y)); if(on1[i][4]==0) g.setColor(new Color(0,0,150)); if(on1[i][4]==1) g.setColor(new Color(255,50,250)); g.fill(gp); g.setStroke(new BasicStroke(3)); g.draw(gp); } g.setStroke(new BasicStroke(1)); } /**Draws the vertices of the graph**/ public void drawVertices(Graphics2D g) { Color[] C = Configuration.colors(); for(int i=0;i<4;++i) { Complex z=makePoint(i); g.setColor(C[i]); g.fillOval((int)(z.x-20),(int)(z.y-20),40,40); g.setColor(Color.blue); if(active[i]==1) { g.setColor(Color.white); g.setStroke(new BasicStroke(3)); } g.drawOval((int)(z.x-20),(int)(z.y-20),40,40); g.setStroke(new BasicStroke(1)); } } /**This routine finds the segment closest to the click, and then toggles the bond representing that segment.**/ public void getLine(Point X) { Complex z=new Complex(X.x,X.y); double d=XtraComplex.dist(z,new Complex(x,y)); int[] index=new int[2]; double min=100; /**checks the bonds between the finite points**/ if(d<150) { for(int i=0;i<4;++i) { for(int j=i+1;j<4;++j) { Complex Z1=makePoint(i); Complex Z2=makePoint(j); double test=XtraComplex.nearness(Z1,Z2,z); if(test20) size[choice][i]=20; used=1; } } return(used); } public Complex makePoint(int i) { Complex z=new Complex(); if(i==0) z=new Complex(x+80,y); if(i==2) z=new Complex(x,y); if(i==3) z=new Complex(x-50,y-70); if(i==1) z=new Complex(x-50,y+70); return(z); } public Complex makePoint2(int i) { Complex z=new Complex(); if(i==0) z=new Complex(x+125,y); if(i==2) z=new Complex(x-42,y); if(i==3) z=new Complex(x-85,y-110); if(i==1) z=new Complex(x-85,y+110); return(z); } public void changeSize(Point X) { SIZE.modify(X); if(SIZE.isModified(X)==1) { for(int i=0;i<4;++i) { size[SELECT.mode][i]=SIZE.val; } } } /**Input from mouse**/ public int process(Point X,int mode) { int used=getPoint(mode,X); if(used==0) getLine(X); int test=SELECT.switchMode(X); if(test==20) return(20); if(INFO.inside(X)==1) return(19); if(DYADIC.inside(X)==1) { DYADIC.on=1-DYADIC.on; return(1); } changeSize(X); return(0); } }