org.jfree.chart.plot
Class PiePlot

java.lang.Object
  extended byorg.jfree.chart.plot.Plot
      extended byorg.jfree.chart.plot.PiePlot
All Implemented Interfaces:
AxisChangeListener, AxisConstants, java.lang.Cloneable, DatasetChangeListener, java.util.EventListener, java.io.Serializable
Direct Known Subclasses:
Pie3DPlot

public class PiePlot
extends Plot
implements java.lang.Cloneable, java.io.Serializable

A plot that displays data in the form of a pie chart, using data from any class that implements the PieDataset interface.

Special notes:

  1. the default starting point is 12 o'clock and the pie sections proceed in a clockwise direction, but these settings can be changed
  2. negative values in the dataset are ignored
  3. there are utility methods for creating a PieDataset from a CategoryDataset

Author:
Andrzej Porebski
See Also:
Plot, PieDataset, Serialized Form

Field Summary
static int ANTICLOCKWISE
          A constant representing the anti-clockwise direction.
static int CLOCKWISE
          A constant indicating the clockwise direction.
static int DEFAULT_DIRECTION
          The default direction for the pie chart.
static double DEFAULT_INTERIOR_GAP
          The default interior gap.
static double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW
          The default minimum arc angle to draw.
static java.text.NumberFormat DEFAULT_PERCENT_FORMATTER
          The default percent label formatter.
static double DEFAULT_RADIUS
          The default radius percent (currently 100%).
static java.awt.Font DEFAULT_SECTION_LABEL_FONT
          The default section label font.
static double DEFAULT_SECTION_LABEL_GAP
          The default section label gap (currently 10%).
static java.awt.Paint DEFAULT_SECTION_LABEL_PAINT
          The default section label paint.
static int DEFAULT_SECTION_LABEL_TYPE
          The default section label type.
static java.awt.Font DEFAULT_SERIES_LABEL_FONT
          The default series label font.
static java.awt.Paint DEFAULT_SERIES_LABEL_PAINT
          The default series label paint.
static boolean DEFAULT_SHOW_SERIES_LABELS
          The default for the show series labels flag
static double DEFAULT_START_ANGLE
          The default starting angle for the pie chart.
static java.text.NumberFormat DEFAULT_VALUE_FORMATTER
          The default value label formatter.
protected static java.util.ResourceBundle localizationResources
          The resourceBundle for the localization.
static double MAX_INTERIOR_GAP
          The maximum interior gap (currently 40%).
static double MAX_RADIUS
          The maximum radius (currently 100%).
static double MAX_SECTION_LABEL_GAP
          The maximum interior gap (currently 30%).
static int NAME_AND_PERCENT_LABELS
          Constant indicating percent labels on the pie sections.
static int NAME_AND_VALUE_LABELS
          Constant indicating percent labels on the pie sections.
static int NAME_LABELS
          Constant indicating name labels on the pie sections.
static int NO_LABELS
          Constant indicating no labels on the pie sections.
static int PER_COLUMN
          A useful constant for multiple pie charts.
static int PER_ROW
          A useful constant for multiple pie charts.
static int PERCENT_LABELS
          Constant indicating percent labels on the pie sections.
static int VALUE_AND_PERCENT_LABELS
          Constant indicating percent labels on the pie sections.
static int VALUE_LABELS
          Constant indicating value labels on the pie sections.
 
Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO
 
Fields inherited from interface org.jfree.chart.axis.AxisConstants
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_AXIS_LINE_PAINT, DEFAULT_AXIS_LINE_STROKE, DEFAULT_AXIS_VISIBLE, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE, DEFAULT_TICK_MARKS_VISIBLE
 
Constructor Summary
PiePlot()
          Creates a new plot.
PiePlot(CategoryDataset dataset, int type)
          Creates a new plot that will draw multiple pie charts, one for each row or column (as requested) in the dataset.
PiePlot(PieDataset dataset)
          Creates a pie chart.
 
Method Summary
protected  java.awt.geom.Point2D calculateLabelLocation(java.awt.geom.Rectangle2D labelBounds, double ascent, java.awt.geom.Rectangle2D unexploded, java.awt.geom.Rectangle2D exploded, double startAngle, double extent, double explodePercent)
          Returns the location for a label, taking into account whether or not the pie section is exploded.
 java.lang.Object clone()
          Returns a clone of the plot.
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info)
          Draws the plot on a Java 2D graphics device (such as the screen or a printer).
protected  void drawLabel(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D pieArea, java.awt.geom.Rectangle2D explodedPieArea, PieDataset data, double value, int section, double startAngle, double extent)
          Draws the label for one pie section.
