// From 2010 demo by Reza import processing.opengl.*; import javax.media.opengl.*; import peasy.org.apache.commons.math.*; import peasy.*; import peasy.org.apache.commons.math.geometry.*; PeasyCam cam; PImage orb; 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; PGraphicsOpenGL pgl; GL gl; 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); hint(ENABLE_DEPTH_SORT); smooth(); frameRate(30); //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"); orb = loadImage("orb.png"); 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, 1000); cam.setMinimumDistance(1); cam.setMaximumDistance(5000); } void draw() //draw loop that runs over and over until user quits { rotations = cam.getRotations(); background(0); pgl = (PGraphicsOpenGL) g; gl = pgl.gl; pgl.beginGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glEnable (GL.GL_LINE_SMOOTH); gl.glHint (GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST); gl.glDepthMask(false); gl.glDisable(GL.GL_DEPTH_TEST); gl.glEnable ( GL.GL_LINE_SMOOTH ); gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE); axis(); //drawGrid(); //drawPlot(); drawTitle(); drawAxisLabels(); drawXLabels(); drawYLabels(); drawZLabels(); drawData(); pgl.endGL(); counter = 0; //sets the counter to zero to start over again } void axis() { strokeWeight(2); stroke(255,100); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX2,PLOTY1,PLOTZ1); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX1,PLOTY2,PLOTZ1); 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; } colorMode(HSB); pushMatrix(); translate(i,k,value); rotateX(rotations[0]); rotateY(rotations[1]); rotateZ(rotations[2]); imageMode(CENTER); tint(map(counter,0,300,0,255),255,117); image(orb,0,0,value/10.0,value/10.0); tint(255); image(orb,0,0,value/20.0,value/20.0); stroke(255,100); textAlign(LEFT, CENTER); textFont(font2); String[] title = split(t.title, " "); text(title[0],15,0,0); popMatrix(); strokeWeight(value/100); stroke(map(counter,0,300,0,255),255,117,100); line(i,k,value,pt.x,pt.y,pt.z); pt.set(i,k,value); } counter = counter + 1; } } colorMode(RGB); }