This was the processing code as I presented in class.

String lines[];
PFont font;
float posX;
float posY;
float r;
float g;
float b;
float a;

ArrayList bubbles;


/////////SETUP

void setup() {
 size(1000,700);
 font = loadFont("EngraversGothicBT-Regular-12.vlw");
 bubbles = new ArrayList();


 lines =loadStrings("http://itp.nyu.edu/~jtl239/icm/php/listyText.txt");
 println("there are " + ((lines.length)-1) + " participants on the list!");
 for (int i=0; i < lines.length; i++) {

   //  println((lines[i]));
   //  println(trim(lines[i]).split("}"));//keeping it here
   float posX = random(0,width);
   float posY = random(0,height);

   String[] name = split(lines[i], "==");
   String[] onlyName = split(name[0], "<");
   println(name);
   //print(", ");
   //println(onlyName[0]);
  r = random(255);
  g = random(255);
  b = random(255);
  a = random(255);

   bubbles.add(new Bubble(onlyName[0], int(name[1]), posX, posY,(i/150.0)));

 }
}

/////////MOUSEPRESSED

void mousePressed() {
 //Loop through the array list, from BACK to FRONT (last drawn to first drawn)
 //and find out if the mouse clicked inside a circle

 Bubble bubble;
 for (int i=0; i < bubbles.size(); i++) {
   bubble = (Bubble)bubbles.get(i);
   bubble.displayName = false;
 }

 for (int i = bubbles.size()-1; i >= 0; i--) {
   bubble = (Bubble)bubbles.get(i);
   if (bubble.testHit(mouseX, mouseY)) {
     //println ("Hit on bubble: " + bubble.name); //if you do "i"
instead of "bubble.name" you will get the # of the bubble...
     bubble.displayName = true;
     i = -1; //Breaks the loop so we don't keep looking for hits, we
already got the top most one.
   }
 }
}

/////////DRAW

void draw() {
 smooth();
 background(200,200,200,100);
 Bubble bubble;
 for (int i=0; i < bubbles.size(); i++) {
   bubble = (Bubble)bubbles.get(i);
   bubble.draw();
   bubble.display();
   bubble.move(); //Making it move
 }

 for (int i=0; i < bubbles.size(); i++) {
   bubble = (Bubble)bubbles.get(i);
   bubble.drawName();
   //bubble.drawNum();
 }
}





/////////CLASS

class Bubble{
 String name;
 int numEmails;
 float posX, posY;
 float xspeed;
// color c;
 boolean displayName = false;
 //boolean displayNum = false;

 Bubble(String theName, int theNumEmails, float thePosX, float
thePosY, float theXSpeed){
   name = theName;
   numEmails = theNumEmails;
   posX = thePosX;
   posY = thePosY;
   xspeed = theXSpeed;
//    c = c_;
 }


/////////MOVE
 void move() {
   posY = posY - xspeed;
   if (posY < -height) {
     posY = height;
   }


   if (mouseX > ((width/3)*2)) {
     posX = posX + (xspeed/4);
   }

   if (mouseX < (width/3)) {
     posX = posX - (xspeed/4);
   }

   else {
    posX = posX;
   }

   if (posX > width) {
     posX = 0;
   }
 }


/////////DISPLAY

 void display() {
    stroke(0,0,0,80);
    fill(255,255,255,150);
    ellipse(posX,posY, numEmails,numEmails);

 }

/////////DRAWNAME

 void drawName(){
  if (displayName){
    fill (4, 92, 113);
    textFont(font);
    text(name, posX, posY);

  }
 }

/////////TESTHIT

 boolean testHit(float mouseX, float mouseY){
  float d = dist(mouseX, mouseY, posX, posY);
  if (d <= (numEmails/2))
    return true;
  else
    return false;
 }

}

I ended up running the the code off a text file rather than the php code because it was just faster.
The link to the text is here: http://itp.nyu.edu/~jtl239/icm/php/listyText.txt
The php url is here: http://itp.nyu.edu/~jtl239/icm/php/listy.php

Alternate to the php link to see the most recent updates.

Here is the PHP code:

