KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > renderer > AbstractRenderer


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  * AbstractRenderer.java
28  * ---------------------
29  * (C) Copyright 2002-2005, by Object Refinery Limited.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): Nicolas Brodu;
33  *
34  * $Id: AbstractRenderer.java,v 1.22 2005/06/01 09:35:54 mungady Exp $
35  *
36  * Changes:
37  * --------
38  * 22-Aug-2002 : Version 1, draws code out of AbstractXYItemRenderer to share
39  * with AbstractCategoryItemRenderer (DG);
40  * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG);
41  * 06-Nov-2002 : Moved to the com.jrefinery.chart.renderer package (DG);
42  * 21-Nov-2002 : Added a paint table for the renderer to use (DG);
43  * 17-Jan-2003 : Moved plot classes into a separate package (DG);
44  * 25-Mar-2003 : Implemented Serializable (DG);
45  * 29-Apr-2003 : Added valueLabelFont and valueLabelPaint attributes, based on
46  * code from Arnaud Lelievre (DG);
47  * 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG);
48  * 13-Aug-2003 : Implemented Cloneable (DG);
49  * 15-Sep-2003 : Fixed serialization (NB);
50  * 17-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG);
51  * 07-Oct-2003 : Moved PlotRenderingInfo into RendererState to allow for
52  * multiple threads using a single renderer (DG);
53  * 20-Oct-2003 : Added missing setOutlinePaint() method (DG);
54  * 23-Oct-2003 : Split item label attributes into 'positive' and 'negative'
55  * values (DG);
56  * 26-Nov-2003 : Added methods to get the positive and negative item label
57  * positions (DG);
58  * 01-Mar-2004 : Modified readObject() method to prevent null pointer exceptions
59  * after deserialization (DG);
60  * 19-Jul-2004 : Fixed bug in getItemLabelFont(int, int) method (DG);
61  * 04-Oct-2004 : Updated equals() method, eliminated use of NumberUtils,
62  * renamed BooleanUtils --> BooleanUtilities, ShapeUtils -->
63  * ShapeUtilities (DG);
64  * 15-Mar-2005 : Fixed serialization of baseFillPaint (DG);
65  * 16-May-2005 : Base outline stroke should never be null (DG);
66  * 01-Jun-2005 : Added hasListener() method for unit testing (DG);
67  *
68  */

69
70 package org.jfree.chart.renderer;
71
72 import java.awt.BasicStroke JavaDoc;
73 import java.awt.Color JavaDoc;
74 import java.awt.Font JavaDoc;
75 import java.awt.Paint JavaDoc;
76 import java.awt.Shape JavaDoc;
77 import java.awt.Stroke JavaDoc;
78 import java.awt.geom.Point2D JavaDoc;
79 import java.awt.geom.Rectangle2D JavaDoc;
80 import java.io.IOException JavaDoc;
81 import java.io.ObjectInputStream JavaDoc;
82 import java.io.ObjectOutputStream JavaDoc;
83 import java.io.Serializable JavaDoc;
84 import java.util.Arrays JavaDoc;
85 import java.util.EventListener JavaDoc;
86 import java.util.List JavaDoc;
87
88 import javax.swing.event.EventListenerList JavaDoc;
89
90 import org.jfree.chart.event.RendererChangeEvent;
91 import org.jfree.chart.event.RendererChangeListener;
92 import org.jfree.chart.labels.ItemLabelAnchor;
93 import org.jfree.chart.labels.ItemLabelPosition;
94 import org.jfree.chart.plot.DrawingSupplier;
95 import org.jfree.chart.plot.PlotOrientation;
96 import org.jfree.io.SerialUtilities;
97 import org.jfree.ui.TextAnchor;
98 import org.jfree.util.BooleanList;
99 import org.jfree.util.BooleanUtilities;
100 import org.jfree.util.ObjectList;
101 import org.jfree.util.ObjectUtilities;
102 import org.jfree.util.PaintList;
103 import org.jfree.util.ShapeList;
104 import org.jfree.util.ShapeUtilities;
105 import org.jfree.util.StrokeList;
106
107 /**
108  * Base class providing common services for renderers. Most methods that update
109  * attributes of the renderer will fire a {@link RendererChangeEvent}, which
110  * normally means the plot that owns the renderer will receive notification that
111  * the renderer has been changed (the plot will, in turn, notify the chart).
112  */