protected  void drawMultiplePies(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PlotRenderingInfo info)
          Draws a plot containing multiple pies.
protected  void drawPie(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PlotRenderingInfo info, int pieIndex, PieDataset data, java.lang.String label)
          Draws the pie.
 boolean equals(java.lang.Object obj)
          Tests this plot for equality with another object.
protected  java.awt.geom.Rectangle2D getArcBounds(java.awt.geom.Rectangle2D unexploded, java.awt.geom.Rectangle2D exploded, double startAngle, double extent, double explodePercent)
          Returns a rectangle that can be used to create a pie section (taking into account the amount by which the pie section is 'exploded').
 PieDataset getDataset()
          Returns the dataset.
 java.awt.Paint getDefaultOutlinePaint()
          Deprecated. Use getSectionOutlinePaint.
 java.awt.Stroke getDefaultOutlineStroke()
          Deprecated. Use getSectionOutlineStroke.
 java.awt.Paint getDefaultPaint()
          Deprecated. Use getSectionPaint().
 org.jfree.util.Rotation getDirection()
          Returns the direction in which the pie sections are drawn (clockwise or anti-clockwise).
 double getExplodePercent(int section)
          Returns the amount that a section should be 'exploded'.
 int getExtractType()
          Returns the data extraction type if this plot uses a category plot.
 double getInteriorGap()
          Returns the interior gap, measured as a percentage of the available drawing space.
 PieItemLabelGenerator getItemLabelGenerator()
          Returns the label generator.
 java.util.Collection getKeys()
          Returns a collection of the section keys (or categories) in the dataset.
 LegendItemCollection getLegendItems()
          Returns a collection of legend items for the pie chart.
 double getMinimumArcAngleToDraw()
          Returns the minimum arc angle that will be drawn.
 CategoryDataset getMultiDataset()
          Returns the dataset for multiple pies.
 java.awt.Paint getOutlinePaint(int section)
          Deprecated. Use getSectionOutlinePaint.
 java.awt.Stroke getOutlineStroke(int section)
          Deprecated. Use getSectionOutlineStroke.
 java.awt.Paint getPaint(int section)
          Deprecated. Use getSectionPaint(int).
 PieDataset getPieDataset()
          Returns the dataset for the plot, cast as a PieDataset.
 java.lang.String getPlotType()
          Returns a short string describing the type of plot.
 double getRadius()
          Returns the radius (a percentage of the available space).
 java.awt.Font getSectionLabelFont()
          Returns the section label font.
 double getSectionLabelGap()
          Returns the section label gap, measured as a percentage of the radius.
 java.awt.Paint getSectionLabelPaint()
          Returns the section label paint.
 int getSectionLabelType()
          Returns the section label type.
 java.awt.Paint getSectionOutlinePaint()
          Returns the outline paint for ALL sections in the plot.
 java.awt.Paint getSectionOutlinePaint(int section)
          Returns the paint used to outline a section of the pie plot.
 boolean getSectionOutlinePaintListAutoFill()
          Returns a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.
 java.awt.Stroke getSectionOutlineStroke()
          Returns the outline stroke for ALL sections in the plot.
 java.awt.Stroke getSectionOutlineStroke(int section)
          Returns the stroke used to outline a section of the pie plot.
 boolean getSectionOutlineStrokeListAutoFill()
          Returns a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.
 java.awt.Paint getSectionPaint()
          Returns the paint for ALL sections in the plot.
 java.awt.Paint getSectionPaint(int section)
          Returns the paint used to fill a section of the pie plot.
 boolean getSectionPaintListAutoFill()
          Returns a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.
 java.awt.Font getSeriesLabelFont()
          Returns the series label font.
 java.awt.Paint getSeriesLabelPaint()
          Returns the series label paint.
 boolean getShowSeriesLabels()
          Returns the show series labels flag.
 double getStartAngle()
          Returns the start angle for the first pie section.
 PieItemLabelGenerator getToolTipGenerator()
          Deprecated. Use getItemLabelGenerator().
 PieURLGenerator getURLGenerator()
          Returns the URL generator (possibly null).
 boolean isCircular()
          Returns a flag indicating whether the pie chart is circular, or stretched into an elliptical shape.
 void setCircular(boolean flag)
          A flag indicating whether the pie chart is circular, or stretched into an elliptical shape.
