/* File work.java */ // Values Range from x=294.45 to 281.45 in Increments of 0.05 import java.applet.*; import java.awt.*; import java.io.*; import java.net.*; import java.util.*; public class work extends Applet { Button button = new Button("Send"); TextArea text = new TextArea(10,30); TextArea text3 = new TextArea(20,20); TextArea text4 = new TextArea(20,20); TextField text1 = new TextField("1",3); TextField text2 = new TextField("1",3); Label label1 = new Label("Choice",Label.RIGHT); Label label2 = new Label("Number of Tests",Label.RIGHT); public void init() { // Copy BG Color from Web Page String arg = getParameter("BGCOLOR"); int bgColorVal = Integer.valueOf(arg, 16).intValue(); setBackground(new Color(bgColorVal)); setLayout(null); add(text); add(text1); add(text2); add(label1); add(label2); add(button); add(text3); add(text4); text.reshape(10,10,270,120); text1.reshape(400,30,30,25); text2.reshape(400,70,30,25); label1.reshape(310,30,80,30); label2.reshape(280,70,110,30); button.reshape(360,120,50,25); text3.reshape(85,190,100,320); text4.reshape(295,190,100,320); text.requestFocus(); setBackground(new Color(6004905)); text3.setEditable(false); text4.setEditable(false); setBackground(new Color(bgColorVal)); setLayout(null); addNotify(); resize(430,270); } public void paint(Graphics g) { getAppletContext().showStatus("In This Page You Can Upload Your Data."); } // Reacts to Pushed Button public boolean action(Event evt,Object arg) { Graphics g = getGraphics(); // Answer Choices if (evt.target instanceof Button) { if (arg.equals("Send")) { getAppletContext().showStatus("Processing Information. Please Wait."); int lpkey[] = {1,1,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0}; // Download Keys int j=0; Integer ikey[][] = new Integer[10][22]; Float fkey[][] = new Float[22][2]; float tfkey[] = new float[22]; float f2key[][] = new float[12][13]; Socket socket1; try { socket1 = new Socket("129.6.179.22",2525); DataInputStream dis1 = new DataInputStream(socket1.getInputStream()); j=1; String line = dis1.readLine(); StringTokenizer st1 = new StringTokenizer(line," "); while(line!=null) { for(int i=0;i<10;i++) for(int k=0;k<22;k++) ikey[i][k]= Integer.valueOf(st1.nextToken()); for(int i=0;i<22;i++) fkey[i][0] = Float.valueOf(st1.nextToken()); for(int i=0;i<18;i++) fkey[i][1] = Float.valueOf(st1.nextToken()); for(int i=0;i<12;i++) for(int k=0;k<13;k++) f2key[i][k] = Float.valueOf(st1.nextToken()).floatValue(); line = dis1.readLine(); j++; } dis1.close(); socket1.close(); } catch (IOException e) { System.out.println("error: "+e); } for(int i=18;i<22;i++) fkey[i][1] = new Float(0); for(int i=0;i<22;i++) tfkey[i] = fkey[i][lpkey[i]].floatValue(); // Upload Matrix char tarray[] = text.getText().toCharArray(); Character tempc = new Character(tarray[j]); int end=0,count=0,done=0; j=0; Float farray[][] = new Float[22][4]; Float tfarray[][] = new Float[22][4]; Float darray[][] = new Float[22][2]; for(int i=0;i<22;i++) for(int k=0;k<2;k++) darray[i][k] = new Float(0); Float sdarray[][] = new Float[22][2]; for(int i=0;i<22;i++) for(int k=0;k<2;k++) sdarray[i][k] = new Float(0); Float tempf = new Float(0.0); String stemp = new String(); Integer itemp = Integer.valueOf(text1.getText()); Integer itemp2 = Integer.valueOf(text2.getText()); if((itemp.intValue()<1||itemp2.intValue()<1)||(itemp.intValue()+itemp2.intValue()>11)) { itemp = new Integer(1); itemp2 = new Integer(1); System.out.println("Choice Values Out of Bounds. Please Input Correct Values."); getAppletContext().showStatus("Choice Values Out of Bounds. Please Input Correct Values."); done=1; } for(int l=0;l1) { sdarray[i][1] = new Float((sdarray[i][0].floatValue() -Math.pow(darray[i][0].floatValue(),2)/darray[i][1].floatValue()) /(darray[i][1].intValue()-1)); if(sdarray[i][1].floatValue()>=0) sdarray[i][1] = new Float(Math.sqrt(sdarray[i][1].floatValue())); else sdarray[i][1] = new Float(Math.sqrt(-sdarray[i][1].floatValue())); if(sdarray[i][1].floatValue()<.0001) sdarray[i][1] = new Float(0); } } // Determine Average Data Deviation for(int i=0;i<22;i++) if(darray[i][1].intValue()>0) darray[i][0] = new Float(darray[i][0].floatValue()/darray[i][1].floatValue()); // Displaying Results in Window g.clearRect(20,135,330,50); int slong=0; String s1=null,s2=null; Font f1 = new Font("TimesRoman",Font.BOLD,14); Font f2 = new Font("TimesRoman",Font.BOLD,11); g.setFont(f1); g.setColor(Color.black); if(itemp2.intValue()==1) g.drawString("Spectra Deviations",139,175); else g.drawString("Average Spectra Deviations",113,175); g.setFont(f2); s2 = text3.getText(); text3.replaceText("",0,s2.length()); for(int i=0;i<22;i++) { if(i<9) s1 = "Deviation "+0+(i+1)+": "; else s1 = "Deviation "+(i+1)+": "; g.drawString(s1,10,(205+i*13)); if(darray[i][1].intValue()>0) text3.appendText(darray[i][0].floatValue()+"\n"); else { text3.appendText("-\n"); darray[i][0] = new Float(-1); } } s2 = text4.getText(); text4.replaceText("",0,s2.length()); s1 = null; for(int i=0;i<22;i++) { if(i<9) s1 = "Std Deviation "+0+(i+1)+": "; else s1 = "Std Deviation "+(i+1)+": "; g.drawString(s1,200,(205+i*13)); if(darray[i][1].intValue()>1) text4.appendText(sdarray[i][1].floatValue()+"\n"); else { text4.appendText("-\n"); sdarray[i][1] = new Float(-1); } } // Display Stats in Table Font f3 = new Font("TimesRoman",Font.BOLD,18); int tiarray[] = {5,3,1,11,9,7,17,15,13,6,4,2,12,10,8,18,16,14,19,20,21,22}; float tdarray[][] = new float[2][22]; for(int i=0;i<22;i++) { tdarray[0][i] = darray[tiarray[i]-1][0].floatValue(); tdarray[1][i] = sdarray[tiarray[i]-1][1].floatValue(); } int x1=420,y1=280,x2=210,y2=228; g.setFont(f3); g.setColor(Color.black); g.drawString("Data Analysis Results",115,155); g.drawString("Data Comparison",580,25); g.setFont(f1); g.drawString("Two Peaks-Low Noise",460,255); g.drawString("Two Peaks-High Noise",690,255); g.drawString("Singlet",771,45); g.drawString("Key:",450,107); g.setColor(new Color(6004905)); g.fillRect(x1,y1,x2,y2); g.fillRect(435,115,230,60); g.setFont(f2); g.setColor(Color.black); g.drawString("No Shoulder Shoulder Valley",423,275); g.drawLine(x1+x2/3,y1,x1+x2/3,y1+y2); g.drawLine(x1+2*x2/3,y1,x1+2*x2/3,y1+y2); g.drawLine(x1,y1+y2/3,x1+x2-2,y1+y2/3); g.drawLine(x1,y1+2*y2/3,x1+x2-2,y1+2*y2/3); drawpeak(410,311,1); drawpeak(410,387,2); drawpeak(410,463,3); drawtable(tdarray,f2key,x1+3,y1+10,3,0,0,0); g.setColor(new Color(6004905)); x1=655;y1=280;x2=210;y2=228; g.fillRect(x1,y1,x2,y2); g.setColor(Color.black); g.drawString("No Shoulder Shoulder Valley",658,275); g.drawLine(x1+x2/3,y1,x1+x2/3,y1+y2); g.drawLine(x1+2*x2/3,y1,x1+2*x2/3,y1+y2); g.drawLine(x1,y1+y2/3,x1+x2-2,y1+y2/3); g.drawLine(x1,y1+2*y2/3,x1+x2-2,y1+2*y2/3); drawpeak(645,311,1); drawpeak(645,387,2); drawpeak(645,463,3); drawtable(tdarray,f2key,x1+3,y1+10,3,9,0,3); g.setColor(new Color(6004905)); x1=725;y1=65;x2=140;y2=152; g.fillRect(x1,y1,x2,y2); g.setColor(Color.black); g.drawString("PDMS PETHS",743,60); g.drawLine(x1+x2/2,y1,x1+x2/2,y1+y2); g.drawLine(x1,y1+y2/2,x1+x2-2,y1+y2/2); g.drawString("Low",693,93); g.drawString("Noise",690,106); g.drawString("High",691,170); g.drawString("Noise",690,183); drawtable(tdarray,f2key,x1+3,y1+10,2,18,9,0); g.drawString("Your Bias",442,130); g.drawString("Your Random Error",442,156); g.setColor(Color.blue); g.drawString("Study Group Bias-25%,Med,75%",442,143); g.drawString("Study Group Random Error-25%,Med,75%",442,169); if(done==0) getAppletContext().showStatus("Processing Complete."); } return true; } return false; } public boolean keyDown(Event evt, int key) { if((char)key=='\t') { Component current = (Component) evt.target; if(current!=button) current.nextFocus(); else text.requestFocus(); return true; } return false; } public float roundit(float f1) { float f2=0f; int t1=0; char c=' '; String s1 = Float.toString(f1); for(int i=0;i4) { f2 = Float.valueOf(s1.substring(t1+4,t1+5)).floatValue(); if(f2>4) { if(f1>0f) f2 = (Float.valueOf(s1.substring(0,t1+4)).floatValue()+0.001f); else f2 = (Float.valueOf(s1.substring(0,t1+4)).floatValue()-0.001f); } else f2 = Float.valueOf(s1.substring(0,t1+4)).floatValue(); } else f2=f1; return f2; } public void drawpeak(int x1,int y1,int c1) { Graphics g = getGraphics(); switch(c1) { case 1: g.drawLine(x1,y1,x1,y1+20); g.drawLine(x1+5,y1+10,x1+5,y1+20); break; case 2: g.drawLine(x1,y1,x1,y1+20); g.drawLine(x1+5,y1,x1+5,y1+20); break; case 3: g.drawLine(x1,y1+10,x1,y1+20); g.drawLine(x1+5,y1,x1+5,y1+20); break; } } public void drawtable(float tdarray[][],float f2key[][],int x1,int y1,int div,int add,int add2,int start) { Graphics g = getGraphics(); Font f2 = new Font("TimesRoman",Font.BOLD,11); g.setFont(f2); int count=0; for(int i=0;i