Last Updated: 3/4/97
Class NFPiechart

Class NFPiechart

public class NFPiechart extends NFGraph

The NFPiechart object provides functionality for a piechart by extending the NFGraph object.

See NFPiechartApp for the HTML parameters supported.

Constructors

Methods


NFPiechart (Applet app)
Create a NFPiechart object associated with the given app.

NFPiechart (Applet app,
            int x,
            int y,
            int w,
            int h)
Create a NFPiechart object associated with the given app.

void addSlice (String name,
               double value,
               Color color)
Define a new slice for the pie. The name is used to modify slice attributes and should be unique for all slices.

void addSlice (String name,
               double value,
               Color color,
               NFActiveLabel activeLabel)
Define a new slice for the pie. The name is used to modify slice attributes and should be unique for all slices.

Polygon createPolygon(Graphics g,
                      int x,
                      int y,
                      int width,
                      int height,
                      double start,
                      double arc)
create polygon which approximates the arc described by the input parametsr.

protected void defineParams ()
This method extends the NFGraph.defineParams() method to define the following piechart parameters:
 	LabelPos
 	Slices
This method may be overridden by sub-classes to define additional parameters. In such cases, this method should be called first.

void deleteAllSlices ()
Delete all slices.

void deleteSlice (String name)
Delete the named slice.

protected void drawGraph (Graphics offg,
                          Rectangle rect)
This method overrides the NFGraph.drawGraph() method to display the piechart in the given rectangle of the given graphics context. Automatically called by the NFGraph object.
This method may be overridden or called by a sub-class to draw piecharts with different display formats.

protected synchronized void loadParams () throws Exception
This method extends the NFGraph.loadParams() method to load the parameters defined in the defineParams method.
This method may be overridden by sub-classes to load additional parameters. In such cases, this method should be called first.

synchronized boolean mouseDown (Event evt,
                                int x,
                                int y)
This method should be used to service a mouseDown event within the piechart.

synchronized boolean mouseDrag (Event evt,
                                int x,
                                int y)
This method should be used to service a mouseDrag event within the piechart.

synchronized boolean mouseUp (Event evt,
                              int x,
                              int y)
This method should be used to service a mouseUp event within the piechart.

void setLabelPos (double ratio)
Sets the label position for each slice, relative to the width of the pie. A value of 1.1 sets the label just outside the pie, while a value of 0.6 sets each label inside each slice.

void setSliceLabel (String name,
                    NFLabel label)
Define a label for the named slice.