protected  void setCircularAttribute(boolean circular)
          Sets the circular attribute, with no side effects.
 void setDataset(PieDataset dataset)
          Sets the dataset.
 void setDefaultOutlinePaint(java.awt.Paint paint)
          Deprecated. Use setSectionOutlinePaint(paint).
 void setDefaultOutlineStroke(java.awt.Stroke stroke)
          Deprecated. Use setSectionOutlineStroke.
 void setDefaultPaint(java.awt.Paint paint)
          Deprecated. Use setSectionPaint(Paint).
 void setDirection(org.jfree.util.Rotation direction)
          Sets the direction (use the constants CLOCKWISE or ANTICLOCKWISE).
 void setExplodePercent(int section, double percent)
          Sets the amount that a pie section should be exploded.
 void setExtractType(int extractType)
          Defines the data extraction type if this plot uses a category plot.
 void setInteriorGap(double percent)
          Sets the interior gap.
 void setItemLabelGenerator(PieItemLabelGenerator generator)
          Sets the label generator (used for generating tool-tips).
 void setMinimumArcAngleToDraw(double angle)
          Sets the minimum arc angle that will be drawn.
 void setMultiDataset(CategoryDataset dataset)
          Sets the dataset for multiplie pies.
 void setOutlinePaint(int section, java.awt.Paint paint)
          Deprecated. Use setSectionOutlinePaint.
 void setOutlineStroke(int section, java.awt.Stroke stroke)
          Deprecated. Use setSectionOutlineStroke.
 void setPaint(int section, java.awt.Paint paint)
          Deprecated. Use setSectionPaint(int, Paint).
 void setPercentFormat(java.text.NumberFormat format)
          Sets the format for the value labels.
 void setPercentFormatString(java.lang.String format)
          Sets the format string for the percent labels.
 void setRadius(double percent)
          Sets the radius.
 void setSectionLabelFont(java.awt.Font font)
          Sets the section label font.
 void setSectionLabelGap(double percent)
          Sets the section label gap percent.
 void setSectionLabelPaint(java.awt.Paint paint)
          Sets the section label paint.
 void setSectionLabelType(int type)
          Sets the section label type.
 void setSectionOutlinePaint(int section, java.awt.Paint paint)
          Sets the paint used to outline a section of the pie.
 void setSectionOutlinePaint(java.awt.Paint paint)
          Sets the outline paint for ALL sections in the plot.
 void setSectionOutlinePaintListAutoFill(boolean fill)
          Sets a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.
 void setSectionOutlineStroke(int section, java.awt.Stroke stroke)
          Sets the stroke used to outline a section of the pie.
 void setSectionOutlineStroke(java.awt.Stroke stroke)
          Sets the outline stroke for ALL sections in the plot.
 void setSectionOutlineStrokeListAutoFill(boolean fill)
          Sets a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.
 void setSectionPaint(int section, java.awt.Paint paint)
          Sets the paint used to fill a section of the pie.
 void setSectionPaint(java.awt.Paint paint)
          Sets the paint for ALL sections in the plot.
 void setSectionPaintListAutoFill(boolean fill)
          Sets a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.
 void setSeriesLabelFont(java.awt.Font font)
          Sets the series label font.
 void setSeriesLabelPaint(java.awt.Paint paint)
          Sets the series label paint.
 void setShowSeriesLabels(boolean flag)
          Sets the show series labels flag.
 void setStartAngle(double angle)
          Sets the starting angle.
 void setToolTipGenerator(PieItemLabelGenerator generator)
          Deprecated. Use setItemLabelGenerator.
 void setURLGenerator(PieURLGenerator generator)
          Sets the URL generator.
 void setValueFormat(java.text.NumberFormat format)
          Sets the format for the value labels.
 void setValueFormatString(java.lang.String format)
          Sets the format string for the value labels.
 void zoom(double percent)
          A zoom method that does nothing.
 
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, datasetChanged, draw, drawBackground, drawNoDataMessage, drawOutline, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundPaint, getDataAreaRatio, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, isSubplot, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundPaint, setDataAreaRatio, setDatasetGroup, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setParent
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLOCKWISE

public static final int CLOCKWISE
A constant indicating the clockwise direction.

See Also:
Constant Field Values

ANTICLOCKWISE

public static final int ANTICLOCKWISE
A constant representing the anti-clockwise direction.

See Also:
Constant Field Values

NO_LABELS

public static final int NO_LABELS
Constant indicating no labels on the pie sections.

See Also:
Constant Field Values

NAME_LABELS

public static final int NAME_LABELS
Constant indicating name labels on the pie sections.

See Also:
Constant Field Values

VALUE_LABELS

public static final int VALUE_LABELS
Constant indicating value labels on the pie sections.

See Also:
Constant Field Values

PERCENT_LABELS

public static final int PERCENT_LABELS
Constant indicating percent labels on the pie sections.

