import java.awt.Color; import processing.core.PApplet; /* * Pehr Hovey * pehr.hovey@gmail.com * MAT259 Data Visualization * Winter 2009 * * BalancePivot.java * * This is an object that goes below the pivot point and may also display data */ public class BalancePivot { double mass; long count; //this is the number that this object represents. Will cause mass and size to change proportionally float size; //size of object to render float x1,y1; //coordinates of 'corners' on the ground if this is a float x2,y2; float midx,midy; //plot two separate triangles meeting at a midpoint double mid_pct; //what percentage of the base of the triange is the midpoint at (relative to left corner) float apex_x,apex_y; //center point float pivot_point_size = 15; float base_width; //Assuming this is a triangle BalancePivot( float _x1 , float _y1, float _apex_x, float _apex_y, float _x2, float _y2){ count = 100; //default x1=_x1; y1=_y1; x2=_x2; y2=_y2; apex_y = _apex_y; apex_x = _apex_x; midx = x1; midy = y1; } public void update(float _x1, float _y1, float _x2, float _y2){ x1=_x1; y1=_y1; x2=_x2; y2=_y2; } public void setWidth(float width){ x1 = apex_x - (width/2); x2 = apex_x + (width/2); } public void setMidPercent(double pct){ mid_pct = pct; midx = (float) (x1+pct*(x2-x1)); midy= (float) (y1+pct*(y2-y1)); } }