package uk.ac.leeds.ccg.widgets; import java.awt.*; import java.util.*; import uk.ac.leeds.ccg.geotools.*; /** a simple class to do basic pie charts (as percentages) * a fairly simple extension to bar charts - I hope! * @author Ian Turton (ian@geog.leeds.ac.uk) * * TO DO * break group out as seperate class * add labels to larger(?) groups * try drawing lines from centre to arcs to hide rounding error! */ public class PieChart extends BarGraph{ double total=0.0; // we need to know how many there are public void paint(Graphics g){ // x,y,w,h describe the whole chart and we don't need to change them! int height = getBounds().height; int width = getBounds().width; int l = Math.min(height,width)-1; // well it'll look nicer as a circle! if(id<=0)return; // not in polygon? int count = groups.size(); total=0.0; for(int i=0;imaxValue){maxValue = value;} } this.repaint(); } public void addGroup(GeoData data,Color color){ Group g = new Group(data,color); groups.addElement(g); } class Group{ public Group(GeoData d,Color c){ data = d; color = c; } public GeoData data; public Color color; } }