/* 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 Edge { Node from; Node to; float len; int count; boolean near; String context; //The context when the words are found Edge(Node from, Node to) { this.from = from; this.to = to; this.len = 50; this.near = false; this.context=""; } void increment() { count++; } void relax() { float vx = to.x - from.x; float vy = to.y - from.y; float d = mag(vx, vy); if (d > 0) { float f = (len - d) / (d * 3); float dx = f * vx; float dy = f * vy; to.dx += dx; to.dy += dy; from.dx -= dx; from.dy -= dy; } } void draw() { if (searchMode){ //If a word is searched if ((from.count+zoom) > filtro && (to.count+zoom)>filtro) if (this.near){ stroke(edgeColor); strokeWeight(count); line(from.x, from.y, to.x, to.y); } } else{ //Normal mode if ((from.count+zoom) > filtro && (to.count+zoom)>filtro) { stroke(edgeColor); strokeWeight(count); line(from.x, from.y, to.x, to.y); } } } }