jparsons – Project 2 – Project Gutenberg

by Jordan Parsons @ 9:20 pm 30 January 2011

So for this project I chose to look at a rdf dump of the project Gutenberg catalog. This is their online listing of almost 30,000 books that are public domain. Their website is very old and clunky to use. So I used processing and a MySQL database to go over their site and try to visualize the data from the catalog looking for some statistics and comparisons where I could.

The Data

I processed the .RDF Project Gutenberg catalog into a MySQL database.

Going from:

<pgterms:etext rdf:ID="etext34067">
<dc:publisher>&pg;</dc:publisher>
<dc:title rdf:parseType="Literal">Catholic Churchmen in Science</dc:title>
<dc:creator rdf:parseType="Literal">Walsh, James J.</dc:creator>
<pgterms:friendlytitle rdf:parseType="Literal">Catholic Churchmen in Science by James J. Walsh</pgterms:friendlytitle>
<dc:language><dcterms:ISO639-2><rdf:value>en</rdf:value></dcterms:ISO639-2></dc:language>
<dc:created><dcterms:W3CDTF><rdf:value>2010-10-13</rdf:value></dcterms:W3CDTF></dc:created>
<dc:rights rdf:resource="&lic;" />
</pgterms:etext>

to :

<book_id id="etext34067">
</book_id>
<book_title id="title">Catholic Churchmen in Science</book_title>
<book_auth id="auth">Walsh, James J.</book_auth>
<book_etitle id="etitle">Catholic Churchmen in Science by James J. Walsh</book_etitle>
<book_lang id="lang">en</book_lang>
<book_created id="create">2010-10-13</book_created>

Then processed through processing’s XML functions into a MySQL database.

The table has 30,248 entries and its about 6 mb in size. This should give me a huge dataset to start to play with and analyze.

MySQL Format:
id 1
book_id etext34714
book_title Catholic Churchmen in Science
book_auth Walsh, James J.
book_etitle Catholic Churchmen in Science by James J. Walsh
book_lang en
book_created 10/13/2010

The Project
The data is visualized as if it is a simple book itself. Once the book is opened the table of contents appears, listing the different methods of browsing the catalog. Each method is listed with the number of different sub categories it contains within itself. This top layer shows a bar graph across the bottom showing the relative scale of the different categories. This same graph changes across the project to show the amount of books each sub category (such as author, or language) has in it. Once a category is picked the user can page through the entries in that category. Upon clicking an author the user is given one of their books to read, the url of which is provided through google, because since releasing the data, they have changed their book id, system so it is impossible to link directly to the book.

My Critique
This project is by no means as successful as I had desired. I think it was a good experience for me to develop this kind of project as I have not programed that many things with user interfaces before. In addition I learned a lot about how to work with strings and data, something I had not had that much exposure to. I’m somewhat happy with the result, but the level of polish I had hoped for and many of the features I wanted are just not there. I think I would take an other iteration for me to get this project to a state where I am happy with it.

http://prezi.com/pdbjwudnrsef/project-2-project-gutenberg-info-viz/

Code:

 
import de.bezier.data.sql.*;
 
book book;
graph graph;
//Book text_book;
 
PImage frame;
PFont base_text,big_text;
MySQL mysql;
int total_entries, book_right_tip,book_right_side,book_bottom_tip;
int margin, page_l,page_r;
int high;
ArrayList g_n, g_t;
String location;
boolean book_open, graph_on;
 
void setup() {
  //Setup
  background(255);
  smooth();
  size(1000,600);
 
  //Vars
  margin = 10;
  ArrayList g_t = new ArrayList();
  ArrayList g_n = new ArrayList();
  location = "Click To Begin";
  book_open = false;
  book = new book(270,400);
  graph_on = false;
  high = 0;
 
  //Text Stuff
  base_text = loadFont("Swiss721BT-Roman-48.vlw");
  big_text = loadFont("Swiss721BT-Bold-48.vlw");
 
  //MySQL Stuff
  String user     = "root";
  String pass     = "989777989";
  String database = "rdf_dump";
  mysql = new MySQL( this, "localhost", database, user, pass );
  mysql.connect();
  mysql.query( "SELECT COUNT(DISTINCT id) FROM books" );
  mysql.next();
  total_entries = mysql.getInt(1);
 
  //Misc
  fill(100);
  textFont(big_text,24);
  text("Project Gutenberg",5,25);
  textFont(base_text,14);
  text("A book of "+total_entries+" books.",5,40);
  book.draw_book(false,0,0);
}
 