113 public abstract class AbstractRenderer implements Cloneable JavaDoc, Serializable JavaDoc {
114
115     /** For serialization. */
116     private static final long serialVersionUID = -828267569428206075L;
117     
118     /** A useful constant. */
119     public static final Double JavaDoc ZERO = new Double JavaDoc(0.0);
120     
121     /** The default paint. */
122     public static final Paint JavaDoc DEFAULT_PAINT = Color.blue;
123
124     /** The default outline paint. */
125     public static final Paint JavaDoc DEFAULT_OUTLINE_PAINT = Color.gray;
126
127     /** The default stroke. */
128     public static final Stroke JavaDoc DEFAULT_STROKE = new BasicStroke JavaDoc(1.0f);
129
130     /** The default outline stroke. */
131     public static final Stroke JavaDoc DEFAULT_OUTLINE_STROKE = new BasicStroke JavaDoc(1.0f);
132
133     /** The default shape. */
134     public static final Shape JavaDoc DEFAULT_SHAPE
135         = new Rectangle2D.Double JavaDoc(-3.0, -3.0, 6.0, 6.0);
136
137     /** The default value label font. */
138     public static final Font JavaDoc DEFAULT_VALUE_LABEL_FONT
139         = new Font JavaDoc("SansSerif", Font.PLAIN, 10);
140
141     /** The default value label paint. */
142     public static final Paint JavaDoc DEFAULT_VALUE_LABEL_PAINT = Color.black;
143
144     /** A flag that controls the visibility of ALL series. */
145     private Boolean JavaDoc seriesVisible;
146     
147     /** A list of flags that controls whether or not each series is visible. */
148     private BooleanList seriesVisibleList;
149
150     /** The default visibility for each series. */
151     private boolean baseSeriesVisible;
152     
153     /** A flag that controls the visibility of ALL series in the legend. */
154     private Boolean JavaDoc seriesVisibleInLegend;
155     
156     /**
157      * A list of flags that controls whether or not each series is visible in
158      * the legend.
159      */

160     private BooleanList seriesVisibleInLegendList;
161
162     /** The default visibility for each series in the legend. */
163     private boolean baseSeriesVisibleInLegend;
164         
165     /** The paint for ALL series (optional). */
166     private transient Paint JavaDoc paint;
167
168     /** The paint list. */
169     private PaintList paintList;
170
171     /** The base paint. */
172     private transient Paint JavaDoc basePaint;
173
174     /** The fill paint for ALL series (optional). */
175     private transient Paint JavaDoc fillPaint;
176
177     /** The fill paint list. */
178     private PaintList fillPaintList;
179
180     /** The base fill paint. */
181     private transient Paint JavaDoc baseFillPaint;
182
183     /** The outline paint for ALL series (optional). */
184     private transient Paint JavaDoc outlinePaint;
185
186     /** The outline paint list. */
187     private PaintList outlinePaintList;
188
189     /** The base outline paint. */
190     private transient Paint JavaDoc baseOutlinePaint;
191
192     /** The stroke for ALL series (optional). */
193     private transient Stroke JavaDoc stroke;
194
195     /** The stroke list. */
196     private StrokeList strokeList;
197
198     /** The base stroke. */
199     private transient Stroke JavaDoc baseStroke;
200
201     /** The outline stroke for ALL series (optional). */
202     private transient Stroke JavaDoc outlineStroke;
203
204     /** The outline stroke list. */
205     private StrokeList outlineStrokeList;
206
207     /** The base outline stroke. */
208     private transient Stroke JavaDoc baseOutlineStroke;
209
210     /** The shape for ALL series (optional). */
211     private transient Shape JavaDoc shape;
212
213     /** A shape list. */
214     private ShapeList shapeList;
215
216     /** The base shape. */
217     private transient Shape JavaDoc baseShape;
218
219     /** Visibility of the item labels for ALL series (optional). */
220     private Boolean JavaDoc itemLabelsVisible;
221
222     /** Visibility of the item labels PER series. */
223     private BooleanList itemLabelsVisibleList;
224
225     /** The base item labels visible. */
226     private Boolean JavaDoc baseItemLabelsVisible;
227
228     /** The item label font for ALL series (optional). */
229     private Font JavaDoc itemLabelFont;
230
231     /** The item label font list (one font per series). */
232     private ObjectList itemLabelFontList;
233
234     /** The base item label font. */
235     private Font JavaDoc baseItemLabelFont;
236
237     /** The item label paint for ALL series. */
238     private transient Paint JavaDoc itemLabelPaint;
239
240     /** The item label paint list (one paint per series). */
241     private PaintList itemLabelPaintList;
242
243     /** The base item label paint. */
244     private transient Paint JavaDoc baseItemLabelPaint;
245
246     /** The positive item label position for ALL series (optional). */
247     private ItemLabelPosition positiveItemLabelPosition;
248     
249     /** The positive item label position (per series). */
250     private ObjectList positiveItemLabelPositionList;
251     
252     /** The fallback positive item label position. */
253     private ItemLabelPosition basePositiveItemLabelPosition;
254     
255     /** The negative item label position for ALL series (optional). */
256     private ItemLabelPosition negativeItemLabelPosition;
257     
258     /** The negative item label position (per series). */
259     private ObjectList negativeItemLabelPositionList;
260     
261     /** The fallback negative item label position. */
262     private ItemLabelPosition baseNegativeItemLabelPosition;
263
264     /** The item label anchor offset. */
265     private double itemLabelAnchorOffset = 2.0;
266
267     /**
268      * A flag that controls whether or not entities are generated for
269      * ALL series (optional).
270      */

271     private Boolean JavaDoc createEntities;
272
273     /**
274      * Flags that control whether or not entities are generated for each
275      * series. This will be overridden by 'createEntities'.
276      */

277     private BooleanList createEntitiesList;
278
279     /**
280      * The default flag that controls whether or not entities are generated.
281      * This flag is used when both the above flags return null.
282      */

283     private boolean baseCreateEntities;
284     
285     /** Storage for registered change listeners. */
286     private transient EventListenerList JavaDoc listenerList;
287
288     /**
289      * Default constructor.
290      */

291     public AbstractRenderer() {
292
293         this.seriesVisible = null;
294         this.seriesVisibleList = new BooleanList();
295         this.baseSeriesVisible = true;
296         
297         this.seriesVisibleInLegend = null;
298         this.seriesVisibleInLegendList = new BooleanList();
299         this.baseSeriesVisibleInLegend = true;
300
301         this.paint = null;
302         this.paintList = new PaintList();
303         this.basePaint = DEFAULT_PAINT;
304
305         this.fillPaint = null;
306         this.fillPaintList = new PaintList();
307         this.baseFillPaint = Color.white;
308
309         this.outlinePaint = null;
310         this.outlinePaintList = new PaintList();
311         this.baseOutlinePaint = DEFAULT_OUTLINE_PAINT;
312
313         this.stroke = null;
314         this.strokeList = new StrokeList();
315         this.baseStroke = DEFAULT_STROKE;
316
317         this.outlineStroke = null;
318         this.outlineStrokeList = new StrokeList();
319         this.baseOutlineStroke = DEFAULT_OUTLINE_STROKE;
320
321         this.shape = null;
322         this.shapeList = new ShapeList();
323         this.baseShape = DEFAULT_SHAPE;
324
325         this.itemLabelsVisible = null;
326         this.itemLabelsVisibleList = new BooleanList();
327         this.baseItemLabelsVisible = Boolean.FALSE;
328
329         this.itemLabelFont = null;
330         this.itemLabelFontList = new ObjectList();
331         this.baseItemLabelFont = new Font JavaDoc("SansSerif", Font.PLAIN, 10);
332
333         this.itemLabelPaint = null;
334         this.itemLabelPaintList = new PaintList();
335         this.baseItemLabelPaint = Color.black;
336
337         this.positiveItemLabelPosition = null;
338         this.positiveItemLabelPositionList = new ObjectList();
339         this.basePositiveItemLabelPosition = new ItemLabelPosition(
340             ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER
341         );
342         
343         this.negativeItemLabelPosition = null;
344         this.negativeItemLabelPositionList = new ObjectList();
345         this.baseNegativeItemLabelPosition = new ItemLabelPosition(
346             ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER
347         );
348
349         this.createEntities = null;
350         this.createEntitiesList = new BooleanList();
351         this.baseCreateEntities = true;
352         
353         this.listenerList = new EventListenerList JavaDoc();
354
355     }
356
357     /**
358      * Returns the drawing supplier from the plot.
359      *
360      * @return The drawing supplier.
361      */

362     public abstract DrawingSupplier getDrawingSupplier();
363     
364     // SERIES VISIBLE (not yet respected by all renderers)
365

366     /**
367      * Returns a boolean that indicates whether or not the specified item
368      * should be drawn (this is typically used to hide an entire series).
369      *
370      * @param series the series index.
371      * @param item the item index.
372      *
373      * @return A boolean.
374      */

375     public boolean getItemVisible(int series, int item) {
376         return isSeriesVisible(series);
377     }
378     
379     /**
380      * Returns a boolean that indicates whether or not the specified series
381      * should be drawn.
382      *
383      * @param series the series index.
384      *
385      * @return A boolean.
386      */

387     public boolean isSeriesVisible(int series) {
388
389         boolean result = this.baseSeriesVisible;
390         if (this.seriesVisible != null) {
391             result = this.seriesVisible.booleanValue();
392         }
393         else {
394             Boolean JavaDoc b = this.seriesVisibleList.getBoolean(series);
395             if (b != null) {
396                 result = b.booleanValue();
397             }
398         }
399         return result;
400     }
401     
402     /**
403      * Returns the flag that controls the visibility of ALL series. This flag
404      * overrides the per series and default settings - you must set it to
405      * <code>null</code> if you want the other settings to apply.
406      *
407      * @return The flag (possibly <code>null</code>).
408      */

409     public Boolean JavaDoc getSeriesVisible() {
410         return this.seriesVisible;
411     }
412     
413     /**
414      * Sets the flag that controls the visibility of ALL series and sends a
415      * {@link RendererChangeEvent} to all registered listeners. This flag
416      * overrides the per series and default settings - you must set it to
417      * <code>null</code> if you want the other settings to apply.
418      *
419      * @param visible the flag (<code>null</code> permitted).
420      */

421     public void setSeriesVisible(Boolean JavaDoc visible) {
422          setSeriesVisible(visible, true);
423     }
424     
425     /**
426      * Sets the flag that controls the visibility of ALL series and sends a
427      * {@link RendererChangeEvent} to all registered listeners. This flag
428      * overrides the per series and default settings - you must set it to
429      * <code>null</code> if you want the other settings to apply.
430      *
431      * @param visible the flag (<code>null</code> permitted).
432      * @param notify notify listeners?
433      */

434     public void setSeriesVisible(Boolean JavaDoc visible, boolean notify) {
435         this.seriesVisible = visible;
436         if (notify) {
437             notifyListeners(new RendererChangeEvent(this));
438         }
439     }
440     
441     /**
442      * Returns the flag that controls whether a series is visible.
443      *
444      * @param series the series index (zero-based).
445      *
446      * @return The flag (possibly <code>null</code>).
447      */

448     public Boolean JavaDoc getSeriesVisible(int series) {
449         return this.seriesVisibleList.getBoolean(series);
450     }
451     
452     /**
453      * Sets the flag that controls whether a series is visible and sends a
454      * {@link RendererChangeEvent} to all registered listeners.
455      *
456      * @param series the series index (zero-based).
457      * @param visible the flag (<code>null</code> permitted).
458      */

459     public void setSeriesVisible(int series, Boolean JavaDoc visible) {
460         setSeriesVisible(series, visible, true);
461     }
462     
463     /**
464      * Sets the flag that controls whether a series is visible and, if
465      * requested, sends a {@link RendererChangeEvent} to all registered
466      * listeners.
467      *
468      * @param series the series index.
469      * @param visible the flag (<code>null</code> permitted).
470      * @param notify notify listeners?
471      */

472     public void setSeriesVisible(int series, Boolean JavaDoc visible, boolean notify) {
473         this.seriesVisibleList.setBoolean(series, visible);
474         if (notify) {
475             notifyListeners(new RendererChangeEvent(this));
476         }
477     }
478
479     /**
480      * Returns the base visibility for all series.
481      *
482      * @return The base visibility.
483      */

484     public boolean getBaseSeriesVisible() {
485         return this.baseSeriesVisible;
486     }
487
488     /**
489      * Sets the base visibility and sends a {@link RendererChangeEvent}
490      * to all registered listeners.
491      *
492      * @param visible the flag.
493      */

494     public void setBaseSeriesVisible(boolean visible) {
495         // defer argument checking...
496
setBaseSeriesVisible(visible, true);
497     }
498     
499     /**
500      * Sets the base visibility and, if requested, sends
501      * a {@link RendererChangeEvent} to all registered listeners.
502      *
503      * @param visible the visibility.
504      * @param notify notify listeners?
505      */

506     public void setBaseSeriesVisible(boolean visible, boolean notify) {
507         this.baseSeriesVisible = visible;
508         if (notify) {
509             notifyListeners(new RendererChangeEvent(this));
510         }
511     }
512
513     // SERIES VISIBLE IN LEGEND (not yet respected by all renderers)
514

515     /**
516      * Returns <code>true</code> if the series should be shown in the legend,
517      * and <code>false</code> otherwise.
518      *
519      * @param series the series index.
520      *
521      * @return A boolean.
522      */

523     public boolean isSeriesVisibleInLegend(int series) {
524         boolean result = this.baseSeriesVisibleInLegend;
525         if (this.seriesVisibleInLegend != null) {
526             result = this.seriesVisibleInLegend.booleanValue();
527         }
528         else {
529             Boolean JavaDoc b = this.seriesVisibleInLegendList.getBoolean(series);
530             if (b != null) {
531                 result = b.booleanValue();
532             }
533         }
534         return result;
535     }
536     
537     /**
538      * Returns the flag that controls the visibility of ALL series in the
539      * legend. This flag overrides the per series and default settings - you
540      * must set it to <code>null</code> if you want the other settings to
541      * apply.
542      *
543      * @return The flag (possibly <code>null</code>).
544      */

545     public Boolean JavaDoc getSeriesVisibleInLegend() {
546         return this.seriesVisibleInLegend;
547     }
548     
549     /**
550      * Sets the flag that controls the visibility of ALL series in the legend
551      * and sends a {@link RendererChangeEvent} to all registered listeners.
552      * This flag overrides the per series and default settings - you must set
553      * it to <code>null</code> if you want the other settings to apply.
554      *
555      * @param visible the flag (<code>null</code> permitted).
556      */

557     public void setSeriesVisibleInLegend(Boolean JavaDoc visible) {
558          setSeriesVisibleInLegend(visible, true);
559     }
560     
561     /**
562      * Sets the flag that controls the visibility of ALL series in the legend
563      * and sends a {@link RendererChangeEvent} to all registered listeners.
564      * This flag overrides the per series and default settings - you must set
565      * it to <code>null</code> if you want the other settings to apply.
566      *
567      * @param visible the flag (<code>null</code> permitted).
568      * @param notify notify listeners?
569      */

570     public void setSeriesVisibleInLegend(Boolean JavaDoc visible, boolean notify) {
571         this.seriesVisibleInLegend = visible;
572         if (notify) {
573             notifyListeners(new RendererChangeEvent(this));
574         }
575     }
576     
577     /**
578      * Returns the flag that controls whether a series is visible in the
579      * legend. This method returns only the "per series" settings - to
580      * incorporate the override and base settings as well, you need to use the
581      * {@link #isSeriesVisibleInLegend(int)} method.
582      *
583      * @param series the series index (zero-based).
584      *
585      * @return The flag (possibly <code>null</code>).
586      */

587     public Boolean JavaDoc getSeriesVisibleInLegend(int series) {
588         return this.seriesVisibleInLegendList.getBoolean(series);
589     }
590     
591     /**
592      * Sets the flag that controls whether a series is visible in the legend
593      * and sends a {@link RendererChangeEvent} to all registered listeners.
594      *
595      * @param series the series index (zero-based).
596      * @param visible the flag (<code>null</code> permitted).
597      */

598     public void setSeriesVisibleInLegend(int series, Boolean JavaDoc visible) {
599         setSeriesVisibleInLegend(series, visible, true);
600     }
601     
602     /**
603      * Sets the flag that controls whether a series is visible in the legend
604      * and, if requested, sends a {@link RendererChangeEvent} to all registered
605      * listeners.
606      *
607      * @param series the series index.
608      * @param visible the flag (<code>null</code> permitted).
609      * @param notify notify listeners?
610      */

611     public void setSeriesVisibleInLegend(int series, Boolean JavaDoc visible,
612                                          boolean notify) {
613         this.seriesVisibleInLegendList.setBoolean(series, visible);
614         if (notify) {
615             notifyListeners(new RendererChangeEvent(this));
616         }
617     }
618
619     /**
620      * Returns the base visibility in the legend for all series.
621      *
622      * @return The base visibility.
623      */

624     public boolean getBaseSeriesVisibleInLegend() {
625         return this.baseSeriesVisibleInLegend;
626     }
627
628     /**
629      * Sets the base visibility in the legend and sends a
630      * {@link RendererChangeEvent} to all registered listeners.
631      *
632      * @param visible the flag.
633      */

634     public void setBaseSeriesVisibleInLegend(boolean visible) {
635         // defer argument checking...
636
setBaseSeriesVisibleInLegend(visible, true);
637     }
638     
639     /**
640      * Sets the base visibility in the legend and, if requested, sends
641      * a {@link RendererChangeEvent} to all registered listeners.
642      *
643      * @param visible the visibility.
644      * @param notify notify listeners?
645      */

646     public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify) {
647         this.baseSeriesVisibleInLegend = visible;
648         if (notify) {
649             notifyListeners(new RendererChangeEvent(this));
650         }
651     }
652
653     // PAINT
654