See Also:
Constant Field Values

NAME_AND_VALUE_LABELS

public static final int NAME_AND_VALUE_LABELS
Constant indicating percent labels on the pie sections.

See Also:
Constant Field Values

NAME_AND_PERCENT_LABELS

public static final int NAME_AND_PERCENT_LABELS
Constant indicating percent labels on the pie sections.

See Also:
Constant Field Values

VALUE_AND_PERCENT_LABELS

public static final int VALUE_AND_PERCENT_LABELS
Constant indicating percent labels on the pie sections.

See Also:
Constant Field Values

PER_ROW

public static final int PER_ROW
A useful constant for multiple pie charts.

See Also:
Constant Field Values

PER_COLUMN

public static final int PER_COLUMN
A useful constant for multiple pie charts.

See Also:
Constant Field Values

DEFAULT_INTERIOR_GAP

public static final double DEFAULT_INTERIOR_GAP
The default interior gap.

See Also:
Constant Field Values

MAX_INTERIOR_GAP

public static final double MAX_INTERIOR_GAP
The maximum interior gap (currently 40%).

See Also:
Constant Field Values

DEFAULT_RADIUS

public static final double DEFAULT_RADIUS
The default radius percent (currently 100%).

See Also:
Constant Field Values

MAX_RADIUS

public static final double MAX_RADIUS
The maximum radius (currently 100%).

See Also:
Constant Field Values

DEFAULT_START_ANGLE

public static final double DEFAULT_START_ANGLE
The default starting angle for the pie chart.

See Also:
Constant Field Values

DEFAULT_DIRECTION

public static final int DEFAULT_DIRECTION
The default direction for the pie chart.

See Also:
Constant Field Values

DEFAULT_SECTION_LABEL_TYPE

public static final int DEFAULT_SECTION_LABEL_TYPE
The default section label type.

See Also:
Constant Field Values

DEFAULT_SECTION_LABEL_FONT

public static final java.awt.Font DEFAULT_SECTION_LABEL_FONT
The default section label font.


DEFAULT_SECTION_LABEL_PAINT

public static final java.awt.Paint DEFAULT_SECTION_LABEL_PAINT
The default section label paint.


DEFAULT_SECTION_LABEL_GAP

public static final double DEFAULT_SECTION_LABEL_GAP
The default section label gap (currently 10%).

See Also:
Constant Field Values

MAX_SECTION_LABEL_GAP

public static final double MAX_SECTION_LABEL_GAP
The maximum interior gap (currently 30%).

See Also:
Constant Field Values

DEFAULT_VALUE_FORMATTER

public static final java.text.NumberFormat DEFAULT_VALUE_FORMATTER
The default value label formatter.


DEFAULT_PERCENT_FORMATTER

public static final java.text.NumberFormat DEFAULT_PERCENT_FORMATTER
The default percent label formatter.


DEFAULT_SERIES_LABEL_FONT

public static final java.awt.Font DEFAULT_SERIES_LABEL_FONT
The default series label font.


DEFAULT_SERIES_LABEL_PAINT

public static final java.awt.Paint DEFAULT_SERIES_LABEL_PAINT
The default series label paint.


DEFAULT_SHOW_SERIES_LABELS

public static final boolean DEFAULT_SHOW_SERIES_LABELS
The default for the show series labels flag

See Also:
Constant Field Values

DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW

public static final double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW
The default minimum arc angle to draw.

See Also:
Constant Field Values

localizationResources

protected static java.util.ResourceBundle localizationResources
The resourceBundle for the localization.

Constructor Detail

PiePlot

public PiePlot()
Creates a new plot.


PiePlot

public PiePlot(PieDataset dataset)
Creates a pie chart.

Parameters:
dataset - the dataset.

PiePlot

public PiePlot(CategoryDataset dataset,
               int type)
Creates a new plot that will draw multiple pie charts, one for each row or column (as requested) in the dataset.

Parameters:
dataset - the dataset.
type - controls how pie data is extracted (PER_ROW or PER_COLUMN).
Method Detail

getExtractType

public int getExtractType()
Returns the data extraction type if this plot uses a category plot. This type is either PER_ROW or PER_COLUMN.

Returns:
the extract type.

setExtractType

public void setExtractType(int extractType)
Defines the data extraction type if this plot uses a category plot. This type is either PER_ROW or PER_COLUMN.

Parameters:
extractType - the extract type.

getDataset

public PieDataset getDataset()
Returns the dataset.

Returns:
The dataset.

setDataset

public void setDataset(PieDataset dataset)
Sets the dataset. A DatasetChangeEvent is sent to all registered listeners.

