int nodeCount; Node[] nodes = new Node[100]; HashMap nodeTable = new HashMap( ); static final color nodeColor = #F0C070; PFont font; float minX, maxX; float minY, maxY; void setup() { size(800, 800); loadData(); font = createFont("SansSerif", 30); textFont(font); smooth( ); } void loadData() { String[] lines = loadStrings("words_mds.txt"); // Split into phrases using any of the provided tokens. minX = 3.4e38; minY = 3.4e38; maxX = -3.4e38; maxY = -3.4e38; float x, y; for (int i = 0; i < lines.length; i++) { println(lines[i]); // Make this phrase lowercase. // Split each phrase into individual words at one or more spaces. String[] pieces = splitTokens(lines[i], " ,"); if(pieces.length==3) { x = float(pieces[1]); y = float(pieces[2]); if(x < minX) minX = x; if(x > maxX) maxX = x; if(y < minY) minY = y; if(y > maxY) maxY = y; } } println(minX); println(maxX); println(minY); println(maxY); for (int i = 0; i < lines.length; i++) { String[] pieces = splitTokens(lines[i], " ,"); if(pieces.length==3) { x = map(float(pieces[1]), minX, maxX, 0, width); y = map(float(pieces[2]), minY, maxY, 0, height); addNode(pieces[0], x, y); } } } void draw( ) { background(255); //translate(width/2, height/2); //scale(30.0, 30.0);//width/(maxX-minX), height/(maxY-minY)); for (int i = 0 ; i < nodeCount ; i++) { nodes[i].draw(nodes[i].isIn(mouseX,mouseY)); } } Node addNode(String label, float x, float y) { Node n = new Node(label, x, y); if (nodeCount == nodes.length) { nodes = (Node[]) expand(nodes); } nodeTable.put(label, n); nodes[nodeCount++] = n; return n; }