655     /**
656      * Returns the paint used to fill data items as they are drawn.
657      * <p>
658      * The default implementation passes control to the
659      * <code>getSeriesPaint</code> method. You can override this method if you
660      * require different behaviour.
661      *
662      * @param row the row (or series) index (zero-based).
663      * @param column the column (or category) index (zero-based).
664      *
665      * @return The paint (never <code>null</code>).
666      */

667     public Paint JavaDoc getItemPaint(int row, int column) {
668         return getSeriesPaint(row);
669     }
670
671     /**
672      * Returns the paint used to fill an item drawn by the renderer.
673      *
674      * @param series the series index (zero-based).
675      *
676      * @return The paint (never <code>null</code>).
677      */

678     public Paint JavaDoc getSeriesPaint(int series) {
679
680         // return the override, if there is one...
681
if (this.paint != null) {
682             return this.paint;
683         }
684
685         // otherwise look up the paint list
686
Paint JavaDoc seriesPaint = this.paintList.getPaint(series);
687         if (seriesPaint == null) {
688             DrawingSupplier supplier = getDrawingSupplier();
689             if (supplier != null) {
690                 seriesPaint = supplier.getNextPaint();
691                 this.paintList.setPaint(series, seriesPaint);
692             }
693             else {
694                 seriesPaint = this.basePaint;
695             }
696         }
697         return seriesPaint;
698
699     }
700
701     /**
702      * Sets the paint to be used for ALL series, and sends a
703      * {@link RendererChangeEvent} to all registered listeners. If this is
704      * <code>null</code>, the renderer will use the paint for the series.
705      *
706      * @param paint the paint (<code>null</code> permitted).
707      */

