//do some calculations void calcMinMax() { int i = 0; long sumC = 0; int sumD = 0; int popLabelNum = 0; Set set= itemTypes.keySet ( ) ; Iterator iter = set.iterator ( ) ; while ( iter.hasNext ( ) ) { i++; Item I = (Item)itemTypes.get(iter.next()); if (I.avgCheckOutDur > maxDur) maxDur = I.avgCheckOutDur; else if (I.avgCheckOutDur < minDur) minDur = I.avgCheckOutDur; if (I.count > maxCount) maxCount = I.count; else if (I.count < minCount) minCount = I.count; sumC += I.count; sumD += I.avgCheckOutDur; if(I.count > popLabelNum){ popLabelNum = I.count; popLabel = I.listing.getLabel(); } for (int j = 1; j<=7; j++) masterDayDistribution[j] += I.dayDistribution[j]; } avgCount = (float)sumC/i; totalCount = sumC; avgDur = (float)sumD/i; masterDayMode = 7; for (int k = 1; k<=6; k++) if(masterDayDistribution[k] > masterDayDistribution[masterDayMode]) masterDayMode = k; } 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. public Transaction parseTransaction(String line) { String sections[] = split(line, ","); // ItemListing info = null; Transaction t = new Transaction(); //store all fields // t.itemNumber = sections[0]; // t.bibNumber = sections[1]; t.ckodate = sections[0]; t.ckotime = sections[1]; t.ckidate = sections[2]; t.ckitime = sections[3]; // t.collcode = sections[6]; t.itemtype = sections[4]; // t.barcode = sections[8]; // t.title = sections[9]; // t.callNumber = sections[10]; // t.deweyClass = sections[5]; // add to the hashmap of itemtypes //if... check if this entry belongs in graph String s = t.itemtype; if (itemTypes.containsKey(s)) { Item I = (Item) itemTypes.get(s); I.count(t); } else { Item I = new Item(s); if (itemTable.containsKey(s)) // info = (ItemListing) itemTable.get(s); itemTypes.put(s, I); I.count(t); } return t; } HashMap getItemTable(String fileName) { println("Collecting Item Table"); HashMap internalItemTable = new HashMap(); String[] itemEntry = new String[4]; String[] tmpEntry; String[] collLoc = { "85", "197" , "328", "503" }; String[] lines = loadStrings(fileName); for (int i = 0; i < lines.length; i++) { String[] item_labels = null; for (int j = 0; j<=3; j++) { item_labels = match(lines[i], ";left:" + collLoc[j] + "\">[A-Za-z\\-/ ]*"); if(item_labels != null){ tmpEntry = splitTokens(item_labels[0], ">"); itemEntry[j] = tmpEntry[1]; if (j !=3) i++; } else{ itemEntry[j] = null; if(j == 3 && itemEntry[j-1] != null) i--; } } if (itemEntry[0] != null){ ItemListing I = new ItemListing(itemEntry[0], itemEntry[1], itemEntry[2], itemEntry[3]); // println(itemEntry[0] + "\t\t" + itemEntry[1] + "\t\t" + itemEntry[2] + "\t\t" + itemEntry[3]); internalItemTable.put(itemEntry[0], I); } } println("entries found: "+ internalItemTable.size()); return internalItemTable; } int[] getColor(String label){ int[] rgb; rgb = new int[]{ 0,0,0 }; if (label.endsWith("cas")) // audio tape rgb = new int[]{ 255,0,77 }; else if (label.endsWith("bk")) // book rgb = new int[]{ 255, 0, 204 }; else if (label.endsWith("cd")) rgb = new int[]{ 204 , 255 ,0 }; else if (label.endsWith("cdrom")) rgb = new int[]{ 0, 204, 255 }; else if (label.endsWith("disk")) rgb = new int[]{ 0, 76, 255 }; else if (label.endsWith("dvd")) rgb = new int[]{ 255 ,110,0 }; else if (label.endsWith("fold")) rgb = new int[]{ 220, 254,0 }; else if (label.endsWith("art")) rgb = new int[]{ 0,21,254 }; else if (label.endsWith("illb")) rgb = new int[]{ 97,0,254 }; else if (label.endsWith("illl")) rgb = new int[]{ 254,30,0 }; else if (label.endsWith("kit")) rgb = new int[]{ 255,255,51 }; else if (label.endsWith("per")) rgb = new int[]{ 153,255,51 }; else if (label.endsWith("map")) rgb = new int[]{ 51,255,102 }; else if (label.endsWith("mfc")) rgb = new int[]{ 51,255,255 }; else if (label.endsWith("mfm")) rgb = new int[]{ 102,51,255 }; else if (label.endsWith("mus")) rgb = new int[]{ 255,51,119 }; else if (label.endsWith("np")) rgb = new int[]{ 163,206,235 }; else if (label.endsWith("ord")) rgb = new int[]{ 253,190,166 }; else if (label.endsWith("pam")) rgb = new int[]{ 246,22,22 }; else if (label.endsWith("photo")) rgb = new int[]{ 231,71,191 }; else if (label.endsWith("post")) rgb = new int[]{ 153,255,51 }; else if (label.endsWith("rec")) rgb = new int[]{ 255,255,51 }; else if (label.endsWith("slide")) rgb = new int[]{ 6,139,227 }; else if (label.endsWith("vhs")) rgb = new int[]{ 117,246,127 }; else if (label.endsWith("med")) rgb = new int[]{ 204,34,31 }; else if (label.endsWith("vid")) rgb = new int[]{ 204,66,242 }; else if (label.endsWith("web")) rgb = new int[]{ }; else rgb = new int[]{ 255,255,255 }; return rgb; }