///////////////////////////////////////////////////////////////////////////////////////// import java.util.*; // variables text PFont f1; PFont f2; ///////////////////////////////////////////////////////////////////////////////////////// // variables for the new visualization int x = 0; float w2 = 0; float h2 = 0; float angle = 0; float a = 150 ; float a1 = 135 ; float p = 100; float p1 = 200; float sc = (1 * log(2)); float sc1 = (1 * log(10)); float mu = 30; ////////////////////////////////////////////////////////////////////////////////////////// //global List of the data ArrayList transactions = null; // arrays hours int[] arre ={ 0,0,0,0,0,0,0,0,0,0,0}; int[] arre1 ={ 0,0,0,0,0,0,0,0,0,0,0}; String [] arre2 ={ "acbk","jcbk","accd"}; // arrays dewey categories int arr[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr1[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr2[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr3[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr4[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr5[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr6[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr7[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr8[] ={ 0,0,0,0,0,0,0, 0, 0,0}; int arr9[] ={ 0,0,0,0,0,0,0, 0, 0,0}; // Counters deey int cont =0; int cont1 =0; int cont2 =0; int cont3 =0; int cont4 =0; int cont5 =0; int cont6 =0; int cont7 =0; int cont8 =0; int cont9 =0; int cont10 =0; int cont11 =0; // variables position int menu = 650; int posx = 70; int posy = 500; ////////////////////////////////////////////////////////////////////////////////////////// void setup() { size(1200,700, P2D); frameRate(10); smooth(); // load Fonts f1 =loadFont("HelveticaNeue-CondensedBlack-30.vlw"); textFont(f1,30); f2 =loadFont("HiraKakuPro-W6-12.vlw"); // position w2 = width/3; h2 = height/2 -25; sc *= 20; sc1 *= 10; // counter function counter(); } ////////////////////////////////////////////////////////////////////////////////////////// void draw() { background(250); fill(50,200); textFont(f2,12); text("by Andres Burbano - MAT UCSB", posy,(height/2)+300); text("Move the Mouse -> Y-Axis", posy,(height/2)-300); // data function data(); // circle function circle(); // clock function clock(); // guide, gris et guide (); } ////////////////////////////////////////////////////////////////////////////////////////// void counter(){ // this functin counts the number of check in and check outs this.transactions = loadTransactions(nameOfDataFileWithinDataDirectory); for (int i=0; i < transactions.size() ; i++){ Transaction t = (Transaction)transactions.get(i); // Strings into SubStrings String ho = t.ckotime.substring(0, 2); String hi = t.ckitime.substring(0, 2); String d1 = t.ckodate; String d2 = t.ckidate; String it = t.itemtype; String dc = t.deweyClass; // SubStrings into Ints int h_out = int(ho); int h_in = int(hi); if (dc != null && dc.length() >= 3){ String dc1 = t.deweyClass.substring(0,3); int dewe = int(dc1); // read info of every hour of every dewey cathegory for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 0 && dewe < 99 && h_out == hora){ cont2 ++; if (x == hora-10){ arr[x]=cont2; } println("dewe = " +dewe + " Computer science, information " + " hora ="+ x +" total items = C2 -> " + cont2); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 100 && dewe < 199 && h_out == hora){ cont3 ++; if (h_out == hora){ arr1[x]=cont3; } println("dewe = " +dewe + " Philosohpy and Psychology " + " hora =" + x + " total items = C3 -> " + cont3); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 200 && dewe < 299 && h_out == hora){ cont4 ++; if (h_out == hora){ arr2[x]=cont4; } println("dewe = " +dewe + " Religion " + " hora =" + x + " total items = C4 -> " + cont4); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 300 && dewe < 399 && h_out == hora){ cont5 ++; if (h_out == hora){ arr3[x]=cont5; } println("dewe = " +dewe + " Social sciences " + " hora =" + x + " total items = C5 -> " + cont5); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 400 && dewe < 499 && h_out == hora){ cont6 ++; if (h_out == hora){ arr4[x]=cont6; } println("dewe = " +dewe + " Languages " + " hora =" + x + " total items = C6 -> " + cont6); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 500 && dewe < 599 && h_out == hora){ cont7 ++; if (h_out == hora){ arr5[x]=cont7; } println("dewe = " +dewe + " Science and Mathematics " + " hora =" + x + " total items = C7 -> " + cont7); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 600 && dewe < 699 && h_out == hora){ cont8 ++; if (h_out == hora){ arr6[x]=cont8; } println("dewe = " +dewe + " Technology and applied science " + " hora = " + x + " total items = C8 -> " + cont8); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 700 && dewe < 799 && h_out == hora){ cont9 ++; if (h_out == hora){ arr7[x]=cont9; } println("dewe = " +dewe + " Arts and recreation " + " hora = " + x + " total items = C9 -> " + cont9); } } for(int x =0; x < 10; x++){ int hora =0; hora = x + 10; if (dewe > 800 && dewe < 899 && h_out == hora){ cont10 ++; if (h_out == hora){ arr8[x]=cont10; } println("dewe = " +dewe + " Literature " + " hora = " + hora + " total items = C10 -> " + cont10); } } for(int x1 =0; x1 < 10; x1++){ int hora1 =0; hora1 = x1 + 10; if (dewe > 900 && dewe < 999 && h_out == hora1){ cont11 ++; if (h_out == hora1){ arr9[x1]=cont11; } println("dewe = " +dewe + " History and geography and biography " + " hora = " + hora1 + " total items = C11 -> " + cont11); } } } // Reds the array and compares with the Strings = Counter / Checkout for(int x =0; x <12; x++){ String x1= str(x+10); if (ho.equals (x1)){ arre[x]++; //println("there are: "+ arre[x] +" times " + (x+(10))); } } // Reds the array and compares with the Strings = Counter / Check in for(int x =0; x <12; x++){ String x1= str(x+10); if (hi.equals (x1)){ arre1[x]++; //println("there are: "+ arre1[x] +" times " + (x+(10)) + " OUTS"); } } } } ////////////////////////////////////////////////////////////////////////////////////////// // working clock function void clock(){ float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI; float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI; float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI; strokeWeight(5); stroke(100,255-mouseY); strokeCap(SQUARE); fill(255,255-mouseY); ellipseMode(RADIUS); ellipse(width/3, (height/2)-30, 100,100); line(width/3, (height/2)-30, cos(s) * 75 + width/3 , sin(s) * 75 +(height/2)-30); line(width/3, (height/2)-30, cos(m) * 75 + width/3 , sin(m) * 75 + (height/2)-30); line(width/3, (height/2)-30, cos(h) * 50 + width/3 , sin(h) * 50 + (height/2)-30); fill(100,100,175,50); rect(1180, 0, 1200, height); } ////////////////////////////////////////////////////////////////////////////////////////// void data(){ // this funtion paints the interface elements posy = 650; fill(10,180); textFont(f1,30); text("Seattle ", 50,(height/2)-40); text("Public", 50,(height/2)-10); text("Library", 50,(height/2)+20); fill(10,100); text("One Day", 50,(height/2)+50); fill(10,220); if (mouseY < 0){ text("One Day Traffic", posy,(height/2)-20); } if (mouseY > 0 && mouseY < height/4){ textFont(f1,30); text("C L O C K working", posy,(height/2)-20); textFont(f2,12); text("twelve hours clock", posy,(height/2)); for (int x =2; x< 700; x+=58){ stroke(0); strokeWeight(4.5); line(1180,(x),1200,(x)); } } if (mouseY > height/4 && mouseY < 2*height/4){ textFont(f1,30); text("Traffic: Check Out + Check In", posy,(height/2)-20); stroke(60,20,200,100); fill(60,20,200,100); textFont(f2,12); text("Max Value 7900 Items - Scale log (10)", posy,(height/2)); for (float x =2; x< 8000; x*=(sc1)){ strokeWeight(4.5); line(1180,(x),1200,(x)); } } if (mouseY > 2*height/4 && mouseY < 3*height/4){ textFont(f1,30); text("Dewey Categories", posy,(height/2)-20); textFont(f2,12); stroke(150,55,0); fill(150,55,0); text("Max Value 2106, Scale log (2)", posy,(height/2)); for (float x =2; x< 2106; x*=(sc)){ strokeWeight(4.5); line(1180,(x),1200,(x)); } } if (mouseY > 3*height/4 && mouseY < height){ textFont(f1,30); text("10 Categories", posy,(height/2)-20); stroke(255,90,0); fill(200,100,20); textFont(f2,12); text("000 100 200 300 400 500 600 700 800 900", posy,(height/2)); for (float x =2; x< 700; x+=70){ strokeWeight(8.5); line(1180,(x),1200,(x)); } } } ////////////////////////////////////////////////////////////////////////////////////////// void circle(){ // circle, here is all about sin and cosine and data of dewey stroke(200,100,100); strokeWeight(0.5); p= mouseY/4; p1=mouseY/4; for(int x =0; x < 10; x++){ strokeWeight(p1/4); stroke(50,50,0,mouseY/4); line(w2 + cos(radians((((x*mu)))-a1))*p1,h2 + sin(radians((((x*mu)))-a1))*p1,(w2 + cos(radians((((x*mu)))-a1))*(p1+((arre[x]+arre1[x])/sc1))) ,(h2 + sin(radians((((x*30)+0))-a1))*(p1+((arre[x]+arre1[x])/sc1)))); stroke(200,0,0,50); line(w2 + cos(radians((((x*mu)))-a1))*p1,h2 + sin(radians((((x*mu)))-a1))*p1,(w2 + cos(radians((((x*mu)))-a1))*(p1+(arre[x]/sc1))) ,(h2 + sin(radians((((x*mu)+0))-a1))*(p1+(arre[x]/sc1)))); stroke(0,0,200,50); line(w2 + cos(radians((((x*mu)))-a1))*p1,h2 + sin(radians((((x*mu)))-a1))*p1,(w2 + cos(radians((((x*mu)))-a1))*(p1+(arre1[x]/sc1))) ,(h2 + sin(radians((((x*mu)+0))-a1))*(p1+(arre1[x]/sc1)))); } for(int x =0; x < 10; x ++){ strokeWeight(2); float je = random(100,200); int ja = int(je); stroke(255,100,0,-150+mouseY/2); // the lines line(w2 + cos(radians(((x+0)*30)-a))*p,h2 + sin(radians(((x+0)*30)-a))*p,(w2 + cos(radians(((x+0)*30)-a))*(p+arr[x]/sc)) ,(h2 + sin(radians(((x+0)*30)-a))*(p+arr[x]/sc))); line(w2 + cos(radians(((x)*30)-(a-2)))*p,h2 + sin(radians(((x)*30)-(a-2)))*p,(w2+ cos(radians(((x)*30)-(a-2)))*(p+arr1[x]/sc)) ,(h2 + sin(radians(((x)*30)-(a-2)))*(p+arr1[x]/sc))); line(w2 + cos(radians(((x)*30)-(a-4)))*p,h2 + sin(radians(((x)*30)-(a-4)))*p,(w2+ cos(radians(((x)*30)-(a-4)))*(p+arr2[x]/sc)) ,(h2 + sin(radians(((x)*30)-(a-4)))*(p+arr2[x]/sc))); line(w2 + cos(radians(((x+0)*30)-(a-6)))*p,h2 + sin(radians(((x+0)*30)-(a-6)))*p,(w2 + cos(radians(((x+0)*30)-(a-6)))*(p+arr3[x]/sc)) ,(h2 + sin(radians(((x+0)*30)-(a-6)))*(p+arr3[x]/sc))); line(w2 + cos(radians(((x)*30)-(a-8)))*p,h2 + sin(radians(((x)*30)-(a-8)))*p,(w2+ cos(radians(((x)*30)-(a-8)))*(p+arr4[x]/sc)) ,(h2 + sin(radians(((x)*30)-(a-8)))*(p+arr4[x]/sc))); line(w2 + cos(radians(((x)*30)-(a-10)))*p,h2 + sin(radians(((x)*30)-(a-10)))*p,(w2+ cos(radians(((x)*30)-(a-10)))*(p+arr5[x]/sc)) ,(h2 + sin(radians(((x)*30)-(a-10)))*(p+arr5[x]/sc))); line(w2 + cos(radians(((x+0)*30)-(a-12)))*p,h2 + sin(radians(((x+0)*30)-(a-12)))*p,(w2 + cos(radians(((x+0)*30)-(a-12)))*(p+arr6[x]/sc)) ,(h2 + sin(radians(((x+0)*30)-(a-12)))*(p+arr6[x]/sc))); line(w2 + cos(radians(((x)*30)-(a-14)))*p,h2 + sin(radians(((x)*30)-(a-14)))*p,(w2+ cos(radians(((x)*30)-(a-14)))*(p+arr7[x]/sc)) ,(h2 + sin(radians(((x)*30)-(a-14)))*(p+arr7[x]/sc))); line(w2 + cos(radians(((x)*30)-(a-16)))*p,h2 + sin(radians(((x)*30)-(a-16)))*p,(w2+ cos(radians(((x)*30)-(a-16)))*(p+arr8[x]/sc)) ,(h2 + sin(radians(((x)*30)-(a-16)))*(p+arr8[x]/sc))); line(w2 + cos(radians(((x)*30)-(a-18)))*p,h2 + sin(radians(((x)*30)-(a-18)))*p,(w2+ cos(radians(((x)*30)-(a-18)))*(p+arr9[x]/sc)) ,(h2 + sin(radians(((x)*30)-(a-18)))*(p+arr9[x]/sc))); } } ////////////////////////////////////////////////////////////////////////////////////////// void guide (){ // elements of the interface fill(50); rect(width-(width/10),mouseY-5,10,10); fill(50,50); rect(width-(width/10),mouseY-5,90,10); } ////////////////////////////////////////////////////////////////////////////////////////// String nameOfDataFileWithinDataDirectory = "smalldata.txt"; public ArrayList loadTransactions(String nameOfDataFileWithinDataDirectory) { ArrayList transactions = new ArrayList(); String[] lines = loadStrings(nameOfDataFileWithinDataDirectory); for (int i = 0; i < lines.length; i++) { transactions.add(parseTransaction(lines[i])); } return transactions; } ////////////////////////////////////////////////////////////////////////////////////////// // This function returns all the files in a directory as an array of File objects // This is useful if you want more info about the file public File[] listFiles(String dir) { File file = new File(dir); if (file.isDirectory()) { File[] files = file.listFiles(); return files; } else { // If it's not a directory return null; } } ////////////////////////////////////////////////////////////////////////////////////////// //create a new transaction obejct from a comma separated line. For this example we are only storing subjects. public Transaction parseTransaction(String line) { String sections[] = split(line, ","); Transaction t = new Transaction(); t.ckodate = sections[0]; t.ckotime = sections[1]; t.ckidate = sections[2]; t.ckitime = sections[3]; t.itemtype = sections[4]; t.deweyClass = sections[5]; // "ckodate", "ckotime", "ckidate", "ckitime", "itemtype", "deweyClass" return t; } /////////////////////////////////////////////////////////////////////////////////////////