708     public void setPaint(Paint JavaDoc paint) {
709         setPaint(paint, true);
710     }
711     
712     /**
713      * Sets the paint to be used for all series and, if requested, sends a
714      * {@link RendererChangeEvent} to all registered listeners.
715      *
716      * @param paint the paint (<code>null</code> permitted).
717      * @param notify notify listeners?
718      */

719     public void setPaint(Paint JavaDoc paint, boolean notify) {
720         this.paint = paint;
721         if (notify) {
722             notifyListeners(new RendererChangeEvent(this));
723         }
724     }
725     
726     /**
727      * Sets the paint used for a series and sends a {@link RendererChangeEvent}
728      * to all registered listeners.
729      *
730      * @param series the series index (zero-based).
731      * @param paint the paint (<code>null</code> permitted).
732      */

733     public void setSeriesPaint(int series, Paint JavaDoc paint) {
734         setSeriesPaint(series, paint, true);
735     }
736     
737     /**
738      * Sets the paint used for a series and, if requested, sends a
739      * {@link RendererChangeEvent} to all registered listeners.
740      *
741      * @param series the series index.
742      * @param paint the paint (<code>null</code> permitted).
743      * @param notify notify listeners?
744      */

745     public void setSeriesPaint(int series, Paint JavaDoc paint, boolean notify) {
746         this.paintList.setPaint(series, paint);
747         if (notify) {
748             notifyListeners(new RendererChangeEvent(this));
749         }
750     }
751
752     /**
753      * Returns the base paint.
754      *
755      * @return The base paint (never <code>null</code>).
756      */