void update() {
  //Run Queries
}
 
void draw() {
  //Math
  update();
  //Make Pretty Things
 
  //Header
  background(255);
  //Graph BG
  if(graph_on==true) {
    graph.render(high);
  }
  //Rest
  book.draw_book(book_open,0,0);
  fill(100);
  textFont(big_text,24);
  text("Project Gutenberg",5,25);
  textFont(base_text,14);
  text("A book of "+total_entries+" books.",5,40);
  //Book Base
 
  book.fill_book();
  disp_info();
  if(book.fill_book = true && book.book_layer >1) {
    book.book_link_on = true;
  }
}
 
 
void disp_info() {
  //draw
 
  textFont(base_text,10);
  text(location, book.book_right_side, book.book_right_tip+15);
  if(book_open == false) {
    text("Instructions:", book.book_right_side, book.book_right_tip+30);
    text("Click the cover to start,", book.book_right_side, book.book_right_tip+45);
    text("then browse through the data using your mouse.", book.book_right_side, book.book_right_tip+60);
    text("Arrow keys move pages, space closes the book.", book.book_right_side, book.book_right_tip+75);
  }
}
 
 
void anim_open_book() {
  //animate the book opening
}
 
boolean overTitle() 
{
  if (mouseX >= 0 && mouseX <= 150 && 
    mouseY >= 0 && mouseY <= 50) {
    return true;
  } 
  else {
    return false;
  }
}
 
 
void mousePressed() {
  if(overTitle()==true) {
    setup();
  } 
  else {
 
    if(book_open == false) {
      book_open = true;
      book.book_layer = 1;
      location = "Index";
      page_l = 1;
      page_r = 10;
      book.fill_book = false;
    } 
    else {
 
      if(book.overAuth() == true&& book.book_layer == 1) {
        book.book_layer = 2;
      } 
      else
        if(book.overLang() == true&& book.book_layer == 1) {
          book.book_layer = 3;
        } 
        else
          if(book.overContrib() == true&& book.book_layer == 1) {
            book.book_layer = 4;
          } 
          else
            if(book.overDate() == true&& book.book_layer == 1) {
              book.book_layer = 5;
            }
      if(book.overIndex() == true && book.book_layer != 1 && book.book_layer != 0) {
        book.book_layer = 1;
      } 
      else
        if(book.overPage_1()==true) {
          //clicked right page 
          book.page_l();
          book.c2_back = true;
          book.c3_back = true;
          book.c4_back = true;
          book.c5_back = true;
          book.c2 = false;
          book.c3 = false;
          book.c4 = false;
          book.c5 = false;
          book.fill_book = false;
        }
        else if(book.overPage_2()==true) {
          book.page_r(); 
          book.c2 = false;
          book.c3 = false;
          book.c4 = false;
          book.c5 = false;
          println("bla");
 
          if(book.book_link_on == true) {
            String[] test = split(book.book_link_id, "etext");
            String test2 = book.book_link_title;
            test2 = test2.replace(" ","+");
            link("http://www.google.com/search?q="+test2+"+site:http://www.gutenberg.org/");
            println("http://www.gutenberg.org/ebooks/search.html/?format=html&default_prefix=titles&sort_order=downloads&query="+test2+"");
            book.book_link_on = false;
          }
        } 
        else {
        }
      if(book.overItem()>-1) {
      }
    }
  }
}
 
 
 
 
void keyPressed() {
  if(key == ' ') {
    setup();
  }
 
  if(keyCode == LEFT) {
    book.page_l();
    switch(book.book_layer) {
 
    case 0:
      break;
 
    case 1:
 
 
      break;
 
    case 2:
      book.c2_back = true;
      book.c2 = false;
      break;
 
    case 3:
      break;
 
    case 4:
      break;
    }
  }
 
  if(keyCode == RIGHT) {
    book.page_r();
    switch(book.book_layer) {
 
    case 0:
      break;
 
    case 1:
 
 
      break;
 
    case 2:
      book.c2 = false;
      break;
 
    case 3:
      break;
 
    case 4:
      break;
    }
  }
  if(key == '2') {
    book.book_layer = 2;
  }
}
//Layers-------------
//0 closed
//1 index
//2 authors
//4 titles
//3 lang
//5 date
//-------------------
 