Parameters:
dataset - the dataset.

getMultiDataset

public CategoryDataset getMultiDataset()
Returns the dataset for multiple pies.

Returns:
The dataset.

setMultiDataset

public void setMultiDataset(CategoryDataset dataset)
Sets the dataset for multiplie pies. A DatasetChangeEvent is sent to all registered listeners.

Parameters:
dataset - the dataset.

getStartAngle

public double getStartAngle()
Returns the start angle for the first pie section.

This is measured in degrees starting from 3 o'clock and measuring anti-clockwise.

Returns:
the start angle.

setStartAngle

public void setStartAngle(double angle)
Sets the starting angle.

The initial default value is 90 degrees, which corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock... this is the encoding used by Java's Arc2D class.

Parameters:
angle - the angle (in degrees).

getDirection

public org.jfree.util.Rotation getDirection()
Returns the direction in which the pie sections are drawn (clockwise or anti-clockwise).

Returns:
The direction.

setDirection

public void setDirection(org.jfree.util.Rotation direction)
Sets the direction (use the constants CLOCKWISE or ANTICLOCKWISE).

Parameters:
direction - the new direction (null not permitted).

getInteriorGap

public double getInteriorGap()
Returns the interior gap, measured as a percentage of the available drawing space.

Returns:
The gap percentage.

setInteriorGap

public void setInteriorGap(double percent)
Sets the interior gap.

Parameters:
percent - The gap.

isCircular

public boolean isCircular()
Returns a flag indicating whether the pie chart is circular, or stretched into an elliptical shape.

Returns:
a flag indicating whether the pie chart is circular.

setCircular

public void setCircular(boolean flag)
A flag indicating whether the pie chart is circular, or stretched into an elliptical shape.

Parameters:
flag - the new value.

setCircularAttribute

protected void setCircularAttribute(boolean circular)
Sets the circular attribute, with no side effects.

Parameters:
circular - the new value of the flag.

getRadius

public double getRadius()
Returns the radius (a percentage of the available space).

Returns:
The radius percentage.

setRadius

public void setRadius(double percent)
Sets the radius.

Parameters:
percent - the new value.

getExplodePercent

public double getExplodePercent(int section)
Returns the amount that a section should be 'exploded'.

Parameters:
section - the section number.
Returns:
the amount that a section should be 'exploded'.

setExplodePercent

public void setExplodePercent(int section,
                              double percent)
Sets the amount that a pie section should be exploded.

If you want to display a pie chart with one or more exploded sections, you first need to set the pie chart radius to something less than 100%. Then, consider a circle that represents a pie chart with the maximum radius (100%) and a smaller circle that is the actual pie chart (with radius x%). Now, the explode percent determines how far out towards the outer circle the pie section is shifted (exploded).

Parameters:
section - the section index.
percent - the amount to explode the section as a percentage.

getSectionLabelType

public int getSectionLabelType()
Returns the section label type. Defined by the constants: NO_LABELS, NAME_LABELS, PERCENT_LABELS and NAME_AND_PERCENT_LABELS.

Returns:
the section label type.

setSectionLabelType

public void setSectionLabelType(int type)
Sets the section label type.

Valid types are defined by the following constants: NO_LABELS, NAME_LABELS, VALUE_LABELS, PERCENT_LABELS, NAME_AND_VALUE_LABELS, NAME_AND_PERCENT_LABELS, VALUE_AND_PERCENT_LABELS.

Parameters:
type - the type.

getSectionLabelFont

public java.awt.Font getSectionLabelFont()
Returns the section label font.

Returns:
the section label font.

setSectionLabelFont

public void setSectionLabelFont(java.awt.Font font)
Sets the section label font.

Notifies registered listeners that the plot has been changed.

Parameters:
font - the new section label font.

getSectionLabelPaint

public java.awt.Paint getSectionLabelPaint()
Returns the section label paint.

Returns:
the section label paint.

setSectionLabelPaint

public void setSectionLabelPaint(java.awt.Paint paint)
Sets the section label paint.

Notifies registered listeners that the plot has been changed.

Parameters:
paint - the new section label paint.

getSectionLabelGap

public double getSectionLabelGap()
Returns the section label gap, measured as a percentage of the radius.

Returns:
the section label gap, measured as a percentage of the radius.

setSectionLabelGap

public void setSectionLabelGap(double percent)
Sets the section label gap percent.

Parameters:
percent - the gap.

setValueFormatString

public void setValueFormatString(java.lang.String format)
Sets the format string for the value labels.

Parameters:
format - The format.

setValueFormat

