/* * @(#)Tilegen.java 1.0 08/08/18 * * * * * * * * */ import java.awt.*; import java.applet.*; import java.net.*; import java.awt.event.*; import java.io.FilePermission; import java.util.Calendar; import java.text.SimpleDateFormat; import java.security.AccessController; import java.lang.*; import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; import java.util.Formatter; import java.util.FormatterClosedException; import java.lang.String; public class Tilegen extends Applet implements ActionListener { Image tile_gif,qug_gif; URL base; MediaTracker mt; Button okButton; Button confirmButton; Button frameButton; TextField north_inputs,east_inputs,south_inputs,west_inputs,frame_inputs; TextArea gls,tls; int cflag,frflag; String newline; public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; static Formatter output1; static Formatter output2; static Formatter output3; public void init() { setLayout(null); okButton = new Button("Submit Inputs"); frameButton = new Button("Submit frame glues"); confirmButton = new Button("Click to confirm"); north_inputs = new TextField("North outputs appear here",40); east_inputs = new TextField("East inputs appear here",40); south_inputs = new TextField("South inputs appear here",40); west_inputs = new TextField("West outputs appear here",40); gls = new TextArea(10,40); gls.setEditable(false); tls = new TextArea(10,40); tls.setEditable(false); frame_inputs = new TextField("Type frame inputs here",80); frame_inputs.setBounds(500,340,400,40); add(frame_inputs); cflag=0; frflag=0; north_inputs.setBounds(130,40,200,30); add(north_inputs); east_inputs.setBounds(340,150,130,30); add(east_inputs); south_inputs.setBounds(130,250,200,30); add(south_inputs); west_inputs.setBounds(10,150,130,30); add(west_inputs); gls.setBounds(500,10,400,200); add(gls); tls.setBounds(500,440,400,260); add(tls); okButton.setBounds(130,280,100,30); add(okButton); okButton.addActionListener(this); confirmButton.setBounds(10,430,120,30); add(confirmButton); confirmButton.addActionListener(this); frameButton.setBounds(500,390,200,30); add(frameButton); frameButton.addActionListener(this); newline = System.getProperty("line.separator"); mt = new MediaTracker(this); try { base = getDocumentBase(); } catch (Exception e) {} tile_gif = getImage(base,"tile_sample.gif"); qug_gif = getImage(base, "quick_user_guide.gif"); try { mt.waitForAll(); } catch (InterruptedException e) {} } public void paint(Graphics g) { g.drawString("Welcome to XTile ver 1.0 for basic .tiles generation", 10, 20 ); g.drawString("\n Please enter inputs for the four sides of the computational tile design.", 10, 35 ); //g.drawImage(tile_gif,150,80,this); //g.drawImage(qug_gif,10,540,this); g.drawString("North inputs :"+north_inputs.getText(),10,360); g.drawString("East inputs :"+east_inputs.getText(),10,380); g.drawString("South inputs :"+south_inputs.getText(),10,400); g.drawString("West inputs :"+west_inputs.getText(),10,420); g.drawString("Below you enter glues from either the table given",500,240); g.drawString(",by entering the glue no. as per your need.",500,260); g.drawString("If you enter a new glue type not present in the table, that would be added",500,280); g.drawString("following this format a,b,c,d;e,f,g,h;....;w,x,y,z",500,300); g.drawString("Quick User Guide:\n \n ",10,480); g.drawString("1. Enter inputs in this form : a+b,(a.b)^c,a,a.(~b)\n",10,510); g.drawString("2. only four gates : AND(.), OR(+), NOT(~), XOR(^) are allowed\n",10,535); g.drawString("3. If more than one gates are used, two operands and an \n",10,560); g.drawString(" operator must be bracketed by ( ).\n",10,580); g.drawString("4. Do take care in entering frame tile glues. commas ',' seperate \n",10,605); g.drawString("glues and semicolon ';' seperate tiles, with NO semicolon in the ending\n",10,625); g.drawString("5.Error handling has not been implemented till now. So if you dont \n ",10,650); g.drawString("follow the directions, incorrect results are surely expected",10,670); int[] xcd = new int[3]; int[] ycd = new int[3]; xcd[0]=150;xcd[1]=235;xcd[2]=150; ycd[0]=80;ycd[1]=160;ycd[2]=240; g.setColor( Color.red ); g.drawPolygon(xcd, ycd, 3); g.fillPolygon(xcd, ycd, 3); xcd[0]=150;xcd[1]=235;xcd[2]=320; ycd[0]=80;ycd[1]=160;ycd[2]=80; g.setColor( Color.blue ); g.drawPolygon(xcd, ycd, 3); g.fillPolygon(xcd, ycd, 3); xcd[0]=320;xcd[1]=235;xcd[2]=320; ycd[0]=80;ycd[1]=160;ycd[2]=240; g.setColor( Color.yellow ); g.drawPolygon(xcd, ycd, 3); g.fillPolygon(xcd, ycd, 3); xcd[0]=150;xcd[1]=235;xcd[2]=320; ycd[0]=240;ycd[1]=160;ycd[2]=240; g.setColor( Color.green ); g.drawPolygon(xcd, ycd, 3); g.fillPolygon(xcd, ycd, 3); g.setColor( Color.black ); g.drawString("\n W", 192, 160 ); g.drawString("\n E", 276, 160 ); g.drawString("\n N", 235, 120 ); g.drawString("\n S", 234, 200 ); } public void actionPerformed(ActionEvent evt) { frflag=0; if(evt.getSource() == frameButton) { frflag=1; } if (evt.getSource() == okButton){ repaint();okButton.setLabel("Submitted");cflag=0;frflag=1;} else if ((evt.getSource() == confirmButton && cflag==0) || frflag==1) { String[] in = new String[100]; int i=0; for(i=0;i<100;i++) {in[i]="";} int xi=0; int l1,l2,l3,l4; l1=l2=l3=l4=0; char[] ni = north_inputs.getText().toCharArray(); int nil = north_inputs.getText().length(); if(north_inputs.getText()!="\n") { l1++; for(i=0;iend); } } //converting infix expression to postfix expression String[] piptable = new String[1000]; for(int g=0;g0); } piptable[g]=""; for(int g2=0;g20)gs--; arr[gy][gx]=stk[gs]; //storing the computed value from stack to array } } for(int a=0;agv[v2+1]) { int temp=gv[v2]; gv[v2]=gv[v2+1]; gv[v2+1]=temp; } } } int nullflag=0; int[][] gc = new int[5000][3]; int lgc=0; int w1=0; int w4=0; //looping to create a glue compare strap according to the no of bits in input taking all faces into consideration for(int q1=0;q10); for(int nc=1;nc0); tv=temp1; //removing the dummy mask and displaying the correct used codes for the glues do{ int tp = tv%10; if(tp==4) glue_strap=glue_strap.concat("0"); else if(tp==5) glue_strap=glue_strap.concat("1"); else if(tp==3) glue_strap=glue_strap.concat("null"); tv=tv/10; }while(tv>0); } //north glues array int[][] nga = new int[r][2]; if(size_north == 0) { for(int zt=0;zt0); for(int nc=1;nc0); nga[g1][0]=temp1; //comparing with glue strap for(int g3=0;g30); for(int nc=1;nc0); ega[g1][0]=temp1; for(int g3=0;g30); for(int nc=1;nc0); sga[g1][0]=temp1; for(int g3=0;g30); for(int nc=1;nc0); wga[g1][0]=temp1; for(int g3=0;g3lgc) //checking to see if new glues are entered { int flagg=0; for(int ui=0;uilgc) { int flagg=0; for(int ui=0;uilgc) { int flagg=0; for(int ui=0;uilgc) { int flagg=0; for(int ui=0;ui0); if(x2>0) { do { int pw=1; for(int t=0;t0); } return x4; } }