import java.awt.*;

public class displayApplet extends java.applet.Applet {

	protected ChartDisplay theDisplay;

	protected int maxCategories=5;
	protected int catCount = 0;
	protected String categories[] = new String[maxCategories];
	protected int amount[] = new int[maxCategories];

	public void init(){
	    String att = getParameter("categories");
	    int i = 0;
	    while (att.length()>0){
      		 if (att.indexOf(' ') > 0){
		          categories[i] = att.substring(0, att.indexOf(' '));
		          att = att.substring(att.indexOf(' '));
		          att = att.trim();
		     }else{
				  categories[i] = att;
				  att = "";
		     }
		     i++;
		   }
		catCount = i;
		for (i=0;i<catCount;i++){
	      amount[i] = Integer.parseInt(getParameter(categories[i]));
		}
		att = getParameter("display");
		if ("pie".equals(att))
		      theDisplay = new PieDisplay();
		else if ("bar".equals(att))
		           theDisplay = new BarDisplay();
		     else
		           theDisplay = new PieDisplay();
    }

   public void paint(Graphics g){
	    theDisplay.display(g, categories, amount, catCount,getSize());
    }
}