public void setValueFormat(java.text.NumberFormat format)
Sets the format for the value labels.

Parameters:
format - the format.

setPercentFormatString

public void setPercentFormatString(java.lang.String format)
Sets the format string for the percent labels.

Parameters:
format - the format.

setPercentFormat

public void setPercentFormat(java.text.NumberFormat format)
Sets the format for the value labels.

Parameters:
format - the format.

getPieDataset

public PieDataset getPieDataset()
Returns the dataset for the plot, cast as a PieDataset.

Provided for convenience.

Returns:
the dataset for the plot, cast as a PieDataset.

getShowSeriesLabels

public boolean getShowSeriesLabels()
Returns the show series labels flag.

Returns:
the show series label flag.

setShowSeriesLabels

public void setShowSeriesLabels(boolean flag)
Sets the show series labels flag.

Notifies registered listeners that the plot has been changed.

Parameters:
flag - the new show series labels flag.

getSeriesLabelFont

public java.awt.Font getSeriesLabelFont()
Returns the series label font.

Returns:
the series label font.

setSeriesLabelFont

public void setSeriesLabelFont(java.awt.Font font)
Sets the series label font.

Notifies registered listeners that the plot has been changed.

Parameters:
font - the new series label font.

getSeriesLabelPaint

public java.awt.Paint getSeriesLabelPaint()
Returns the series label paint.

Returns:
the series label paint.

setSeriesLabelPaint

public void setSeriesLabelPaint(java.awt.Paint paint)
Sets the series label paint.

Notifies registered listeners that the plot has been changed.

Parameters:
paint - the new series label paint. ??? ??? ???

getKeys

public java.util.Collection getKeys()
Returns a collection of the section keys (or categories) in the dataset.

Returns:
the categories.

getSectionPaint

public java.awt.Paint getSectionPaint(int section)
Returns the paint used to fill a section of the pie plot.

Parameters:
section - the section index (zero-based).
Returns:
The paint.

setSectionPaint

public void setSectionPaint(int section,
                            java.awt.Paint paint)
Sets the paint used to fill a section of the pie.

Parameters:
section - the section index (zero-based).
paint - the paint.

getPaint

public java.awt.Paint getPaint(int section)
Deprecated. Use getSectionPaint(int).

Returns the paint used to fill a section of the pie plot.

Parameters:
section - the section index (zero-based).
Returns:
The paint.

setPaint

public void setPaint(int section,
                     java.awt.Paint paint)
Deprecated. Use setSectionPaint(int, Paint).

Sets the paint used to fill a section of the pie.

Parameters:
section - the section index (zero-based).
paint - the paint.

getSectionPaint

public java.awt.Paint getSectionPaint()
Returns the paint for ALL sections in the plot.

Returns:
The paint (possibly null).

setSectionPaint

public void setSectionPaint(java.awt.Paint paint)
Sets the paint for ALL sections in the plot. If this is set to null, then a list of paints is used instead (to allow different colors to be used for each section).

Parameters:
paint - the paint (null permitted).

getSectionPaintListAutoFill

public boolean getSectionPaintListAutoFill()
Returns a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.

Returns:
A boolean.

setSectionPaintListAutoFill

public void setSectionPaintListAutoFill(boolean fill)
Sets a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.

Parameters:
fill - the flag.

getDefaultPaint

public java.awt.Paint getDefaultPaint()
Deprecated. Use getSectionPaint().

Returns the default paint. This is used to fill pie sections when the paint table is inactive (not common).

Returns:
The paint.

setDefaultPaint

public void setDefaultPaint(java.awt.Paint paint)
Deprecated. Use setSectionPaint(Paint).

Sets the default paint.

Parameters:
paint - the paint.

getSectionOutlinePaint

public java.awt.Paint getSectionOutlinePaint()
Returns the outline paint for ALL sections in the plot.

