// from 2010 by Reza import processing.opengl.*; import peasy.org.apache.commons.math.*; import peasy.*; import peasy.org.apache.commons.math.geometry.*; PeasyCam cam; ArrayList transactions = null; //create a container for transactions from the data int squareSize = 5; //sets the size of the squares being drawn int counter = 0; int counter2 = 0; //counter to keep track of the transactions being used. float value = 0; float[] rotations = new float[3]; int gridInterval = 50; int PLOTX1, PLOTX2; int PLOTY1, PLOTY2; int PLOTZ1, PLOTZ2; int DATAMIN, DATAMAX; int DATAMINZ, DATAMAXZ; int XMIN, XMAX; int XINTERVAL; int YINTERVAL; int ZINTERVAL; PFont font; PFont font2; void setup() { ///Set up Canvas size(1000,700,OPENGL); //setup a 500 by 500 Pixel Space to work with 280 transactions...for you want to show more make sure you have enough transactions in your splxmldata.txt file. hint(DISABLE_OPENGL_2X_SMOOTH); hint(ENABLE_OPENGL_4X_SMOOTH); smooth(); frameRate(1000); //set the frameRate of the Visualization this.transactions = loadTransactions(); //load the transactions from the splxmldata.txt file font = loadFont("Helvetica-18.vlw"); font2 = loadFont("Helvetica-24.vlw"); PLOTX1 = -1000; PLOTX2 = 1000; PLOTY1 = -750; PLOTY2 = 750; PLOTZ1 = 0; PLOTZ2 = 1000; DATAMIN = 0; DATAMAX = 500; DATAMINZ = 0; DATAMAXZ = 250; XMIN = 0; XMAX = PLOTX2; XINTERVAL = 100; YINTERVAL = 100; ZINTERVAL = 100; cam = new PeasyCam(this,(PLOTX1+PLOTX2)*.5,(PLOTY1+PLOTY2)*.5,(PLOTZ1+PLOTZ2)*.5, 2500); cam.setMinimumDistance(1); cam.setMaximumDistance(5000); // cam.rotateX(-HALF_PI/4.0); // rotate around the x-axis passing through the subject // cam.rotateY(HALF_PI/2.0); // rotate around the y-axis passing through the subject // cam.rotateZ(HALF_PI/2.0); // rotate around the z-axis passing through the subject } void draw() //draw loop that runs over and over until user quits { rotations = cam.getRotations(); // background(31,126,255); //sets the background color to white = 255; background(120); axis(); drawGrid(); // drawPlot(); drawTitle(); drawAxisLabels(); drawXLabels(); drawYLabels(); drawZLabels(); drawData(); counter = counter2; //sets the counter to zero to start over again if(frameCount%60 == 0) { counter2++; } } void axis() { strokeWeight(2); stroke(255,255,255); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX2,PLOTY1,PLOTZ1); stroke(255,255,255); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX1,PLOTY2,PLOTZ1); stroke(255,255,255); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX1,PLOTY1,PLOTZ2); } void drawData() { PVector pt = new PVector(PLOTX1,PLOTY1,700); Transaction t; //create a transaction object stroke(255); for(int i = PLOTX1; i < PLOTX2; i = i + XINTERVAL) //nested for loops to create a grid of squares. { for(int k = PLOTY1; k < PLOTY2; k = k + YINTERVAL) { t = (Transaction) transactions.get(counter); if(t.deweyClass.length() > 0) { String number = t.deweyClass.substring(0,3); try { value = (float)Integer.parseInt(number); } catch (Exception e) { value = 0; } noFill(); stroke(value); strokeWeight(value/50); point(i,k,value); stroke(0,200); strokeWeight((value/50)*.75); point(i,k,value); stroke(255,50); line(i,k,value,pt.x,pt.y,pt.z); pt.set(i,k,value); pushMatrix(); translate(i,k,value); rotateX(rotations[0]); rotateY(rotations[1]); rotateZ(rotations[2]); stroke(255,200); textAlign(LEFT, CENTER); textFont(font2); text(t.title,15,0,0); popMatrix(); } counter = counter + 1; } } }