KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > plot > PiePlot


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * ------------
27  * PiePlot.java
28  * ------------
29  * (C) Copyright 2000-2005, by Andrzej Porebski and Contributors.
30  *
31  * Original Author: Andrzej Porebski;
32  * Contributor(s): David Gilbert (for Object Refinery Limited);
33  * Martin Cordova (percentages in labels);
34  * Richard Atkinson (URL support for image maps);
35  * Christian W. Zuckschwerdt;
36  * Arnaud Lelievre;
37  * Andreas Schroeder (very minor);
38  *
39  * $Id: PiePlot.java,v 1.17 2005/05/19 14:03:41 mungady Exp $
40  *
41  * Changes (from 21-Jun-2001)
42  * --------------------------
43  * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG);
44  * 18-Sep-2001 : Updated header (DG);
45  * 15-Oct-2001 : Data source classes moved to com.jrefinery.data.* (DG);
46  * 19-Oct-2001 : Moved series paint and stroke methods from JFreeChart.java to
47  * Plot.java (DG);
48  * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG);
49  * 13-Nov-2001 : Modified plot subclasses so that null axes are possible for
50  * pie plot (DG);
51  * 17-Nov-2001 : Added PieDataset interface and amended this class accordingly,
52  * and completed removal of BlankAxis class as it is no longer
53  * required (DG);
54  * 19-Nov-2001 : Changed 'drawCircle' property to 'circular' property (DG);
55  * 21-Nov-2001 : Added options for exploding pie sections and filled out range
56  * of properties (DG);
57  * Added option for percentages in chart labels, based on code
58  * by Martin Cordova (DG);
59  * 30-Nov-2001 : Changed default font from "Arial" --> "SansSerif" (DG);
60  * 12-Dec-2001 : Removed unnecessary 'throws' clause in constructor (DG);
61  * 13-Dec-2001 : Added tooltips (DG);
62  * 16-Jan-2002 : Renamed tooltips class (DG);
63  * 22-Jan-2002 : Fixed bug correlating legend labels with pie data (DG);
64  * 05-Feb-2002 : Added alpha-transparency to plot class, and updated
65  * constructors accordingly (DG);
66  * 06-Feb-2002 : Added optional background image and alpha-transparency to Plot
67  * and subclasses. Clipped drawing within plot area (DG);
68  * 26-Mar-2002 : Added an empty zoom method (DG);
69  * 18-Apr-2002 : PieDataset is no longer sorted (oldman);
70  * 23-Apr-2002 : Moved dataset from JFreeChart to Plot. Added
71  * getLegendItemLabels() method (DG);
72  * 19-Jun-2002 : Added attributes to control starting angle and direction
73  * (default is now clockwise) (DG);
74  * 25-Jun-2002 : Removed redundant imports (DG);
75  * 02-Jul-2002 : Fixed sign of percentage bug introduced in 0.9.2 (DG);
76  * 16-Jul-2002 : Added check for null dataset in getLegendItemLabels() (DG);
77  * 30-Jul-2002 : Moved summation code to DatasetUtilities (DG);
78  * 05-Aug-2002 : Added URL support for image maps - new member variable for
79  * urlGenerator, modified constructor and minor change to the
80  * draw method (RA);
81  * 18-Sep-2002 : Modified the percent label creation and added setters for the
82  * formatters (AS);
83  * 24-Sep-2002 : Added getLegendItems() method (DG);
84  * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
85  * 09-Oct-2002 : Added check for null entity collection (DG);
86  * 30-Oct-2002 : Changed PieDataset interface (DG);
87  * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG);
88  * 02-Jan-2003 : Fixed "no data" message (DG);
89  * 23-Jan-2003 : Modified to extract data from rows OR columns in
90  * CategoryDataset (DG);
91  * 14-Feb-2003 : Fixed label drawing so that foreground alpha does not apply
92  * (bug id 685536) (DG);
93  * 07-Mar-2003 : Modified to pass pieIndex on to PieSectionEntity and tooltip
94  * and URL generators (DG);
95  * 21-Mar-2003 : Added a minimum angle for drawing arcs
96  * (see bug id 620031) (DG);
97  * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG);
98  * 02-Jun-2003 : Fixed bug 721733 (DG);
99  * 30-Jul-2003 : Modified entity constructor (CZ);
100  * 19-Aug-2003 : Implemented Cloneable (DG);
101  * 29-Aug-2003 : Fixed bug 796936 (null pointer on setOutlinePaint()) (DG);
102  * 08-Sep-2003 : Added internationalization via use of properties
103  * resourceBundle (RFE 690236) (AL);
104  * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG);
105  * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG);
106  * 05-Nov-2003 : Fixed missing legend bug (DG);
107  * 10-Nov-2003 : Re-added the DatasetChangeListener to constructors (CZ);
108  * 29-Jan-2004 : Fixed clipping bug in draw() method (DG);
109  * 11-Mar-2004 : Major overhaul to improve labelling (DG);
110  * 31-Mar-2004 : Made an adjustment for the plot area when the label generator
111  * is null. Fixed null pointer exception when the label
112  * generator returns null for a label (DG);
113  * 06-Apr-2004 : Added getter, setter, serialization and draw support for
114  * labelBackgroundPaint (AS);
115  * 08-Apr-2004 : Added flag to control whether null values are ignored or
116  * not (DG);
117  * 15-Apr-2004 : Fixed some minor warnings from Eclipse (DG);
118  * 26-Apr-2004 : Added attributes for label outline and shadow (DG);
119  * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG);
120  * 04-Nov-2004 : Fixed null pointer exception with new LegendTitle class (DG);
121  * 09-Nov-2004 : Added user definable legend item shape (DG);
122  * 25-Nov-2004 : Added new legend label generator (DG);
123  * 20-Apr-2005 : Added a tool tip generator for legend labels (DG);
124  * 26-Apr-2005 : Removed LOGGER (DG);
125  * 05-May-2005 : Updated draw() method parameters (DG);
126  * 10-May-2005 : Added flag to control visibility of label linking lines, plus
127  * another flag to control the handling of zero values (DG);
128  *
129  */