757     public Paint JavaDoc getBasePaint() {
758         return this.basePaint;
759     }
760
761     /**
762      * Sets the base paint and sends a {@link RendererChangeEvent} to all
763      * registered listeners.
764      *
765      * @param paint the paint (<code>null</code> not permitted).
766      */

767     public void setBasePaint(Paint JavaDoc paint) {
768         // defer argument checking...
769
setBasePaint(paint, true);
770     }
771     
772     /**
773      * Sets the base paint and, if requested, sends a
774      * {@link RendererChangeEvent} to all registered listeners.
775      *
776      * @param paint the paint (<code>null</code> not permitted).
777      * @param notify notify listeners?
778      */

779     public void setBasePaint(Paint JavaDoc paint, boolean notify) {
780         this.basePaint = paint;
781         if (notify) {
782             notifyListeners(new RendererChangeEvent(this));
783         }
784     }
785
786     //// FILL PAINT //////////////////////////////////////////////////////////
787

788     /**
789      * Returns the paint used to fill data items as they are drawn. The
790      * default implementation passes control to the
791      * {@link #getSeriesFillPaint(int)} method - you can override this method
792      * if you require different behaviour.
793      *
794      * @param row the row (or series) index (zero-based).
795      * @param column the column (or category) index (zero-based).
796      *
797      * @return The paint (never <code>null</code>).
798      */

