import java.applet.Applet;

import java.awt.*;
import java.awt.event.*;

public class PieDemo extends Applet
implements ActionListener
{

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

    private Color [] colors = { Color.red, Color.green, Color.blue };
    private float [] starts1 = { 30, 120, 210 };
    private float [] starts23 = { 30, 120, 210 };

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

/** 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 () {

/* Construct a few pies */

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

/* Listen on them */

	pie1.addActionListener (this);
	pie2.addActionListener (this);
	pie3.addActionListener (this);

/* Set segment labels for popups */

	pie1.setPieLabels (color_names);

	pie2.setPieLabels (color_names);

	pie3.setPieLabels (color_names);

/* Color some of the backgrounds and leave one defaulted */

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

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

	pie2.setMark (Color.white, 45);

/* Will report events here */

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

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

    public void actionPerformed (ActionEvent evt) {
	textarea.append ("\n"+evt);
    }

}
/* <IMG SRC="/cgi-bin/counter">*/
