nick /224 /data_vis

node[] points;
import processing.pdf.*;
String[] file_input;
float x,y,cx,cy,cx2,cy2,temperature,db;

PFont font;
PGraphics pdf;
boolean makePDF = false;

void setup(){
   /*make_pdf("01-16");
   make_pdf("01-17");
   make_pdf("01-18");
   make_pdf("01-19");
   make_pdf("01-20");
   make_pdf("01-21");
   make_pdf("01-22");
   make_pdf("02-02");
   make_pdf("02-03");
   make_pdf("02-04");
   make_pdf("02-05");
   make_pdf("02-06");
   make_pdf("02-07");
   make_pdf("02-08");
   make_pdf("02-09");
   make_pdf("02-10");
   make_pdf("02-11");
   make_pdf("02-12");
   make_pdf("02-13");
   make_pdf("02-14");
   make_pdf("02-15");
   make_pdf("02-16");
   make_pdf("02-17");
   make_pdf("02-18");
   make_pdf("02-19");
   make_pdf("02-20");
   make_pdf("02-21");
   make_pdf("02-22");
   make_pdf("02-23");
   make_pdf("02-24");
   make_pdf("02-25");
   make_pdf("02-26");
   make_pdf("02-27");
   make_pdf("02-28");
   make_pdf("03-01");
   make_pdf("03-02");
   make_pdf("03-03");*/
 make_pdf("03-04");
//make_pdf("03-05");
//make_pdf("03-06");

}

void draw(){
   image(pdf,0,0,width,height);

}

void make_pdf(String file){
  println(file);
  file_input = loadStrings(file + ".csv");
  points = new node[file_input.length];
  for(int i = 0; i < file_input.length; i++){
    String[] pieces = split(file_input[i], "\";\"");
    pieces[0] = pieces[0].substring(1,pieces[0].length());
    pieces[5] = pieces[5].substring(0,pieces[5].length() - 1);
    points[i] = new node(parseInt(pieces[0]), pieces[1], parseInt(pieces[2]),
                         parseInt(pieces[3]), parseFloat(pieces[4]),  parseFloat(pieces[5]));
  }
  size(1024,768);
  font = loadFont("HelveticaNeue-Light-12.vlw");
  if (makePDF == true){
    pdf = createGraphics(6000, 6000, PDF, "blah.pdf");
  } else {
    pdf = createGraphics(width,height, JAVA2D);
  }

  pdf.beginDraw();
  pdf.smooth();
  pdf.colorMode(HSB,360,100,100);
  //background(0);
  pdf.textFont(font,12);
  pdf.background(0,0,100);
  pdf.noFill();
  pdf.strokeWeight(.1);
  pdf.stroke(0,0,0,1);
  x = 0;
  y = 100;

  println(points.length);
  println(pdf.height/float(points.length));

  for(int i = 0; i < points.length; i++){
    temperature = map(points[i].temperature,18,22,50,100);
    db = points[i].db * 500;
    cx = x + map(points[i].light,0,500,0,pdf.width);
    cy = y - db/2;
    cx2 = x + map(points[i].light,0,500,0,pdf.width);
    cy2 = y + db/2;
    pdf.stroke(map(points[i].proximity,0,177,160,250),temperature,90,1);
    pdf.bezier(x,y,cx,cy,cx2,cy2,x,y);
    pdf.ellipse(x,y,1,1);
    y = y + (pdf.height-400)/float(points.length);
    //y++;

  }

  //nik's visualization
  /*for(int i = 0; i < points.length; i++){
    float x2 = cos(points[i].light) * float(points[i].light)/50.0 + x;
    float y2 = sin(points[i].light) * float(points[i].light)/50.0 + y;
    pdf.stroke(points[i].db * 100, 100,100);
    //pdf.strokeWeight(points[i].temperature/20);
    pdf.line(x,y,x2,y2);
    x = x2;
    y = y2;
  }*/

  pdf.save(file + ".png");
  pdf.dispose();
  pdf.endDraw();
}

class node{
  int index;
  String time;
  int light;
  int proximity;
  float db;
  float temperature;
  node(int i, String t, int l, int p, float d, float tp){
    index = i;
    time = t;
    light = l;
    proximity = p;
    db = d;
    temperature = tp;
  }
}

void keyPressed(){
  if (key == 's'){
    pdf.save("sketch" + ".png");
    println("saved");
  }
}  

Page Details
Contact DANM  |  Digital Arts and New Media  |  Arts Division  |  Grad Division
login