class Title{ String title; HashMap titleWords = new HashMap(); HashMap connections = new HashMap(); PVector p; PVector targetP; //this used to manage multiple recusion integrators int dewCode; boolean pTargetOn = false; boolean firstLoad = true; boolean targetOpacity = false; Integrator g[] = new Integrator[3]; Integrator opacity = new Integrator(); public Title(String title, PVector p, float deweyClass){ this.title = title; this.p = p; this.targetP = p; //spaces[int(p.x)][int(p.y)][int(p.z)] = this; parseTitle(title, deweyClass); // g[0] = new Integrator(0.001,0.01, 1); // g[1] = new Integrator(0.001,0.01, 1); // g[2] = new Integrator(0.001,0.01, 1); g[0] = new Integrator(0.1,0.01, 1); g[1] = new Integrator(0.1,0.01, 1); g[2] = new Integrator(0.1,0.01, 1); opacity = new Integrator(0.001, 0.03, 1); g[0].noTarget(); g[1].noTarget(); g[2].noTarget(); opacity.set(0); opacity.target(255); opacityIntegrators.put(this.title, this); targetOpacity = true; } public void updateIntegrators(){ //unfortunately this is updating everything if(this.pTargetOn == true){ //this means it's in range for completeion if(g[0].value < g[0].target+20 && g[0].value > g[0].target-20 && g[1].value < g[1].target+20 && g[1].value > g[1].target-20 && g[2].value < g[2].target+20 && g[2].value > g[2].target-20){ println("pop "+this.title); activeIntegrators.remove(this.title); this.pTargetOn = false; } else{ g[0].update(); g[1].update(); g[2].update(); p.x = g[0].value; p.y = g[1].value; p.z = g[2].value; } } if(opacity.hasTarget()) opacity.update(); else opacity.noTarget(); if(targetOpacity == true && opacity.value >= 240){ opacityIntegrators.remove(this.title); targetOpacity = false; } } void parseTitle(String title, float deweyClass){ int arraySize = 1; int count = 0; String words[] = split(title, ' '); Word w; for(int k = 0; k < title.length(); k++){ if(title.charAt(k) == ' '){ arraySize++; } } //get each word individually for(int j = 0; j < arraySize; j++){ words[j] = words[j].toLowerCase(); //if the word is greater than 2 letters and isn't a forbidden "boring" word if(words[j].length() > 2 && !(no.containsKey(words[j]))){ //if it's in a given class if((deweyClass >= 230 && deweyClass < 240) || (deweyClass >= 297 && deweyClass < 298) || (deweyClass >= 294 && deweyClass < 295)){ if(deweyClass >= 230 && deweyClass < 240){ dewCode = 0; } else if(deweyClass >= 297 && deweyClass < 298){ dewCode = 1; } else{ dewCode = 2; } } } }//end adding all of the words, now add the connections if(words.length> 1){ addConnectionsNew(words); } } public void addConnections(String[] title){ Map.Entry me; String t; Title tobj; int count; boolean found = false; String[] thisTitle; Iterator it = titleStrings.entrySet().iterator(); while(it.hasNext()){ me = (Map.Entry) it.next(); t = (String) me.getKey(); tobj = (Title) me.getValue(); for(int i=0; i< title.length; i++){ found = false; if(!no.containsKey(title[i])){ //need to make sure that there are spaces on either side if(t.indexOf(title[i]) >= 0 && title[i].length() > 2){ thisTitle = t.split(" "); //make sure the reverse is true for(int j = 0; j< thisTitle.length; j++){ if(title[i].equals(thisTitle[j])){ found = true; } } if(found == true){ if(connections.containsKey(tobj) ){ count = int(connections.get(tobj).toString()); connections.put(tobj,++count); if(count > maxConnections){ maxConnections = count; } } else{ connections.put(tobj, 1); } if(titleWords.containsKey(title[i])){ count = int(titleWords.get(title[i]).toString()); titleWords.put(title[i],++count); } else{ titleWords.put(title[i], 1); } } } } } } } public void addConnectionsNew(String[] title){ String t; Title tobj; String[] thisTitle; //look through the words that have already been printed Iterator it = printTitles.iterator(); while(it.hasNext()){ tobj = (Title) it.next(); t = tobj.title; for(int i=0; i< title.length; i++){ if(!no.containsKey(title[i])){ //if the other title has the current title's word, go to the next step if(t.indexOf(title[i]) >= 0 && title[i].length() > 2){ thisTitle = t.split(" "); //make sure the reverse is true for(int j = 0; j< thisTitle.length; j++){ if(title[i].equals(thisTitle[j])){ addThisConnection(tobj, title[i]); addTheOtherConnection(tobj, title[i]); } } } } } } } void putTargetValues(PVector target){ activeIntegrators.put(this.title, target); // spaces[int(p.x)][int(p.y)][int(p.z)] = null; targetP.x = g[0].target; targetP.y = g[1].target; targetP.z = g[2].target; // spaces[int(g[0].target)][int(g[1].target)][int(g[2].target)] = this; println("put "+this.title); this.pTargetOn = true; } //adds title t, to the connected list void addThisConnection(Title t, String word){ int count; if(connections.containsKey(t)){ count = int(connections.get(t).toString()); connections.put(t, count++); } else{ connections.put(t,1); } if(titleWords.containsKey(word)){ count = int(titleWords.get(word).toString()); titleWords.put(word, count++); } else{ titleWords.put(word,1); } } //adds the current title to the other title's connected list void addTheOtherConnection(Title t, String word){ int count; if(t.connections.containsKey(this)){ count = int(t.connections.get(this).toString()); t.connections.put(this, count++); } else{ t.connections.put(this,1); } if(t.titleWords.containsKey(word)){ count = int(titleWords.get(word).toString()); t.titleWords.put(word, count++); } else{ t.titleWords.put(word,1); } } }