import java.util.*; // function to read the parsed txt file and use it // to extract the checkout time information Date [] CkoutDates; Date [] CkinDates; int [] Category; long [] Differences; float plotX1, plotY1; float plotX2, plotY2; float labelX, labelY; long MaxTime=0; int [] TransCat ={0,0,0,0,0,0,0,0,0,0,0}; String[] DeweyNumbers = {"000","100","200","300","400","500","600","700","800","900","No Dewey"}; PFont font; void setup() { size(800,600); String lines[] = loadStrings("splxmlTIMES2010-10-29.txt"); font = loadFont("UniversLTStd-Cn-14.vlw"); CkoutDates = new Date[lines.length]; CkinDates = new Date[lines.length]; Category = new int[lines.length]; Differences = new long [lines.length]; //// going line by line for (int i=0; i < lines.length; i++){ String[] ParseList = split(lines[i],','); int TheYear = int(ParseList[0].substring(0,4)); int TheMonth = int(ParseList[0].substring(5,7)); int TheDay = int(ParseList[0].substring(8,10)); int TheHour = int(ParseList[1].substring(0,2)); int TheMinute = int(ParseList[1].substring(3,5)); CkoutDates[i] = new Date(TheYear,TheMonth,TheDay,TheHour,TheMinute); TheYear = int(ParseList[2].substring(0,4)); TheMonth = int(ParseList[2].substring(5,7)); TheDay = int(ParseList[2].substring(8,10)); TheHour = int(ParseList[3].substring(0,2)); TheMinute = int(ParseList[3].substring(3,5)); CkinDates[i] = new Date(TheYear,TheMonth,TheDay,TheHour,TheMinute); Differences[i] = (CkinDates[i].getTime()-CkoutDates[i].getTime()); // if (CkoutDates[i].getYear()!=1970){ if (Differences[i] >MaxTime){ MaxTime = Differences[i]; println(MaxTime/(1000*60*60*24) + " " + CkoutDates[i].getYear() + " " +CkoutDates[i] + " "+ CkinDates[i]); } // } if(ParseList[4].length()==0){ Category[i]=10; } else{ Category[i]= int(ParseList[4].substring(0,1)); } TransCat[Category[i]]++; // println (CkoutDates[i] + " " + CkinDates[i] + " " + Category[i]); } plotX1 = 160; plotX2 = width - 30; labelX = 20; plotY1 = 30; plotY2 = height - 40; labelY = height - 20; } void draw(){ drawScatter(); } void drawScatter(){ float PointX; float PointY; background(255); stroke(120); fill(128,128,128,190); int MaxCat =0; // Finding the Category with more transaction for(int c=0; c < 11;c++){ if (TransCat[c] > MaxCat){ MaxCat = TransCat[c]; } } for (int t=0; t