| line no. 1 (1 comments) | import java.awt.*; |
| line no. 2 (0 comments) | import java.awt.event.*; |
| line no. 3 (0 comments) | import javax.swing.*; |
| line no. 4 (0 comments) | TextArea myTextArea; |
| line no. 5 (0 comments) | Client myClient; |
| line no. 6 (0 comments) | String dataIn; |
| line no. 7 (0 comments) | byte interesting = 10; |
| line no. 8 (0 comments) | PFont font; |
| line no. 9 (0 comments) | String statText = " "; |
| line no. 10 (0 comments) | int stallCount = 0; |
| line no. 11 (0 comments) | Client txtClient; |
| line no. 12 (0 comments) | String txtIn; |
| line no. 13 (0 comments) | String printTxt; |
| line no. 14 (0 comments) | void setup() |
| line no. 15 (0 comments) | { |
| line no. 16 (0 comments) | //Panel p = new Panel(); |
| line no. 17 (0 comments) | setLayout(new BorderLayout()); |
| line no. 18 (0 comments) | myTextArea = new TextArea(" ", 3, 8, TextArea.SCROLLBARS_NONE); |
| line no. 19 (0 comments) | add(myTextArea, BorderLayout.SOUTH); |
| line no. 20 (0 comments) | txtClient = new Client(this, "130.208.220.190", 3460); |
| line no. 21 (0 comments) | background(#ffffff); |
| line no. 22 (0 comments) | framerate(10); |
| line no. 23 (0 comments) | } |
| line no. 24 (0 comments) | void draw() |
| line no. 25 (0 comments) | { |
| line no. 26 (0 comments) | //System.out.println(printTxt); |
| line no. 27 (0 comments) | noStroke(); |
| line no. 28 (0 comments) | try{ |
| line no. 29 (0 comments) | dataIn = null; |
| line no. 30 (0 comments) | if (myClient.available() > 0) { |
| line no. 31 (0 comments) | stallCount = 0; |
| line no. 32 (0 comments) | statText = "Drawing..."; |
| line no. 33 (0 comments) | String dataSplit[] = split(dataIn, '-'); |
| line no. 34 (0 comments) | String myColor = dataSplit[dataSplit.length-1]; |
| line no. 35 (0 comments) | myColor = myColor.substring(1, dataSplit[dataSplit.length-1].length()-1); |
| line no. 36 (0 comments) | int myR = unhex(myColor.substring(0, 2)); |
| line no. 37 (0 comments) | int myG = unhex(myColor.substring(2, 4)); |
| line no. 38 (0 comments) | int myB = unhex(myColor.substring(4, 6)); |
| line no. 39 (0 comments) | //println("length: "+myColor); |
| line no. 40 (0 comments) | //int filler = unhex(dataSplit[dataSplit.length].substring(1, dataSplit[dataSplit.length].length()-1)+"ff"); |
| line no. 41 (0 comments) | fill(myR, myG, myB); |
| line no. 42 (0 comments) | //println("filler: "+myR+" "+myG+" "+myB); |
| line no. 43 (0 comments) | smooth(); |
| line no. 44 (0 comments) | beginShape(POLYGON); |
| line no. 45 (0 comments) | for(int i = 0; i < dataSplit.length-2; i++){ |
| line no. 46 (0 comments) | //println(dataSplit[i]); |
| line no. 47 (0 comments) | if(dataSplit[i].charAt(0) == 'C'){ |
| line no. 48 (0 comments) | int dataLength = dataSplit[i].length(); |
| line no. 49 (0 comments) | String useCoords[] = split(dataSplit[i].substring(1, dataLength)); |
| line no. 50 (0 comments) | bezierVertex(float(useCoords[0]), float(useCoords[1]), float(useCoords[2]), float(useCoords[3]), float(useCoords[4]), float(useCoords[5])); |
| line no. 51 (1 comments) | } |
| line no. 52 (0 comments) | else if(dataSplit[i].charAt(0) == 'L'){ |
| line no. 53 (0 comments) | int dataLength = dataSplit[i].length(); |
| line no. 54 (0 comments) | String useCoords[] = split(dataSplit[i].substring(1, dataLength)); |
| line no. 55 (0 comments) | vertex(float(useCoords[0]), float(useCoords[1])); |
| line no. 56 (0 comments) | //println("vert: "+float(useCoords[0])+" "+float(useCoords[1])); |
| line no. 57 (0 comments) | } |
| line no. 58 (0 comments) | else if(dataSplit[i].charAt(0) == 'M'){ |
| line no. 59 (0 comments) | endShape(); |
| line no. 60 (0 comments) | beginShape(POLYGON); |
| line no. 61 (0 comments) | int dataLength = dataSplit[i].length(); |
| line no. 62 (0 comments) | String useCoords[] = split(dataSplit[i].substring(1, dataLength)); |
| line no. 63 (0 comments) | vertex(float(useCoords[0]), float(useCoords[1])); |
| line no. 64 (0 comments) | //println("vert: "+float(useCoords[0])+" "+float(useCoords[1])); |
| line no. 65 (0 comments) | } |
| line no. 66 (0 comments) | } |
| line no. 67 (0 comments) | endShape(); |
| line no. 68 (0 comments) | /*fill(#000000); |
| line no. 69 (0 comments) | rect(0, 430, 1200, 470); |
| line no. 70 (0 comments) | fill(#ffffff); |
| line no. 71 (1 comments) | textSize(48); |
| line no. 72 (0 comments) | text(printTxt, 20, 480);*/ |
| line no. 73 (0 comments) | } |
| line no. 74 (0 comments) | else{ |
| line no. 75 (0 comments) | stallCount++; |
| line no. 76 (0 comments) | if(stallCount > 10){ |
| line no. 77 (0 comments) | statText = "Locating next image..."; |
| line no. 78 (0 comments) | } |
| line no. 79 (0 comments) | } |
| line no. 80 (0 comments) | if (txtClient.available() > 0) { |
| line no. 81 (0 comments) | String txtsplit[] = split(txtIn, ';'); |
| line no. 82 (0 comments) | printTxt = txtsplit[0]; |
| line no. 83 (0 comments) | /*fill(#000000); |
| line no. 84 (0 comments) | rect(0, 430, 1200, 470); |
| line no. 85 (0 comments) | fill(#ffffff); |
| line no. 86 (0 comments) | textSize(48); |
| line no. 87 (0 comments) | text(printTxt, 20, 480);*/ |
| line no. 88 (0 comments) | myTextArea.append(printTxt + " "); |
| line no. 89 (0 comments) | } |
| line no. 90 (0 comments) | } |
| line no. 91 (0 comments) | catch(Exception e){ |
| line no. 92 (0 comments) | //println(e); |
| line no. 93 (0 comments) | } |
| line no. 94 (0 comments) | } |