import java.awt.*;

public class PieDisplay implements ChartDisplay{

    protected Color fillColor[] = {Color.green, Color.red, Color.blue, Color.black, Color.yellow};
	protected int total = 0;

	public void display(Graphics g, String[] categories, int[] amount, int catCount, Dimension d) {
		int angle=0;
		for (int i=0;i<catCount;i++){
			  total += amount[i];
		}
	    for (int i=0;i<catCount;i++){
			g.setColor(Color.black);
		    g.drawString(categories[i],20, (i+1)*20 + 350);
		    g.setColor(fillColor[i]);
			g.fillRect(100, (i+1)*20 + 340,10,10);
		    double temp = amount[i];
		    temp = temp/(double)total;
			g.fillArc(30,30,250,250, angle, (int)(temp *360));
			angle = angle + (int)(temp * 360);
	    }
    }
}