// --------------------------------------------------- // University of California Santa Barbara // Media Arts and Technology // MAT 259 | Visualizing Information | Winter 2011 // // Patrick Rudolph // Project 3 | Animation // // Level 2 data structures // --------------------------------------------------- class Level2 extends Circle { int num; // first number of dewey class int[] recent = new int[dayMax+5]; // data for the last period(default:30) days = trend public Level2(Level1 parent,String name,int num,float x,float y,float radius) { super(parent,name,x,y,radius); this.num = num; } void add(int d, int num) { recent[d]+=num; if(d > period) { sum -= recent[d-period]; recent[d-period] = 0; } sum+=num; // create particle if(num > 0 && effects[1]) { float mX = parent.x+x; // center X float mY = parent.y+y; // center Y checkouts.add(new Checkout( (mX + sin(TWO_PI*random(0.1,1)) * random(0,radius*0.8/2) ) , (mY + cos(TWO_PI*random(0.1,1)) * random(0,radius*0.8/2) ) , 0 )); } } void draw() { pushMatrix(); translate(parent.x,parent.y); // data if(parent.deweySum != 0) this.share = sum / parent.deweySum; else this.share = 0; this.radius = 15+share*30+parent.share*15; // resize this.distance = parent.radius*1.2/2+radius; this.x = initX*distance; this.y = initY*distance; // draw if( parent.mouseInside() || mouseInside() ) super.draw(); popMatrix(); } void drawLine() { stroke(cCircle3); strokeWeight(5); line(0,0,x,y); } void drawCircles() { noStroke(); super.drawCircles(); // creamy yellow circle fill(cBg); ellipse(x,y,radius,radius); } }