799     public Paint JavaDoc getItemFillPaint(int row, int column) {
800         return getSeriesFillPaint(row);
801     }
802
803     /**
804      * Returns the paint used to fill an item drawn by the renderer.
805      *
806      * @param series the series (zero-based index).
807      *
808      * @return The paint (never <code>null</code>).
809      */

810     public Paint JavaDoc getSeriesFillPaint(int series) {
811
812         // return the override, if there is one...
813
if (this.fillPaint != null) {
814             return this.fillPaint;
815         }
816
817         // otherwise look up the paint table
818
Paint JavaDoc seriesFillPaint = this.fillPaintList.getPaint(series);
819         if (seriesFillPaint == null) {
820             seriesFillPaint = this.baseFillPaint;
821         }
822         return seriesFillPaint;
823
824     }
825
826     /**
827      * Sets the paint used for a series fill and sends a
828      * {@link RendererChangeEvent} to all registered listeners.
829      *
830      * @param series the series index (zero-based).
831      * @param paint the paint (<code>null</code> permitted).
832      */

833     public void setSeriesFillPaint(int series, Paint JavaDoc paint) {
834         setSeriesFillPaint(series, paint, true);
835     }
836
837     /**
838      * Sets the paint used to fill a series and, if requested,
839      * sends a {@link RendererChangeEvent} to all registered listeners.
840      *
841      * @param series the series index (zero-based).
842      * @param paint the paint (<code>null</code> permitted).
843      * @param notify notify listeners?
844      */