class book {
  int book_right_side, book_right_tip, book_bottom_tip; 
  int book_x, book_y, margin, offset, text_width, book_layer;
  ArrayList book_stats, book_auths, book_auths_n, book_lang, book_lang_n, book_contrib, book_contrib_n, book_date, book_date_n;
  int max_stuff, start, end,item;
  String out ,book_link_id, book_link_title;
 
  boolean fill_book,book_link_on;
 
 
  boolean c1,c2,c3,c4,c5;
  boolean c2_back,c3_back,c4_back,c5_back;
 
  book(int bx, int by) {
    margin = 10;
    offset = 100;
    book_x = bx;
    book_y = by;
    book_right_side = book_x+margin;
    book_right_tip = offset;
    book_bottom_tip = offset+book_y;
    book_layer = 0;
 
    c1=c2=c3=c4=c5=false;
    book_stats = new ArrayList();
    book_auths = new ArrayList();
    book_auths_n = new ArrayList();
    book_lang = new ArrayList();
    book_lang_n = new ArrayList();
    book_contrib = new ArrayList();
    book_contrib_n = new ArrayList();
    book_date = new ArrayList();
    book_date_n = new ArrayList();
    max_stuff = 30;
    start = 0;
    c2_back = false;
    c3_back = false;
    book_link_on = false;
    fill_book = false;
    end = max_stuff;
    out = "";
  }
 
  void draw_book(boolean book_open, int book_pages,int book_read_pages) {
 
    if(!book_open) {
      stroke(200);
      fill(255);
      book_right_side = book_x+margin+offset;
      book_right_tip = offset;
      book_bottom_tip = offset+book_y;
      rect(offset,offset,book_x,book_y);
      line(offset+10,offset,offset+10,book_bottom_tip);
    }
    else {
      stroke(200);
      fill(255);
      book_right_side = book_x*2+margin+offset;
      book_right_tip = offset;
      book_bottom_tip = offset+book_y;
      rect(offset,offset,book_x,book_y);
      rect(offset+book_x,offset,book_x,book_y);
      draw_pages(page_l,page_r);
    }
  }
 
