This was the processing code as I presented in class.
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:
$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


