import java.applet.Applet;
import java.awt.*;

/* Demo PieControl for 1.0.2 Java */

public class PieDemo extends Applet
{

/* Colors for the segments */

    private Color [] colors = { Color.red, Color.green, Color.blue };

    private String [] color_names = { "Red", "Green", "Blue" };

/* Starting values for the segments */

    private float [] starts1 = { 30, 120, 210 };
    private float [] starts23 = { 30, 120, 210 };

    private TextArea textarea;
    private PieControl pie1, pie2, pie3;

/** To run as an application,
 * construct it and show it in a frame.
 * This must be a static (class not instance) method,
 * because the instance won't exist until we construct it here. */

  public static void main (String []argv) {

      Frame ff = new Frame ("PieDemo");
      ff.setBounds (100, 100, 600, 500);

      PieDemo cd = new PieDemo ();
      ff.add (cd);

      cd.init ();

      ff.pack ();
      ff.show ();

      cd.invalidate ();
      cd.validate ();
  }

    public PieDemo () {
	setForeground (Color.black);
	setBackground (Color.yellow);

        pie1 = new PieControl ();
	pie1.setPie (PieDial.ZERO_NORTH_DEG_CW, colors, starts1);
        add (pie1);

        add (pie2 = new PieControl (PieControl.ZERO_NORTH_DEG_CW, colors, starts23));
        add (pie3 = new PieControl (PieControl.ZERO_EAST_DEG_CCW, colors, starts23));

	pie1.setBackground (Color.black);
	pie3.setBackground (Color.gray);

/* Mark some value on the scale over the various ranges */

	pie2.setMark (Color.black, 45);

	pie1.setPieLabels (color_names);

        add (textarea = new TextArea (12,60));

	add (new Button ("Hello"));
	add (new Button ("World"));
    }

    public void init () {
	textarea.setText ("PieDemo\n");
    }

    public boolean action (Event evt, Object arg) {
	textarea.setText (textarea.getText ()+"\n"+evt);

	return true;
    }

}