130
131 package org.jfree.chart.plot;
132
133 import java.awt.AlphaComposite JavaDoc;
134 import java.awt.BasicStroke JavaDoc;
135 import java.awt.Color JavaDoc;
136 import java.awt.Composite JavaDoc;
137 import java.awt.Font JavaDoc;
138 import java.awt.Graphics2D JavaDoc;
139 import java.awt.Paint JavaDoc;
140 import java.awt.Shape JavaDoc;
141 import java.awt.Stroke JavaDoc;
142 import java.awt.geom.Arc2D JavaDoc;
143 import java.awt.geom.Line2D JavaDoc;
144 import java.awt.geom.Point2D JavaDoc;
145 import java.awt.geom.Rectangle2D JavaDoc;
146 import java.io.IOException JavaDoc;
147 import java.io.ObjectInputStream JavaDoc;
148 import java.io.ObjectOutputStream JavaDoc;
149 import java.io.Serializable JavaDoc;
150 import java.util.Iterator JavaDoc;
151 import java.util.List JavaDoc;
152 import java.util.ResourceBundle JavaDoc;
153
154 import org.jfree.chart.LegendItem;
155 import org.jfree.chart.LegendItemCollection;
156 import org.jfree.chart.entity.EntityCollection;
157 import org.jfree.chart.entity.PieSectionEntity;
158 import org.jfree.chart.event.PlotChangeEvent;
159 import org.jfree.chart.labels.PieSectionLabelGenerator;
160 import org.jfree.chart.labels.PieToolTipGenerator;
161 import org.jfree.chart.labels.StandardPieItemLabelGenerator;
162 import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
163 import org.jfree.chart.urls.PieURLGenerator;
164 import org.jfree.data.DefaultKeyedValues;
165 import org.jfree.data.KeyedValues;
166 import org.jfree.data.general.DatasetChangeEvent;
167 import org.jfree.data.general.DatasetUtilities;
168 import org.jfree.data.general.PieDataset;
169 import org.jfree.io.SerialUtilities;
170 import org.jfree.text.G2TextMeasurer;
171 import org.jfree.text.TextBlock;
172 import org.jfree.text.TextBox;
173 import org.jfree.text.TextUtilities;
174 import org.jfree.ui.RectangleAnchor;
175 import org.jfree.ui.RectangleInsets;
176 import org.jfree.util.ObjectList;
177 import org.jfree.util.ObjectUtilities;
178 import org.jfree.util.PaintList;
179 import org.jfree.util.Rotation;
180 import org.jfree.util.ShapeUtilities;
181 import org.jfree.util.StrokeList;
182
183 /**
184  * A plot that displays data in the form of a pie chart, using data from any
185  * class that implements the {@link PieDataset} interface.
186  * <P>
187  * Special notes:
188  * <ol>
189  * <li>the default starting point is 12 o'clock and the pie sections proceed
190  * in a clockwise direction, but these settings can be changed;</li>
191  * <li>negative values in the dataset are ignored;</li>
192  * <li>there are utility methods for creating a {@link PieDataset} from a
193  * {@link org.jfree.data.category.CategoryDataset};</li>
194  * </ol>
195  *
196  * @see Plot
197  * @see PieDataset
198  */

