/*
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.
*/
import rita.*; // for rita
import megamu.shapetween.*; // for animations
RiStemmer stem; // for stem words
RiSpeech vozSelected; // voice of girl
RiSpeech vozNews; // voice of man for the news
Tween ani; // animation for node travel from the original position to center of screen
color nodeColor = color(255,191,0,200);
color selectColor = color(255,191,0);
color fixedColor = color(232,0,31,200);
color edgeColor = color(255,255,255);
//color fixedColor = #E8001F;
boolean vozSelectedBusy; //True if the voice of User Interface is busy
boolean vozNewsBusy; //True if the voice for speak news is busy
int lastNews; //last SemanticNet marked
boolean searchMode = false; //True if a word is searched
boolean zoomMode=false;
boolean mouseOver = false; //True if the position of mouse is clickable
PFont font;
String[] stopWords; //Array for load the stopWords
String textNews=""; //String for read the news
int filtro=10; //Initial filter
float zoom = 0; //Zoom for show or not show the nodes
float minZoom; //Min Zoom Permited
float maxZoom; //Max Zoom Permited
SemanticNet snIsrael; //Semantic net of Israel Official News media
SemanticNet snPalestina; //Semantic net of Palestina Media & blogs
SearchBox searchBox; //The search Box object: for find & meta info
void setup() {
//size(screen.width, screen.height); //For fullScreen
size(1200, 650);
background(0);
frameRate(25);
smooth();
font = createFont("Arial-BoldMT-18.vlw", 6);
textFont(font);
//Use for application run (better voices, you need mbrola binary)
//vozSelected = new RiSpeech(this,"us1","/usr/share/mbrola");
//vozNews = new RiSpeech(this,"mbrola_us3","/usr/share/mbrola");
//Use for applet mode -> without mbrola
vozSelected = new RiSpeech(this);
vozNews = new RiSpeech(this);
stem = new RiStemmer(this); //For Stem Objects
searchBox = new SearchBox(this,0,height-95); //The Searchbox object
snIsrael = new SemanticNet(this,1,0,0,width/2,height); //Semantic Net about Israel
snPalestina = new SemanticNet(this,2,width/2,0,width/2,height); //Semantic Net about Gaza/Palestina
ani = new Tween(this, 5,Tween.SECONDS, Shaper.COSINE); //Animation for node searched position
addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
mouseWheel(evt.getWheelRotation());
}});
//Download data from RSS
//downloadIsraelData();
//downloadPalestinaData();
//Load data
snIsrael.loadData();
snPalestina.loadData();
//Welcome
vozSelected.speak("Welcome to Massive Comprension Machine"); //Sounds beeter!
}
//The CORE draw
void draw() {
background(20);
mouseOver=false;
snIsrael.draw();
snPalestina.draw();
searchBox.draw();
//True if the mouse have a position clickable
if (mouseOver)
cursor(HAND);
else
cursor(CROSS);
}
//################# Handle Events ############################
void mouseWheel(int delta) { //Called when the user move the mouse wheel
float z=zoom-delta;
makeZoom(z);
}
void makeZoom(float z){ //Manage the zoom of the Semantic net
println(frameCount + "- Zoom: "+ zoom+ " Z: "+ z);
if (zoomMode)
zoom = z; //If zoomMode is true the zoom is free
else{
if ((snIsrael.visibleNodes>1) && (snPalestina.visibleNodes>1) && (zoom<=filtro) ) //Only change the zoom between the interval
zoom=z;
else{
if ((z>zoom) && (zoom <= filtro)) //If the zoom is minimal, we can only zoom in
zoom = z;
else
if ((zoom >= filtro) && z