// --------------------------------------------------- // University of California Santa Barbara // Media Arts and Technology // MAT 259 | Visualizing Information | Winter 2011 // // Patrick Rudolph // Project 3 | Animation // // Circle data structures // --------------------------------------------------- class Circle { Level1 parent; String name; float x,initX,y,initY; float radius,distance; float sum,share; boolean lineOn; public Circle(Level1 parent,String name,float x,float y,float radius) { this.parent = parent; this.name = name; this.radius = radius; this.initX = x; this.initY = y; x = x; y = y; distance = 0; sum = 0; share = 0; } public void draw() { if( mouseInside() ) { drawLine(); info = this; } if(lineOn) cBar = cCircle2; else cBar = cCircle3; drawCircles(); drawImg(); drawTitle(); } void drawLine() {} ; void drawImg() {} ; void drawCircles() { fill(cCircle3); ellipse(x,y,radius*1.05+2,radius*1.05+2); // creamy yellow circle } void drawTitle() { // variable text size if(radius >= 210) textFont(fTitleHuge); else if(radius >= 150) textFont(fTitleBig); else if(radius >= 110) textFont(fTitle); else if(radius >= 80) textFont(fTitleSmall); else textFont(fTitleTiny); if(textWidth(name)+3 < radius) { textAlign(CENTER,CENTER); noStroke(); fill(cTitleBorder,220); textBorder(name,x,y); fill(cTitle); text(name,x,y); } } boolean mouseInside() { if(parent == null) { return (mouseX-centerX > x-radius*1.1/2 && mouseX-centerX < x+radius*1.1/2 && mouseY-centerY > y-radius*1.1/2 && mouseY-centerY < y+radius*1.1/2); } return (mouseX-centerX-parent.x > x-radius*1.1/2 && mouseX-centerX-parent.x < x+radius*1.1/2 && mouseY-centerY-parent.y > y-radius*1.1/2 && mouseY-centerY-parent.y < y+radius*1.1/2); } }