845     public void setSeriesFillPaint(int series, Paint JavaDoc paint, boolean notify) {
846         this.fillPaintList.setPaint(series, paint);
847         if (notify) {
848             notifyListeners(new RendererChangeEvent(this));
849         }
850     }
851
852     /**
853      * Sets the fill paint for ALL series (optional).
854      *
855      * @param paint the paint (<code>null</code> permitted).
856      */

857     public void setFillPaint(Paint JavaDoc paint) {
858         setFillPaint(paint, true);
859     }
860
861     /**
862      * Sets the fill paint for ALL series and, if requested, sends a
863      * {@link RendererChangeEvent} to all registered listeners.
864      *
865      * @param paint the paint (<code>null</code> permitted).
866      * @param notify notify listeners?
867      */

868     public void setFillPaint(Paint JavaDoc paint, boolean notify) {
869         this.fillPaint = paint;
870         if (notify) {
871             notifyListeners(new RendererChangeEvent(this));
872         }
873     }
874     
875     /**
876      * Returns the base fill paint.
877      *
878      * @return The paint (never <code>null</code>).
879      */

880     public Paint JavaDoc getBaseFillPaint() {
881         return this.baseFillPaint;
882     }
883
884     /**
885      * Sets the base fill paint and sends a {@link RendererChangeEvent} to
886      * all registered listeners.
887      *
888      * @param paint the paint (<code>null</code> not permitted).
889      */

890     public void setBaseFillPaint(Paint JavaDoc paint) {
891         // defer argument checking...
892
setBaseFillPaint(paint, true);
893     }
894     
895     /**
896      * Sets the base fill paint and, if requested, sends a
897      * {@link RendererChangeEvent} to all registered listeners.
898      *
899      * @param paint the paint (<code>null</code> not permitted).
900      * @param notify notify listeners?
901      */

902     public void setBaseFillPaint(Paint JavaDoc paint, boolean notify) {
903         if (paint == null) {
904             throw new IllegalArgumentException JavaDoc("Null 'paint' argument.");
905         }
906         this.baseFillPaint = paint;
907         if (notify) {
908             notifyListeners(new RendererChangeEvent(this));
909         }
910     }
911
912     // OUTLINE PAINT //////////////////////////////////////////////////////////
913

914     /**
915      * Returns the paint used to outline data items as they are drawn.
916      * <p>
917      * The default implementation passes control to the getSeriesOutlinePaint
918      * method