/* This file is part of Massive Comprehension Machine by Lot AmorĂ³s http://mcm.feenelcaos.org Massive Comprehension Machine is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License. Massive Comprehension Machine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Massive Comprehension Machine. If not, see . One part of this code is based on the book Visualizing Data from Ben Fry. */ class Node{ float x, y; float dx, dy; boolean fixed; //True if the node is fixed with the mouse boolean searched; //True if is the node searched String label; //The word stemmed float count; //Number of words found String originalLabel; //The original label of the word (not stemmed) ArrayList contexts; //List of texts when the word are founded boolean near; //True if the node is a near ot the node searched Node(String stemLabel,String label, String context,int _x, int _y, int sizeX, int sizeY) { this.label = new String(stemLabel); this.originalLabel = new String(label); this.contexts = new ArrayList(); contexts.add(context); this.searched = false; this.near = false; x = random(_x,_x+sizeX); y = random(_y,_y+sizeY); } void increment() { count++; } void draw() { float closest = 5; float d = dist(mouseX, mouseY, x, y); //Distance between mouse and node color nCol; //Color for draw the node if ((d-(zoom+count)/2 < closest) && (count+zoom >= filtro)){ nCol = selectColor; mouseOver = true; } else{ nCol = nodeColor; } if (fixed) nCol = fixedColor; stroke(0); strokeWeight(0.5); if (searchMode){ //If the machine is in searchmode only shows the node searched and near nodes if (zoomMode && this.searched) drawNode(nCol); else if (this.near || this.searched) if (count+zoom >= filtro) { drawNode(nCol); } } else{ //Normal mode if (count+zoom >= filtro) { drawNode(nCol); } } } void drawNode(color nCol){ fill(nCol); strokeWeight(1); ellipse(x, y, count+zoom, count+zoom); fill(#000000); textAlign(CENTER,CENTER); textFont(font, count+zoom+2); //Print Shadow text(originalLabel, x, y); fill(#FFFFFF); textFont(font, count+zoom); text(originalLabel, x, y); //Print label } }