Returns:
The paint (possibly null.

setSectionOutlinePaint

public void setSectionOutlinePaint(java.awt.Paint paint)
Sets the outline paint for ALL sections in the plot. If this is set to null, then a list of outline paints is used instead (to allow different colors to be used for the outline of each section).

Parameters:
paint - the paint (null permitted).

getSectionOutlinePaint

public java.awt.Paint getSectionOutlinePaint(int section)
Returns the paint used to outline a section of the pie plot.

Parameters:
section - the section index (zero-based).
Returns:
The paint.

setSectionOutlinePaint

public void setSectionOutlinePaint(int section,
                                   java.awt.Paint paint)
Sets the paint used to outline a section of the pie.

Parameters:
section - the section index (zero-based).
paint - the paint.

getSectionOutlinePaintListAutoFill

public boolean getSectionOutlinePaintListAutoFill()
Returns a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.

Returns:
A boolean.

setSectionOutlinePaintListAutoFill

public void setSectionOutlinePaintListAutoFill(boolean fill)
Sets a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.

Parameters:
fill - the flag.

getOutlinePaint

public java.awt.Paint getOutlinePaint(int section)
Deprecated. Use getSectionOutlinePaint.

Returns the paint used to outline a section of the pie plot.

Parameters:
section - the section index (zero-based).
Returns:
The paint.

setOutlinePaint

public void setOutlinePaint(int section,
                            java.awt.Paint paint)
Deprecated. Use setSectionOutlinePaint.

Sets the paint used to outline a section of the pie.

Parameters:
section - the section index (zero-based).
paint - the paint.

getDefaultOutlinePaint

public java.awt.Paint getDefaultOutlinePaint()
Deprecated. Use getSectionOutlinePaint.

Returns the default outline paint. This is used to outline pie sections when the paint table is inactive (the usual case).

Returns:
The paint.

setDefaultOutlinePaint

public void setDefaultOutlinePaint(java.awt.Paint paint)
Deprecated. Use setSectionOutlinePaint(paint).

Sets the default outline paint.

Parameters:
paint - the paint.

getSectionOutlineStroke

public java.awt.Stroke getSectionOutlineStroke(int section)
Returns the stroke used to outline a section of the pie plot.

Parameters:
section - the section index (zero-based).
Returns:
The stroke.

setSectionOutlineStroke

public void setSectionOutlineStroke(int section,
                                    java.awt.Stroke stroke)
Sets the stroke used to outline a section of the pie.

Parameters:
section - the section index (zero-based).
stroke - the stroke.

getOutlineStroke

public java.awt.Stroke getOutlineStroke(int section)
Deprecated. Use getSectionOutlineStroke.

Returns the stroke used to outline a section of the pie plot.

Parameters:
section - the section index (zero-based).
Returns:
The stroke.

setOutlineStroke

public void setOutlineStroke(int section,
                             java.awt.Stroke stroke)
Deprecated. Use setSectionOutlineStroke.

Sets the stroke used to outline a section of the pie.

Parameters:
section - the section index (zero-based).
stroke - the stroke.

getSectionOutlineStroke

public java.awt.Stroke getSectionOutlineStroke()
Returns the outline stroke for ALL sections in the plot.

Returns:
The stroke (possibly null).

setSectionOutlineStroke

public void setSectionOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke for ALL sections in the plot.

Parameters:
stroke - the stroke (null permitted).

getDefaultOutlineStroke

public java.awt.Stroke getDefaultOutlineStroke()
Deprecated. Use getSectionOutlineStroke.

Returns the default outline stroke. This is used to outline pie sections when the outline stroke table is inactive.

Returns:
The stroke.

setDefaultOutlineStroke

public void setDefaultOutlineStroke(java.awt.Stroke stroke)
Deprecated. Use setSectionOutlineStroke.

Sets the default outline stroke.

Parameters:
stroke - the stroke.

getSectionOutlineStrokeListAutoFill

public boolean getSectionOutlineStrokeListAutoFill()
Returns a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.

Returns:
A boolean.

setSectionOutlineStrokeListAutoFill

public void setSectionOutlineStrokeListAutoFill(boolean fill)
Sets a flag that controls whether or not null values are automatically replaced with a value from the DrawingSupplier.

Parameters:
fill - the flag.

getMinimumArcAngleToDraw

public double getMinimumArcAngleToDraw()
Returns the minimum arc angle that will be drawn. Pie sections for an angle smaller than this are not drawn, to avoid a JDK bug.

Returns:
The minimum angle.

setMinimumArcAngleToDraw

public void setMinimumArcAngleToDraw(double angle)
Sets the minimum arc angle that will be drawn. Pie sections for an angle smaller than this are not drawn, to avoid a JDK bug.

Parameters:
angle - the minimum angle.

getLegendItems

public LegendItemCollection getLegendItems()
Returns a collection of legend items for the pie chart.

Overrides:
getLegendItems in class Plot
Returns:
the legend items.

getToolTipGenerator

public PieItemLabelGenerator getToolTipGenerator()
Deprecated. Use getItemLabelGenerator().

Returns the tool-tip generator (possibly null).

Returns:
The tool-tip generator.

setToolTipGenerator

public void setToolTipGenerator(PieItemLabelGenerator generator)
Deprecated. Use setItemLabelGenerator.

Sets the tool tip generator.

If you set the generator to null, no tool tips will be generated for the pie chart.

Parameters:
generator - the new tooltip generator (null permitted).

getItemLabelGenerator

public PieItemLabelGenerator getItemLabelGenerator()
Returns the label generator.

Returns:
The label generator (possibly null).

setItemLabelGenerator

public void setItemLabelGenerator(PieItemLabelGenerator generator)
Sets the label generator (used for generating tool-tips).

If you set the generator to null, no tool tips will be generated for the pie chart.

Parameters:
generator - the label generator (null permitted).

getURLGenerator

public PieURLGenerator getURLGenerator()
Returns the URL generator (possibly null).

Returns:
the URL generator.

setURLGenerator

public void setURLGenerator(PieURLGenerator generator)
Sets the URL generator.

Parameters:
generator - the new URL generator (null permitted).

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 PlotState parentState,
                 PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

Specified by:
draw in class Plot
Parameters:
g2 - the graphics device.
plotArea - the area within which the plot should be drawn.
parentState - the state from the parent plot, if there is one.
info - collects info about the drawing.

drawPie

protected void drawPie(java.awt.Graphics2D g2,
                       java.awt.geom.Rectangle2D plotArea,
                       PlotRenderingInfo info,
                       int pieIndex,
                       PieDataset data,
                       java.lang.String label)
Draws the pie.

Parameters:
g2 - the graphics device.
plotArea - the plot area.
info - chart rendering info.
pieIndex - the pie index.
data - the data.
label - the label.

drawMultiplePies

protected void drawMultiplePies(java.awt.Graphics2D g2,
                                java.awt.geom.Rectangle2D plotArea,
                                PlotRenderingInfo info)
Draws a plot containing multiple pies.

Parameters:
g2 - the graphics device.
plotArea - the plot area.
info - an (optional) carrier for return information about the chart structure.

drawLabel

protected void drawLabel(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D pieArea,
                         java.awt.geom.Rectangle2D explodedPieArea,
                         PieDataset data,
                         double value,
                         int section,
                         double startAngle,
                         double extent)
Draws the label for one pie section.

You can control the label type using the setSectionLabelType() method.

Parameters:
g2 - the graphics device.
pieArea - the area for the unexploded pie sections.
explodedPieArea - the area for the exploded pie section.
data - the data for the plot.
value - the value of the label.
section - the section (zero-based index).
startAngle - the starting angle.
extent - the extent of the arc.

getPlotType

public java.lang.String getPlotType()
Returns a short string describing the type of plot.

Specified by:
getPlotType in class Plot
Returns:
the plot type.

zoom

public void zoom(double percent)
A zoom method that does nothing.

Plots are required to support the zoom operation. In the case of a pie chart, it doesn't make sense to zoom in or out, so the method is empty.

Overrides:
zoom in class Plot
Parameters:
percent - the zoom percentage.

getArcBounds

protected java.awt.geom.Rectangle2D getArcBounds(java.awt.geom.Rectangle2D unexploded,
                                                 java.awt.geom.Rectangle2D exploded,
                                                 double startAngle,
                                                 double extent,
                                                 double explodePercent)
Returns a rectangle that can be used to create a pie section (taking into account the amount by which the pie section is 'exploded').

Parameters:
unexploded - the area inside which the unexploded pie sections are drawn.
exploded - the area inside which the exploded pie sections are drawn.
startAngle - the start angle.
extent - the extent of the arc.
explodePercent - the amount by which the pie section is exploded.
Returns:
a rectangle that can be used to create a pie section.

calculateLabelLocation

protected java.awt.geom.Point2D calculateLabelLocation(java.awt.geom.Rectangle2D labelBounds,
                                                       double ascent,
                                                       java.awt.geom.Rectangle2D unexploded,
                                                       java.awt.geom.Rectangle2D exploded,
                                                       double startAngle,
                                                       double extent,
                                                       double explodePercent)
Returns the location for a label, taking into account whether or not the pie section is exploded.

Parameters:
labelBounds - the label bounds.
ascent - the ascent.
unexploded - the area within which the unexploded pie sections are drawn.
exploded - the area within which the exploded pie sections are drawn.
startAngle - the start angle for the pie section.
extent - the extent of the arc.
explodePercent - the amount by which the pie section is exploded.
Returns:
the location for a label.

equals

public boolean equals(java.lang.Object obj)
Tests this plot for equality with another object. Note that the plot's dataset is NOT included in the test for equality.

Overrides:
equals in class Plot
Parameters:
obj - the other object.
Returns:
true or false.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the plot.

Overrides:
clone in class Plot
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - if some component of the plot does not support cloning.