  void fill_book() {
    //text on pages
    if(book_open == false) {
      //cover!
      textFont(big_text,20);
      textAlign(CENTER);
      text("Project Gutenberg",offset,offset+book_y/2-20,book_x,book_y);
 
      textFont(base_text,12);
      text("Catalog",offset,offset+book_y/2+12,book_x,book_y);
      textAlign(LEFT);
    } 
    else {
      //Data
      get_data("");
      render_data();
 
      //Labels
 
      switch(book_layer) {
 
      case 0:
        break;
 
      case 1:
        textFont(big_text,14);
        color(150);
        textAlign(RIGHT);
        text("Table of Contents",offset+book_x-margin,offset+14+margin);
        textAlign(LEFT);
 
 
        break;
 
      case 2:
        textFont(big_text,14);
        color(150);
        textAlign(RIGHT);
        text("Authors",offset+book_x-margin,offset+14+margin);
        textAlign(LEFT);
        for(int i = 0; i<book_auths.size(); i++) {
          textFont(base_text,12);
          color(150);
          textAlign(RIGHT);
          text((String) book_auths.get(i),width-margin,offset+(13*i));
          textAlign(LEFT);
        }
        break;
 
      case 3:
        textFont(big_text,14);
        color(150);
        textAlign(RIGHT);
        text("Languages",offset+book_x-margin,offset+14+margin);
        textAlign(LEFT);
        for(int i = 0; i<book_lang.size(); i++) {
          textFont(base_text,12);
          color(150);
          textAlign(RIGHT);
          text((String) book_lang.get(i),width-margin,offset+(13*i));
          textAlign(LEFT);
        }
        break;
 
      case 4:
        textFont(big_text,14);
        color(150);
        textAlign(RIGHT);
        text("Contributiors",offset+book_x-margin,offset+14+margin);
        textAlign(LEFT);
        for(int i = 0; i<book_contrib.size(); i++) {
          textFont(base_text,12);
          color(150);
          textAlign(RIGHT);
          text((String) book_contrib.get(i),width-margin,offset+(13*i));
          textAlign(LEFT);
        }
        break;
 
      case 5:
        textFont(big_text,14);
        color(150);
        textAlign(RIGHT);
        text("Dates Added",offset+book_x-margin,offset+14+margin);
        textAlign(LEFT);
        for(int i = 0; i<book_date.size(); i++) {
          textFont(base_text,12);
          color(150);
          textAlign(RIGHT);
          text((String) book_date.get(i),width-margin,offset+(13*i));
          textAlign(LEFT);
        }
        break;
      }
      if(fill_book == true) {
        if(out.equals("")) {
        } 
        else {
          textFont(base_text,12);
          text(out,offset+book_x+margin,offset+14+margin,offset+book_x*2-margin,offset+book_y);
          textAlign(LEFT);
        }
      }
    }
  }
 
 
  void textFill(int item) {
    //link("http://www.processing.org", "_new");
 
    switch(book_layer) {
 
    case 0:
      fill_book = false;
      break;
 
 
    case 1:
      fill_book = false;
      break;
 
    case 2:
 
      mysql.query( "SELECT * FROM `books` WHERE `book_auth` = '"+book_auths.get(item)+"'" );
      mysql.next();
 
      out = mysql.getString("book_title");
      book_link_id = mysql.getString("book_id");
      book_link_title = (String) mysql.getObject("book_etitle");
      println(book_link_title);
      fill_book = true;
 
      break;
 
    case 3:
      out = "";
 
      textFont(base_text,12);
      text(out,offset+book_x+margin,offset+14+margin,offset+book_x*2,offset+book_y);
      textAlign(LEFT);
      break;
 
    case 4:
      out = "";
 
      textFont(base_text,12);
      text(out,offset+book_x+margin,offset+14+margin,offset+book_x*2,offset+book_y);
      textAlign(LEFT);
      break;
 
    case 5:
      String out = "";
 
      textFont(base_text,12);
      text(out,offset+book_x+margin,offset+14+margin,offset+book_x*2,offset+book_y);
      textAlign(LEFT);
      break;
    }
  }
 
 
  void get_data(String misc) {
 
    switch(book_layer) {
 
    case 0:
      break;
 
    case 1:
      //Index
      if(c1 == false) {
        mysql.query( "SELECT COUNT(DISTINCT book_auth) FROM books" );
        mysql.next();
        book_stats.add(mysql.getInt(1));
 
        mysql.query( "SELECT COUNT(DISTINCT book_lang) FROM books" );
        mysql.next();
        book_stats.add(mysql.getInt(1));
 
        mysql.query( "SELECT COUNT(DISTINCT book_contrib) FROM books" );
        mysql.next();
        book_stats.add(mysql.getInt(1));
 
 
        mysql.query( "SELECT COUNT(DISTINCT book_created) FROM books" );
        mysql.next();
        book_stats.add(mysql.getInt(1));
 
        graph = new graph(book_stats);
        graph_on = true;
 
        c1 = true;
      } 
 
      break;
 
    case 2:
      //auths
      if(c2 == false) {
        //right page clicked
        if(c2_back == false) {
          println( "+SELECT DISTINCT book_auth FROM books LIMIT "+start+" , "+end );
          mysql.query( "SELECT DISTINCT book_auth FROM books LIMIT "+start+" , "+end );
 
          //mysql.next();
          while(mysql.next()) {
            if(book_auths.size()>max_stuff) {
              book_auths.remove(0);
              book_auths.add(mysql.getString("book_auth"));
            }
            else {
              book_auths.add(mysql.getString("book_auth"));
            }
          }
          start = end;
          end = end+max_stuff;
        } 
        else {
          //left page clicked
          if((start-max_stuff)<0) {
            println("-SELECT DISTINCT book_auth FROM books LIMIT "+(0)+" , "+(max_stuff));
            mysql.query( "SELECT DISTINCT book_auth FROM books LIMIT "+(0)+" , "+(max_stuff) );
            start=30;
            end=60;
          }
          else {
            println( "-aSELECT DISTINCT book_auth FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
            mysql.query( "SELECT DISTINCT book_auth FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
          }
          //mysql.next();
          while(mysql.next()) {
            if(book_auths.size()>max_stuff) {
              book_auths.remove(0);
              book_auths.add(mysql.getString("book_auth"));
            }
            else {
              book_auths.add(mysql.getString("book_auth"));
            }
          }
          end = start;
          start = start-max_stuff;
          c2_back = false;
        }
        //draw it
        for(int i = 0; i < book_auths.size(); i++) {
          mysql.query( "SELECT COUNT(`book_auth`) FROM `books` WHERE `book_auth` = '"+book_auths.get(i)+"'" );
          mysql.next();
          if(book_auths.size()>max_stuff) {
            book_auths_n.remove(0);
            book_auths_n.add((int)mysql.getInt(1));
          } 
          else {
            book_auths_n.add((int)mysql.getInt(1));
          }
        }
 
        graph.is_dead = true;
        graph = new graph(book_auths_n);
        graph_on = true;
        c2 = true;
      }
      break;
      ////////////////////////////////////////////////////////////////////////////////////
    case 3:
 
      //lang Echo
      if(c3 == false) {
        //right page clicked
        if(c3_back == false) {
          println( "+SELECT DISTINCT book_lang FROM books LIMIT "+start+" , "+end );
          mysql.query( "SELECT DISTINCT book_lang FROM books LIMIT "+start+" , "+end );
 
          //mysql.next();
          while(mysql.next()) {
            if(book_lang.size()>max_stuff) {
              book_lang.remove(0);
              book_lang.add(mysql.getString("book_lang"));
            }
            else {
              book_lang.add(mysql.getString("book_lang"));
            }
          }
          start = end;
          end = end+max_stuff;
        } 
        else {
          //left page clicked
          if((start-max_stuff)<0) {
            println("-SELECT DISTINCT book_lang FROM books LIMIT "+(0)+" , "+(max_stuff));
            mysql.query( "SELECT DISTINCT book_lang FROM books LIMIT "+(0)+" , "+(max_stuff) );
            start=30;
            end=60;
          }
          else {
            println( "-aSELECT DISTINCT book_lang FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
            mysql.query( "SELECT DISTINCT book_lang FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
          }
          //mysql.next();
          while(mysql.next()) {
            if(book_lang.size()>max_stuff) {
              book_lang.remove(0);
              book_lang.add(mysql.getString("book_lang"));
            }
            else {
              book_lang.add(mysql.getString("book_lang"));
            }
          }
          end = start;
          start = start-max_stuff;
          c3_back = false;
        }
        //draw it
        for(int i = 0; i < book_lang.size(); i++) {
          mysql.query( "SELECT COUNT(`book_lang`) FROM `books` WHERE `book_lang` = '"+book_lang.get(i)+"'" );
          mysql.next();
          if(book_lang.size()>max_stuff) {
            book_lang_n.remove(0);
            book_lang_n.add((int)mysql.getInt(1));
          } 
          else {
            book_lang_n.add((int)mysql.getInt(1));
          }
        }
 
        graph.is_dead = true;
        graph = new graph(book_lang_n);
        graph_on = true;
        c3 = true;
      }
      break;
      /////////////////////////////////////////////////////////////////////////////////
    case 4:
      //lang Date
      if(c4 == false) {
        //right page clicked
        if(c4_back == false) {
          println( "+SELECT DISTINCT book_contrib FROM books LIMIT "+start+" , "+end );
          mysql.query( "SELECT DISTINCT book_contrib FROM books LIMIT "+start+" , "+end );
 
          //mysql.next();
          while(mysql.next()) {
            if(book_contrib.size()>max_stuff) {
              book_contrib.remove(0);
              book_contrib.add(mysql.getString("book_contrib"));
            }
            else {
              book_contrib.add(mysql.getString("book_contrib"));
            }
          }
          start = end;
          end = end+max_stuff;
        } 
        else {
          //left page clicked
          if((start-max_stuff)<0) {
            println("-SELECT DISTINCT book_contrib FROM books LIMIT "+(0)+" , "+(max_stuff));
            mysql.query( "SELECT DISTINCT book_contrib FROM books LIMIT "+(0)+" , "+(max_stuff) );
            start=30;
            end=60;
          }
          else {
            println( "-aSELECT DISTINCT book_contrib FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
            mysql.query( "SELECT DISTINCT book_contrib FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
          }
          //mysql.next();
          while(mysql.next()) {
            if(book_contrib.size()>max_stuff) {
              book_contrib.remove(0);
              book_contrib.add(mysql.getString("book_contrib"));
            }
            else {
              book_lang.add(mysql.getString("book_contrib"));
            }
          }
          end = start;
          start = start-max_stuff;
          c4_back = false;
        }
        //draw it
        for(int i = 0; i < book_contrib.size(); i++) {
          mysql.query( "SELECT COUNT(`book_contrib`) FROM `books` WHERE `book_contrib` = '"+book_contrib.get(i)+"'" );
          mysql.next();
          if(book_contrib_n.size()>max_stuff) {
            book_contrib_n.remove(0);
            book_contrib_n.add((int)mysql.getInt(1));
          } 
          else {
            book_contrib_n.add((int)mysql.getInt(1));
          }
        }
 
        graph.is_dead = true;
        graph = new graph(book_contrib_n);
        graph_on = true;
        c4 = true;
      }
 
      break;
 
      /////////////////////////////////////////////////////////////////////////////////
    case 5:
      //date Data
      if(c5 == false) {
        //right page clicked
        if(c5_back == false) {
          println( "+SELECT DISTINCT book_created FROM books LIMIT "+start+" , "+end );
          mysql.query( "SELECT DISTINCT book_created FROM books LIMIT "+start+" , "+end );
 
          //mysql.next();
          while(mysql.next()) {
            if(book_date.size()>max_stuff) {
              book_date.remove(0);
              book_date.add(mysql.getString("book_created"));
            }
            else {
              book_date.add(mysql.getString("book_created"));
            }
          }
          start = end;
          end = end+max_stuff;
        } 
        else {
          //left page clicked
          if((start-max_stuff)<0) {
            println("-SELECT DISTINCT book_created FROM books LIMIT "+(0)+" , "+(max_stuff));
            mysql.query( "SELECT DISTINCT book_created FROM books LIMIT "+(0)+" , "+(max_stuff) );
            start=30;
            end=60;
          }
          else {
            println( "-aSELECT DISTINCT book_created FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
            mysql.query( "SELECT DISTINCT book_created FROM books LIMIT "+(start-max_stuff)+" , "+(end-max_stuff) );
          }
          //mysql.next();
          while(mysql.next()) {
            if(book_date.size()>max_stuff) {
              book_date.remove(0);
              book_date.add(mysql.getString("book_created"));
            }
            else {
              book_lang.add(mysql.getString("book_created"));
            }
          }
          end = start;
          start = start-max_stuff;
          c5_back = false;
        }
        //draw it
        for(int i = 0; i < book_date.size(); i++) {
          mysql.query( "SELECT COUNT(`book_created`) FROM `books` WHERE `book_created` = '"+book_date.get(i)+"'" );
          mysql.next();
          if(book_date.size()>max_stuff) {
            book_date_n.remove(0);
            book_date_n.add((int)mysql.getInt(1));
          } 
          else {
            book_date_n.add((int)mysql.getInt(1));
          }
        }
 
        graph.is_dead = true;
        graph = new graph(book_date_n);
        graph_on = true;
        c5 = true;
      }
 
      break;
    }
  }
 
  void render_data() {
 
    switch(book_layer) {
 
    case 0:
      break;
 
    case 1:
      textFont(base_text,14);
      text("Authors: "+book_stats.get(0),offset+book_x+margin,offset+14+margin);
      text("Languages: "+book_stats.get(1),offset+book_x+margin,offset+14+margin+20);
      text("Contributiors: "+book_stats.get(2),offset+book_x+margin,offset+14+margin+40);
      text("Dates Added: "+book_stats.get(3),offset+book_x+margin,offset+14+margin+60);
      textAlign(LEFT);
 
 
 
      break;
 
    case 2:
      break;
 
    case 3:
      break;
 
    case 4:
      break;
    }
  }
 
 
 
 
 
 
  void draw_pages(int p_left, int p_right) {
    //draw the pages on the ege of the book
 
    if(p_left <= 0) {
      p_left = 1;
    }
    if(p_left >= 10) {
      p_left = 10;
    }
    if(p_right <= 0) {
      p_right = 1;
    }
    if(p_right >= 10) {
      p_right = 10;
    }
 
    stroke(200);
    for(int i = p_left; i>0; i--) {
      int x = offset+4+i*2;
      line(x,offset,x,book_bottom_tip);
    }
 
    for(int i = p_right; i>0; i--) {
      int x = offset-4+book_x*2-i*2;
      line(x,offset,x,book_bottom_tip);
    }
  }
 
 
  void page_l() {
    page_l--;
    page_r++;
  }
 
  void page_r() {
    page_l++;
    page_r--;
  }
 
 
 
  int overItem() {
    if (mouseX >= offset+book_x*2 && mouseX <= width && 
      mouseY >= offset-13 && mouseY <= offset+book_y&&book_layer>1) {
 
      item =(int) (mouseY-offset)/11;
      println(mouseY+" "+item);
 
      if(item>0) {
 
        textFill(item);
      }
      return 0;
    } 
    else {
      item = -1;
      return -1;
    }
  }
 
  boolean overPage_1() 
  {
    if (mouseX >= offset && mouseX <= offset+book_x && 
      mouseY >= offset && mouseY <= offset+book_y) {
      return true;
    } 
    else {
      return false;
    }
  }
 
  boolean overPage_2() 
  {
    if (mouseX >= offset+book_x && mouseX <= offset+book_x*2 && 
      mouseY >= offset && mouseY <= offset+book_y) {
      return true;
    } 
    else {
      return false;
    }
  }
 
  boolean overAuth() {
 
    if (mouseX >= 375 && mouseX <= 430 && 
      mouseY >= 115 && mouseY <= 130) {
      return true;
    } 
    else {
      return false;
    }
  }
 
  boolean overLang() {
 
    if (mouseX >= 375 && mouseX <= 430 && 
      mouseY >= 140 && mouseY <= 155) {
      return true;
    } 
    else {
      return false;
    }
  }
 
  boolean overContrib() {
 
    if (mouseX >= 375 && mouseX <= 430 && 
      mouseY >= 160 && mouseY <= 175) {
      return true;
    } 
    else {
      return false;
    }
  }
 
  boolean overDate() {
 
    if (mouseX >= 375 && mouseX <= 430 && 
      mouseY >= 180 && mouseY <= 195) {
      return true;
    } 
    else {
      return false;
    }
  }
  boolean overIndex() {
 
    if (mouseX >= 240 && mouseX <= 360 && 
      mouseY >= 100 && mouseY <= 130) {
      return true;
    } 
    else {
      return false;
    }
  }
 
 
  void anim_open_book() {
    //animate the book opening
  }
}
class graph {
 
  int g_length, j,k,max_index;
  float x,y,vel;
  boolean is_new, is_dead, dead;
  ArrayList g_v = new ArrayList();
 
 
 
  graph(ArrayList g_vals) {
 
    x = 0;
    vel = .25;
    j=k=0;
    g_v = g_vals;
    //g_t = g_text;
    is_new = true;
    is_dead = dead = false;
 
    g_length = g_v.size();
 
    Integer max_int = 0;
    for(int i = 0; i<g_length; i++) {
      if((Integer) g_v.get(i) > (Integer) max_int) {
        max_int = (Integer) g_v.get(i);
      }
      max_index = g_v.indexOf(max_int);
    }
  }
 
  void update() {
    if(dead == true) {
    } 
    else {
      //x = x - vel;
      if(x<300) {
        is_dead = true;
      }
    }
  }
 
  void render(int high) {
    if(dead == true) {
    } 
    else {
 
      for(int i = 0; i < g_length; i++) {
        int h = (int) map((Integer) g_v.get(i),0,(Integer) g_v.get(max_index),0,300);
        fill(50);//(Integer) g_v.get(i)
        noStroke();
 
        //make graph text mouse over
        if(mouse_over_rect((int)x+15*(i+1)-12, height-h, 15, height)) {
          fill(200);
          rect(x+15*(i+1)-12, height-h, 15, h);
 
          textFont(base_text,15);
          text((Integer)g_v.get(i),mouseX+20,mouseY);
        } 
        else {
 
          rect(x+15*(i+1)-12, height-h, 15, h);
        }
      }
      //new
      if(is_new==true) {
        j++;
        fill(255,255-j);
        rect(0,0,width,height);
      }
      if(j>255) {
        is_new = false;
      }
      //dead
      if(is_dead==true) {
        k++;
        noStroke();
        fill(255,k);
        rect(0,0,width,height);
      }
      if(k>255) {
        dead = true;
        is_dead = false;
        is_new = true;
      }
    }
  }
  boolean mouse_over_rect(int x, int y, int w, int h) {
    if (mouseX >= x && mouseX <= x+w && 
      mouseY >= y && mouseY <= y+h) {
      return true;
    } 
    else {
      return false;
    }
  }
}

1 Comment

  1. Hi Jordan – thanks – could you please add some more screenshots of the project itself?

    Here are the comments from the PiratePad:

    ———————————–
    good job hacking the data parsing of it
    Wow, what a convoluted path for scraping your data. Cool.

    put it online, send an email to gutenberg

    cool project!

    Nice decision to use Project Gutenberg. An amazing resource to mine. So many questions to ask.
    Nice conceit to make “one book” out of Project Gutenberg. Analogous to thinking about Wikipedia as a single encyclopedia. You have a lovely sense of design, and this is a good first immersion.

    nice to see how you scoped project gutenberg for this project.

    Present the best aspects of your project, rather than saying what it is lacking before you even begin … and you’re right, the project guttenburg inteface does suck, and yours is the beginning of a really nice alternative.

    I was impressed by the cleanliness of the final output. Nice work parsing through the junky file.

    Nice idea/concept/execution.
    Is this live on the web right now? done :-)
    What do the columns mean?
    Good way to overcome the id problem.

    show us the applet sooner, rather then later
    ah a meta gutenberg book, nice … but where are the correlations and comparions beyond bargraphs?

    I like the concept: building your own catalog. some color would have been nice, but it would have been difficult to match the “book” style.

    Straightforward and works well. Maybe you can try using some color to differentiate the items in the bar graph.

    This is solid.

    Comment by Golan Levin — 4 February 2011 @ 3:14 pm

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2018 Interactive Art & Computational Design / Spring 2011 | powered by WordPress with Barecity