import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.geom.*; import java.math.*; /**This file controls the arithmetic graph window.*/ public class ArithmeticGraph extends ScaleCanvas implements MouseListener, MouseMotionListener, KeyListener { Manager M; AffineTransform[] A=new AffineTransform[5]; Complex SOURCE; ComputeArithmeticGraph CAG; Documentation DOC; Output OUT; Point JX; ListenSquare[] ACTION=new ListenSquare[10]; Complex MOVE; SelectIntegerKeyboard[] I=new SelectIntegerKeyboard[3]; ListenSquare[] L=new ListenSquare[3]; SelectInteger[] IS=new SelectInteger[3]; Color[] COLOR=new Color[1000000]; GeneralPath[] GP=new GeneralPath[1000000]; int[] STYLE=new int[1000000]; int SELECT=-1; int type=3; int count=0; ListenSquare INFO; public ArithmeticGraph addManager(Manager M) { ArithmeticGraph XX=this; XX.M=M; return(XX); } public ArithmeticGraph() { addMouseListener(this); addMouseMotionListener(this); addKeyListener(this); DOC=new Documentation(); SOURCE=new Complex(0,0); L[0]=new ListenSquare(0,0,80,38,Color.white); L[0].on=1; INFO=new ListenSquare(0,0,12,12,Color.black); setScales(300,300,10); makeConsole(); } public void makeConsole() { I[0]=new SelectIntegerKeyboard(15,2,40,14,0,10000); //Xcoord I[1]=new SelectIntegerKeyboard(15,22,40,14,0,10000); //Ycoord IS[0]=new SelectInteger(60,2,30,14,0,-10000,10000,1); //Xcoord backup IS[1]=new SelectInteger(60,22,30,14,0,-10000,10000,1); //Ycoord backup IS[2]=new SelectInteger(400,2,30,14,2,1,5,1); //thickness ACTION[0]=new ListenSquare(150,2,13,13,Color.white); //delete ACTION[1]=new ListenSquare(98,2,43,32,Color.white); //move cursor to origin ACTION[2]=new ListenSquare(150,22,13,13,Color.white); //reflect for(int i=0;i<3;++i) ACTION[i].on=1; } public void paint(Graphics gfx) { OUT=new Output("Output/graph_markings"); Graphics2D g=(Graphics2D) gfx; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //background g.setColor(Color.black); try {g.setColor(M.C.CON_G.BASIC.M[0].C);} catch(Exception e) {} g.fillRect(0,0,this.getWidth(),this.getHeight()); g.setColor(Color.white); try{drawRegions(g); drawPath(g); drawMarker(g); drawLines(g); drawControls(g); INFO.infoRender(g); } catch(Exception e) {} g.drawRect(0,0,this.getWidth()-1,this.getHeight()-1); } /**These are all the auxilliary markings.*/ public void drawLines(Graphics2D g) { /*hexagrid */ if(M.C.CON_G.HEX.L[0].on==1) ArithmeticGraphMarkings.drawHexagrid(g,M,OUT); if(M.C.CON_G.HEX.L[1].on==1) ArithmeticGraphMarkings.drawGrid1(g,M,OUT); if(M.C.CON_G.HEX.L[2].on==1) ArithmeticGraphMarkings.drawGrid2(g,M,OUT); if(M.C.CON_G.HEX.L[3].on==1) ArithmeticGraphMarkings.drawGrid3(g,M,OUT); if(M.C.CON_G.HEX.L[4].on==1) ArithmeticGraphMarkings.drawGrid4(g,M,OUT); if(M.C.CON_G.HEX.L[5].on==1) ArithmeticGraphMarkings.drawGrid5(g,M,OUT); if(M.C.CON_G.HEX.L[6].on==1) ArithmeticGraphMarkings.drawGrid6(g,M,OUT); /*more lines*/ if(M.C.CON_G.LINE.L[0].on==1) ArithmeticGraphMarkings.drawBarrier(g,M,OUT); if(M.C.CON_G.LINE.L[1].on==1) ArithmeticGraphMarkings.drawIotaWall(g,M,OUT); if(M.C.CON_G.LINE.L[2].on==1) ArithmeticGraphMarkings.drawSymmLine(g,M,OUT); } public void drawRegions(Graphics2D g) { /*regions*/ if(M.C.CON_G.REGION.L[5].on==1) ArithmeticGraphMarkings.drawTent(g,M,OUT); if(M.C.CON_G.REGION.L[1].on==1) ArithmeticGraphMarkings.drawRoom(g,M,OUT); if(M.C.CON_G.REGION.L[2].on==1) ArithmeticGraphMarkings.drawDecomp(g,M,OUT); if(M.C.CON_G.REGION.L[3].on==1) ArithmeticGraphMarkings.drawDecomp2(g,M,OUT); if(M.C.CON_G.REGION.L[4].on==1) ArithmeticGraphMarkings.drawKite(g,M,OUT); if(M.C.CON_G.REGION.L[6].on==1) ArithmeticGraphMarkings.drawTraps(g,M,OUT); if(M.C.CON_G.REGION.L[7].on==1) ArithmeticGraphMarkings.drawPeriodBox(g,M,OUT); /*basics*/ if(M.C.CON_G.BASIC.L[1].on==1) ArithmeticGraphMarkings.drawAxesGraph(g,M,OUT); if(M.C.CON_G.BASIC.L[2].on==1) ArithmeticGraphMarkings.drawZ2Grid(g,M,OUT); if(M.C.CON_G.BASIC.L[3].on==1) ArithmeticGraphMarkings.drawBaseline(g,M,OUT); if(M.C.CON_G.BASIC.L[4].on==1) ArithmeticGraphMarkings.drawRational(g,M,OUT); if(M.C.EXPORT.mode==1) OUT.tclBgSet(M.C.CON_G.BASIC.M[0].C); } public void drawMarker(Graphics2D g) { if(M.C.CON_G.BASIC.L[5].on==1) drawSource(g,M.C.CON_G.BASIC.M[5].C,SOURCE,.5); } public void drawSquare(Graphics2D g) { GeneralPath gp=new GeneralPath(); float x=(float)(.5); gp.moveTo(-x,0); gp.lineTo(-x,1); gp.lineTo(x,1); gp.lineTo(x,0); gp.closePath(); gp=transform(gp); g.setColor(Color.white); g.draw(gp); } /**this is the general routine*/ public void drawPath(Graphics2D g) { int thickness=2; try {thickness=IS[2].val;} catch(Exception e) {} GeneralPath gp2=new GeneralPath(); GeneralPath gp=new GeneralPath(); for(int i=0;i0) doMouseClick(JX,test); if(ch=='a') forceGo(0); if(ch=='s') forceGo(1); if(ch=='d') forceGo(2); if(ch=='f') forceGo(8); if(ch=='g') forceGo(9); } public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) {} public void forceGo(int j) { M.C.CON_G.CHOICE.forceMode(j); M.C.repaint(); CAG=new ComputeArithmeticGraph(SOURCE,M); new Thread(CAG).start(); } /**done with key events */ }