199 public class PiePlot extends Plot implements Cloneable JavaDoc, Serializable JavaDoc {
200     
201     /** For serialization. */
202     private static final long serialVersionUID = -795612466005590431L;
203     
204     /** The default interior gap. */
205     public static final double DEFAULT_INTERIOR_GAP = 0.25;
206
207     /** The maximum interior gap (currently 40%). */
208     public static final double MAX_INTERIOR_GAP = 0.40;
209
210     /** The default starting angle for the pie chart. */
211     public static final double DEFAULT_START_ANGLE = 90.0;
212
213     /** The default section label font. */
214     public static final Font JavaDoc DEFAULT_LABEL_FONT
215         = new Font JavaDoc("SansSerif", Font.PLAIN, 10);
216
217     /** The default section label paint. */
218     public static final Paint JavaDoc DEFAULT_LABEL_PAINT = Color.black;
219     
220     /** The default section label background paint. */
221     public static final Paint JavaDoc DEFAULT_LABEL_BACKGROUND_PAINT
222         = new Color JavaDoc(255, 255, 192);
223
224     /** The default section label outline paint. */
225     public static final Paint JavaDoc DEFAULT_LABEL_OUTLINE_PAINT = Color.black;
226     
227     /** The default section label outline stroke. */
228     public static final Stroke JavaDoc DEFAULT_LABEL_OUTLINE_STROKE
229         = new BasicStroke JavaDoc(0.5f);
230     
231     /** The default section label shadow paint. */
232     public static final Paint JavaDoc DEFAULT_LABEL_SHADOW_PAINT = Color.lightGray;
233     
234     /** The default minimum arc angle to draw. */
235     public static final double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW = 0.00001;
236
237     /** The dataset for the pie chart. */
238     private PieDataset dataset;
239
240     /** The pie index (used by the {@link MultiplePiePlot} class). */
241     private int pieIndex;
242
243     /**
244      * The amount of space left around the outside of the pie plot, expressed
245      * as a percentage.
246      */

247     private double interiorGap;
248
249     /** Flag determining whether to draw an ellipse or a perfect circle. */
250     private boolean circular;
251
252     /** The starting angle. */
253     private double startAngle;
254
255     /** The direction for the pie segments. */
256     private Rotation direction;
257
258     /** The paint for ALL sections (overrides list). */
259     private transient Paint JavaDoc sectionPaint;
260
261     /** The section paint list. */
262     private PaintList sectionPaintList;
263
264     /** The base section paint (fallback). */
265     private transient Paint JavaDoc baseSectionPaint;
266
267     /** The outline paint for ALL sections (overrides list). */
268     private transient Paint JavaDoc sectionOutlinePaint;
269
270     /** The section outline paint list. */
271     private PaintList sectionOutlinePaintList;
272
273     /** The base section outline paint (fallback). */
274     private transient Paint JavaDoc baseSectionOutlinePaint;
275
276     /** The outline stroke for ALL sections (overrides list). */
277     private transient Stroke JavaDoc sectionOutlineStroke;
278
279     /** The section outline stroke list. */
280     private StrokeList sectionOutlineStrokeList;
281
282     /** The base section outline stroke (fallback). */
283     private transient Stroke JavaDoc baseSectionOutlineStroke;
284
285     /** The shadow paint. */
286     private transient Paint JavaDoc shadowPaint = Color.gray;
287
288     /** The x-offset for the shadow effect. */
289     private double shadowXOffset = 4.0f;
290     
291     /** The y-offset for the shadow effect. */
292     private double shadowYOffset = 4.0f;
293     
294     /** The percentage amount to explode each pie section. */
295     private ObjectList explodePercentages;
296     
297     /** The section label generator. */
298     private PieSectionLabelGenerator labelGenerator;
299
300     /** The font used to display the section labels. */
301     private Font JavaDoc labelFont;
302
303     /** The color used to draw the section labels. */
304     private transient Paint JavaDoc labelPaint;
305     
306     /** The color used to draw the background of the section labels. */
307     private transient Paint JavaDoc labelBackgroundPaint;
308
309     /**
310      * The paint used to draw the outline of the section labels
311      * (<code>null</code> permitted).
312      */

313     private transient Paint JavaDoc labelOutlinePaint;
314     
315     /**
316      * The stroke used to draw the outline of the section labels
317      * (<code>null</code> permitted).
318      */

319     private transient Stroke JavaDoc labelOutlineStroke;
320     
321     /**
322      * The paint used to draw the shadow for the section labels
323      * (<code>null</code> permitted).
324      */

325     private transient Paint JavaDoc labelShadowPaint;
326     
327     /** The maximum label width as a percentage of the plot width. */
328     private double maximumLabelWidth = 0.20;
329     
330     /**
331      * The gap between the labels and the plot as a percentage of the plot
332      * width.
333      */

334     private double labelGap = 0.05;
335
336     /** A flag that controls whether or not the label links are drawn. */
337     private boolean labelLinksVisible;
338     
339     /** The link margin. */
340     private double labelLinkMargin = 0.05;
341     
342     /** The paint used for the label linking lines. */
343     private transient Paint JavaDoc labelLinkPaint = Color.black;
344     
345     /** The stroke used for the label linking lines. */
346     private transient Stroke JavaDoc labelLinkStroke = new BasicStroke JavaDoc(0.5f);
347     
348     /** The tooltip generator. */
349     private PieToolTipGenerator toolTipGenerator;
350
351     /** The URL generator. */
352     private PieURLGenerator urlGenerator;
353     
354     /** The legend label generator. */
355     private PieSectionLabelGenerator legendLabelGenerator;
356     
357     /** A tool tip generator for the legend. */
358     private PieSectionLabelGenerator legendLabelToolTipGenerator;
359     
360     /**
361      * A flag that controls whether <code>null</code> values are ignored.
362      */

363     private boolean ignoreNullValues;
364     
365     /**
366      * A flag that controls whether zero values are ignored.
367      */

368     private boolean ignoreZeroValues;
369
370     /** The legend item shape. */
371     private transient Shape JavaDoc legendItemShape;
372     
373     /**
374      * The smallest arc angle that will get drawn (this is to avoid a bug in
375      * various Java implementations that causes the JVM to crash). See this
376      * link for details:
377      *
378      * http://www.jfree.org/phpBB2/viewtopic.php?t=2707
379      *
380      * ...and this bug report in the Java Bug Parade:
381      *
382      * http://developer.java.sun.com/developer/bugParade/bugs/4836495.html
383      */

384     private double minimumArcAngleToDraw;
385
386     /** The resourceBundle for the localization. */
387     protected static ResourceBundle JavaDoc localizationResources =
388         ResourceBundle.getBundle("org.jfree.chart.plot.LocalizationBundle");
389
390     /**
391      * Creates a new plot. The dataset is initially set to <code>null</code>.
392      */

393     public PiePlot() {
394         this(null);
395     }
396
397     /**
398      * Creates a plot that will draw a pie chart for the specified dataset.
399      *
400      * @param dataset the dataset (<code>null</code> permitted).
401      */

402     public PiePlot(PieDataset dataset) {
403         super();
404         this.dataset = dataset;
405         if (dataset != null) {
406             dataset.addChangeListener(this);
407         }
408         this.pieIndex = 0;
409         
410         this.interiorGap = DEFAULT_INTERIOR_GAP;
411         this.circular = true;
412         this.startAngle = DEFAULT_START_ANGLE;
413         this.direction = Rotation.CLOCKWISE;
414         this.minimumArcAngleToDraw = DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW;
415         
416         this.sectionPaint = null;
417         this.sectionPaintList = new PaintList();
418         this.baseSectionPaint = null;
419
420         this.sectionOutlinePaint = null;
421         this.sectionOutlinePaintList = new PaintList();
422         this.baseSectionOutlinePaint = DEFAULT_OUTLINE_PAINT;
423
424         this.sectionOutlineStroke = null;
425         this.sectionOutlineStrokeList = new StrokeList();
426         this.baseSectionOutlineStroke = DEFAULT_OUTLINE_STROKE;
427         
428         this.explodePercentages = new ObjectList();
429
430         this.labelGenerator = new StandardPieItemLabelGenerator();
431         this.labelFont = DEFAULT_LABEL_FONT;
432         this.labelPaint = DEFAULT_LABEL_PAINT;
433         this.labelBackgroundPaint = DEFAULT_LABEL_BACKGROUND_PAINT;
434         this.labelOutlinePaint = DEFAULT_LABEL_OUTLINE_PAINT;
435         this.labelOutlineStroke = DEFAULT_LABEL_OUTLINE_STROKE;
436         this.labelShadowPaint = DEFAULT_LABEL_SHADOW_PAINT;
437         this.labelLinksVisible = true;
438         
439         this.toolTipGenerator = null;
440         this.urlGenerator = null;
441         this.legendLabelGenerator = new StandardPieSectionLabelGenerator();
442         this.legendLabelToolTipGenerator = null;
443         this.legendItemShape = Plot.DEFAULT_LEGEND_ITEM_CIRCLE;
444         
445         this.ignoreNullValues = false;
446         this.ignoreZeroValues = false;
447     }
448
449     /**
450      * Returns the dataset.
451      *
452      * @return The dataset (possibly <code>null</code>).
453      */

454     public PieDataset getDataset() {
455         return this.dataset;
456     }
457
458     /**
459      * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'.
460      *
461      * @param dataset the dataset (<code>null</code> permitted).
462      */

463     public void setDataset(PieDataset dataset) {
464         // if there is an existing dataset, remove the plot from the list of
465
// change listeners...
466
PieDataset existing = this.dataset;
467         if (existing != null) {
468             existing.removeChangeListener(this);
469         }
470
471         // set the new dataset, and register the chart as a change listener...
472
this.dataset = dataset;
473         if (dataset != null) {
474             setDatasetGroup(dataset.getGroup());
475             dataset.addChangeListener(this);
476         }
477
478         // send a dataset change event to self...
479
DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
480         datasetChanged(event);
481     }
482     
483     /**
484      * Returns the pie index (this is used by the {@link MultiplePiePlot} class
485      * to track subplots).
486      *
487      * @return The pie index.
488      */

489     public int getPieIndex() {
490         return this.pieIndex;
491     }
492     
493     /**
494      * Sets the pie index (this is used by the {@link MultiplePiePlot} class to
495      * track subplots).
496      *
497      * @param index the index.
498      */

499     public void setPieIndex(int index) {
500         this.pieIndex = index;
501     }
502     
503     /**
504      * Returns the start angle for the first pie section. This is measured in
505      * degrees starting from 3 o'clock and measuring anti-clockwise.
506      *
507      * @return The start angle.
508      */

509     public double getStartAngle() {
510         return this.startAngle;
511     }
512
513     /**
514      * Sets the starting angle and sends a {@link PlotChangeEvent} to all
515      * registered listeners. The initial default value is 90 degrees, which
516      * corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock...
517      * this is the encoding used by Java's Arc2D class.
518      *
519      * @param angle the angle (in degrees).
520      */

521     public void setStartAngle(double angle) {
522         this.startAngle = angle;
523         notifyListeners(new PlotChangeEvent(this));
524     }
525
526     /**
527      * Returns the direction in which the pie sections are drawn (clockwise or
528      * anti-clockwise).
529      *
530      * @return The direction (never <code>null</code>).
531      */

532     public Rotation getDirection() {
533         return this.direction;
534     }
535
536     /**
537      * Sets the direction in which the pie sections are drawn and sends a
538      * {@link PlotChangeEvent} to all registered listeners.
539      *
540      * @param direction the direction (<code>null</code> not permitted).
541      */

542     public void setDirection(Rotation direction) {
543         if (direction == null) {
544             throw new IllegalArgumentException JavaDoc("Null 'direction' argument.");
545         }
546         this.direction = direction;
547         notifyListeners(new PlotChangeEvent(this));
548
549     }
550
551     /**
552      * Returns the interior gap, measured as a percentage of the available
553      * drawing space.
554      *
555      * @return The gap (as a percentage of the available drawing space).
556      */

557     public double getInteriorGap() {
558         return this.interiorGap;
559     }
560
561     /**
562      * Sets the interior gap and sends a {@link PlotChangeEvent} to all
563      * registered listeners. This controls the space between the edges of the
564      * pie plot and the plot area itself (the region where the section labels
565      * appear).
566      *
567      * @param percent the gap (as a percentage of the available drawing space).
568      */

569     public void setInteriorGap(double percent) {
570
571         // check arguments...
572
if ((percent < 0.0) || (percent > MAX_INTERIOR_GAP)) {
573             throw new IllegalArgumentException JavaDoc(
574                 "Invalid 'percent' (" + percent + ") argument.");
575         }
576
577         // make the change...
578
if (this.interiorGap != percent) {
579             this.interiorGap = percent;
580             notifyListeners(new PlotChangeEvent(this));
581         }
582
583     }
584
585     /**
586      * Returns a flag indicating whether the pie chart is circular, or
587      * stretched into an elliptical shape.
588      *
589      * @return A flag indicating whether the pie chart is circular.
590      */

591     public boolean isCircular() {
592         return this.circular;
593     }
594
595     /**
596      * A flag indicating whether the pie chart is circular, or stretched into
597      * an elliptical shape.
598      *
599      * @param flag the new value.
600      */

601     public void setCircular(boolean flag) {
602         setCircular(flag, true);
603     }
604
605     /**
606      * Sets the circular attribute and, if requested, sends a
607      * {@link PlotChangeEvent} to all registered listeners.
608      *
609      * @param circular the new value of the flag.
610      * @param notify notify listeners?
611      */

612     public void setCircular(boolean circular, boolean notify) {
613         this.circular = circular;
614         if (notify) {
615             notifyListeners(new PlotChangeEvent(this));
616         }
617     }
618
619     /**
620      * Returns the flag that controls whether <code>null</code> values in the
621      * dataset are ignored.
622      *
623      * @return A boolean.
624      */

625     public boolean getIgnoreNullValues() {
626         return this.ignoreNullValues;
627     }
628     
629     /**
630      * Sets a flag that controls whether <code>null</code> values are ignored,
631      * and sends a {@link PlotChangeEvent} to all registered listeners. At
632      * present, this only affects whether or not the key is presented in the
633      * legend.
634      *
635      * @param flag the flag.
636      */

637     public void setIgnoreNullValues(boolean flag) {
638         this.ignoreNullValues = flag;
639         notifyListeners(new PlotChangeEvent(this));
640     }
641     
642     /**
643      * Returns the flag that controls whether zero values in the
644      * dataset are ignored.
645      *
646      * @return A boolean.
647      */

648     public boolean getIgnoreZeroValues() {
649         return this.ignoreZeroValues;
650     }
651     
652     /**
653      * Sets a flag that controls whether zero values are ignored,
654      * and sends a {@link PlotChangeEvent} to all registered listeners. This
655      * only affects whether or not a label appears for the non-visible
656      * pie section.
657      *
658      * @param flag the flag.
659      */

660     public void setIgnoreZeroValues(boolean flag) {
661         this.ignoreZeroValues = flag;
662         notifyListeners(new PlotChangeEvent(this));
663     }
664     
665     //// SECTION PAINT ////////////////////////////////////////////////////////
666

667     /**
668      * Returns the paint for ALL sections in the plot.
669      *
670      * @return The paint (possibly <code>null</code>).
671      */

672     public Paint JavaDoc getSectionPaint() {
673         return this.sectionPaint;
674     }
675
676     /**
677      * Sets the paint for ALL sections in the plot. If this is set to
678      * </code>null</code>, then a list of paints is used instead (to allow
679      * different colors to be used for each section).
680      *
681      * @param paint the paint (<code>null</code> permitted).
682      */

683     public void setSectionPaint(Paint JavaDoc paint) {
684         this.sectionPaint = paint;
685         notifyListeners(new PlotChangeEvent(this));
686     }
687
688     /**
689      * Returns the paint for the specified section.
690      *
691      * @param section the section index (zero-based).
692      *
693      * @return The paint (never <code>null</code>).
694      */

695     public Paint JavaDoc getSectionPaint(int section) {
696         
697         // return the override, if there is one...
698
if (this.sectionPaint != null) {
699             return this.sectionPaint;
700         }
701
702         // otherwise look up the paint list
703
Paint JavaDoc result = this.sectionPaintList.getPaint(section);
704         if (result == null) {
705             DrawingSupplier supplier = getDrawingSupplier();
706             if (supplier != null) {
707                 Paint JavaDoc p = supplier.getNextPaint();
708                 this.sectionPaintList.setPaint(section, p);
709                 result = p;
710             }
711             else {
712                 result = this.baseSectionPaint;
713             }
714         }
715         return result;
716        
717     }
718     
719     /**
720      * Sets the paint used to fill a section of the pie and sends a
721      * {@link PlotChangeEvent} to all registered listeners.
722      *
723      * @param section the section index (zero-based).
724      * @param paint the paint (<code>null</code> permitted).
725      */

726     public void setSectionPaint(int section, Paint JavaDoc paint) {
727         this.sectionPaintList.setPaint(section, paint);
728         notifyListeners(new PlotChangeEvent(this));
729     }
730     
731     /**
732      * Returns the base section paint. This is used when no other paint is
733      * available.
734      *
735      * @return The paint (never <code>null</code>).
736      */

737     public Paint JavaDoc getBaseSectionPaint() {
738         return this.baseSectionPaint;
739     }
740     
741     /**
742      * Sets the base section paint.
743      *
744      * @param paint the paint (<code>null</code> not permitted).
745      */

746     public void setBaseSectionPaint(Paint JavaDoc paint) {
747         if (paint == null) {
748             throw new IllegalArgumentException JavaDoc("Null 'paint' argument.");
749         }
750         this.baseSectionPaint = paint;
751         notifyListeners(new PlotChangeEvent(this));
752     }
753     
754     //// SECTION OUTLINE PAINT ////////////////////////////////////////////////
755

756     /**
757      * Returns the outline paint for ALL sections in the plot.
758      *
759      * @return The paint (possibly <code>null</code>).
760      */

761     public Paint JavaDoc getSectionOutlinePaint() {
762         return this.sectionOutlinePaint;
763     }
764
765     /**
766      * Sets the outline paint for ALL sections in the plot. If this is set to
767      * </code>null</code>, then a list of paints is used instead (to allow
768      * different colors to be used for each section).
769      *
770      * @param paint the paint (<code>null</code> permitted).
771      */

772     public void setSectionOutlinePaint(Paint JavaDoc paint) {
773         this.sectionOutlinePaint = paint;
774         notifyListeners(new PlotChangeEvent(this));
775     }
776
777     /**
778      * Returns the paint for the specified section.
779      *
780      * @param section the section index (zero-based).
781      *
782      * @return The paint (never <code>null</code>).
783      */

784     public Paint JavaDoc getSectionOutlinePaint(int section) {
785         
786         // return the override, if there is one...
787
if (this.sectionOutlinePaint != null) {
788             return this.sectionOutlinePaint;
789         }
790
791         // otherwise look up the paint list
792
Paint JavaDoc result = this.sectionOutlinePaintList.getPaint(section);
793         if (result == null) {
794             result = this.baseSectionOutlinePaint;
795         }
796         return result;
797        
798     }
799     
800     /**
801      * Sets the paint used to fill a section of the pie and sends a
802      * {@link PlotChangeEvent} to all registered listeners.
803      *
804      * @param section the section index (zero-based).
805      * @param paint the paint (<code>null</code> permitted).
806      */

807     public void setSectionOutlinePaint(int section, Paint JavaDoc paint) {
808         this.sectionOutlinePaintList.setPaint(section, paint);
809         notifyListeners(new PlotChangeEvent(this));
810     }
811     
812     /**
813      * Returns the base section paint. This is used when no other paint is
814      * available.
815      *
816      * @return The paint (never <code>null</code>).
817      */

818     public Paint JavaDoc getBaseSectionOutlinePaint() {
819         return this.baseSectionOutlinePaint;
820     }
821     
822     /**
823      * Sets the base section paint.
824      *
825      * @param paint the paint (<code>null</code> not permitted).
826      */

827     public void setBaseSectionOutlinePaint(Paint JavaDoc paint) {
828         if (paint == null) {
829             throw new IllegalArgumentException JavaDoc("Null 'paint' argument.");
830         }
831         this.baseSectionOutlinePaint = paint;
832         notifyListeners(new PlotChangeEvent(this));
833     }
834     
835     //// SECTION OUTLINE STROKE ///////////////////////////////////////////////
836

837     /**
838      * Returns the outline stroke for ALL sections in the plot.
839      *
840      * @return The stroke (possibly <code>null</code>).
841      */

842     public Stroke JavaDoc getSectionOutlineStroke() {
843         return this.sectionOutlineStroke;
844     }
845
846     /**
847      * Sets the outline stroke for ALL sections in the plot. If this is set to
848      * </code>null</code>, then a list of paints is used instead (to allow
849      * different colors to be used for each section).
850      *
851      * @param stroke the stroke (<code>null</code> permitted).
852      */

853     public void setSectionOutlineStroke(Stroke JavaDoc stroke) {
854         this.sectionOutlineStroke = stroke;
855         notifyListeners(new PlotChangeEvent(this));
856     }
857
858     /**
859      * Returns the stroke for the specified section.
860      *
861      * @param section the section index (zero-based).
862      *
863      * @return The stroke (never <code>null</code>).
864      */

865     public Stroke JavaDoc getSectionOutlineStroke(int section) {
866         
867         // return the override, if there is one...
868
if (this.sectionOutlineStroke != null) {
869             return this.sectionOutlineStroke;
870         }
871
872         // otherwise look up the paint list
873
Stroke JavaDoc result = this.sectionOutlineStrokeList.getStroke(section);
874         if (result == null) {
875             result = this.baseSectionOutlineStroke;
876         }
877         return result;
878        
879     }
880     
881     /**
882      * Sets the stroke used to fill a section of the pie and sends a
883      * {@link PlotChangeEvent} to all registered listeners.
884      *
885      * @param section the section index (zero-based).
886      * @param stroke the stroke (<code>null</code> permitted).
887      */

888     public void setSectionOutlineStroke(int section, Stroke JavaDoc stroke) {
889         this.sectionOutlineStrokeList.setStroke(section, stroke);
890         notifyListeners(new PlotChangeEvent(this));
891     }
892     
893     /**
894      * Returns the base section stroke. This is used when no other stroke is
895      * available.
896      *
897      * @return The stroke (never <code>null</code>).
898      */

899     public Stroke JavaDoc getBaseSectionOutlineStroke() {
900         return this.baseSectionOutlineStroke;
901     }
902     
903     /**
904      * Sets the base section stroke.
905      *
906      * @param stroke the stroke (<code>null</code> not permitted).
907      */

908     public void setBaseSectionOutlineStroke(Stroke JavaDoc stroke) {
909         if (stroke == null) {
910             throw new IllegalArgumentException JavaDoc("Null 'stroke' argument.");
911         }
912         this.baseSectionOutlineStroke = stroke;
913         notifyListeners(new PlotChangeEvent(this));
914     }
915
916     /**
917      * Returns the shadow paint.
918      *
919      * @return The paint (possibly <code>null</code>).
920      */

921     public Paint JavaDoc getShadowPaint() {
922         return this.shadowPaint;
923     }
924     
925     /**
926      * Sets the shadow paint and sends a {@link PlotChangeEvent} to all
927      * registered listeners.
928      *
929      * @param paint the paint (<code>null</code> permitted).
930      */

931     public void setShadowPaint(Paint JavaDoc paint) {
932         this.shadowPaint = paint;
933         notifyListeners(new