<?php
$imap = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX", "itplist.printer", "721broadway");
$message_count = imap_num_msg($imap);
$usercount = array();
for ($i = 1; $i <= $message_count; ++$i) {
  $header = imap_header($imap, $i);  
  if (empty($usercount[$header->fromaddress]))
  {
    $usercount[$header->fromaddress] = 1;
  }
  else
  {
    $usercount[$header->fromaddress]++;
  }
  //echo date("jS F Y", $header->udate) . "|" . $header->fromaddress . "|" . $header->subject . "\n";
}
foreach ($usercount as $key => $value)  
{  
  //print $key . "==" . $value . "\n";
  print $key;
}
imap_close($imap);

Edit: Going through my email for the past few weeks, I realize that I forgot to mention how much help I had gotten through the process.
It started with Shiffman’s code that fetched emailed through processing.
Next I spoke with Meredith, who suggested I speak directly to shiffman.
Shiffman helped orient me in a better direction and pointed me to Gabriela, who had a similar idea in mind.
Gabriela had the php chunk of the code done and fed back into processing.
With some help from Avery, Liesje, and Craig the php was filtered to yield only what was needed.
Zeven gave me a much needed review and beginnings to the processing side of the code.
Che-wei advised with the visualizing, and Craig gave some more last minute technical guidance.
Ginny and Kimi also had sample code that I learned a lot from.

Had anyone been missing in this chain of help, I wouldn’t have completed the code to where it is now. I’m grateful for all the willing help there is at ITP. <3

Earlier in the semester I became overwhelmed with “the list.” It was like a never ending battle that I would never ever win. I thought of ways to make a consolation prize to myself, and thought about making a tree that would visualize the emails in an aesthetic way so the more emails there were, the more complete the tree would be.

Then towards the end of the semester, I decided the idea could be a reality. I had a bit of a struggle starting up the code. I had found code that would check email in processing, but ran into the problem of checking through the inbox every single time I ran the processing sketch, which would take a while. After contacting Dan Shiffman for help, he pointed me to Gabriela G. who also happened to be working on the same idea and had made more headway with code.

The code changed from strictly processing, to include php, a new email account used purely used to check the list, and a loadString code that would check the php code and run it in processing.

The next step of the process is getting the emails to be represented visually. At first, we wanted to try working with an algorithmic tree, but due to the time constraints and the fact that a tree insinuates the structure would be hierarchical, we dropped the idea. Instead, we’re now considering going with a garden idea where each student or each email topic could be a flower. In the case of the garden, it would probably be an email title rather than a person.

I would still like for the data to be visualized by person, because we can easily watch email topics cluster up, but we this would give us an idea of who writes the most. I am still thinking of alternate visuals, but for now, the garden idea works. I’ve tried running our data with another student’s visualization code, and it can be a little overwhelming for processing, so we do need to keep it simple.

Ultimately, we would like to be able to display this information on a screen where it could ideally run real time. We would like for the flowers/visual to be mouse-over-able for either a name or email topic, and as the responses increase the flower changes.

Further thoughts I was toying with was hiding ‘easter eggs’ in the code, so when specific people write to the list,  a rainbow will be added to the background, or the birds will fly across the screen, etc.

General idea:

Php link: http://itp.nyu.edu/~gg964/getheader.php

(Stores email data since Nov 8th)

PHP:

<?php

$connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$mbox = imap_open($connect_to, "itplist.printer", "721broadway");

$headers = imap_headers($mbox);

if ($headers == false) {
   echo "Call failed<br />\n";
} else {
   foreach ($headers as $val) {
       echo $val . "\n";
   }
}

imap_close($mbox);
?>

Processing:

String lines[] = loadStrings("http://itp.nyu.edu/~gg964/getheader.php");

println("there are " + lines.length + " messages on the list!");

for (int i=0; i &lt; lines.length; i++) {

println(lines[i]);

}

http://itp.nyu.edu/~jtl239/icm/week5/index.html

Oct 182010

Week 4 Assignment

If files are missing it’s because it may take some time for me to repost old entries…

if I can even remember them all.

happy day made in processing

© 2012 ITPeed Suffusion theme by Sayontan Sinha