Index: org/jfree/chart/plot/PiePlot.java
===================================================================
RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/plot/PiePlot.java,v
retrieving revision 1.17.2.11
diff -u -r1.17.2.11 PiePlot.java
--- org/jfree/chart/plot/PiePlot.java	28 Feb 2006 16:16:55 -0000	1.17.2.11
+++ org/jfree/chart/plot/PiePlot.java	27 Sep 2006 13:37:32 -0000
@@ -135,6 +135,8 @@
  *               values in dataset (DG);
  * 28-Feb-2006 : Fixed bug 1440415, bad distribution of pie section 
  *               labels (DG);
+ * 27-Sep-2006 : Initialised baseSectionPaint correctly, added lookup methods
+ *               for section paint, outline paint and outline stroke (DG);
  *               
  */
 
@@ -431,7 +433,7 @@
         
         this.sectionPaint = null;
         this.sectionPaintList = new PaintList();
-        this.baseSectionPaint = null;
+        this.baseSectionPaint = Color.gray;
 
         this.sectionOutlinesVisible = true;
         this.sectionOutlinePaint = null;
@@ -682,6 +684,76 @@
     //// SECTION PAINT ////////////////////////////////////////////////////////
 
     /**
+     * Returns the paint for the specified section.  This is equivalent to
+     * <code>lookupSectionPaint(section, false)</code>.
+     * 
+     * @param section  the section index.
+     * 
+     * @return The paint for the specified section.
+     * 
+     * @since 1.0.3
+     * 
+     * @see #lookupSectionPaint(int, boolean)
+     */
+    protected Paint lookupSectionPaint(int section) {
+        return lookupSectionPaint(section, false);        
+    }
+    
+    /**
+     * Returns the paint for the specified section.  The lookup involves these
+     * steps:
+     * <ul>
+     * <li>if {@link #getSectionPaint()} is non-<code>null</code>, return 
+     *         it;</li>
+     * <li>if {@link #getSectionPaint(int)} is non-<code>null</code> return 
+     *         it;</li>
+     * <li>if {@link #getSectionPaint(int)} is <code>null</code> but 
+     *         <code>autoPopulate</code> is <code>true</code>, attempt to fetch
+     *         a new paint from the drawing supplier 
+     *         ({@link #getDrawingSupplier()});
+     * <li>if all else fails, return {@link #getBaseSectionPaint()}.
+     * </ul> 
+     * 
+     * @param section  the section index.
+     * @param autoPopulate  a flag that controls whether the drawing supplier 
+     *     is used to auto-populate the section paint settings.
+     *     
+     * @return The paint.
+     * 
+     * @since 1.0.3
+     */
+    protected Paint lookupSectionPaint(int section, boolean autoPopulate) {
+        
+        // is there an override?
+        Paint result = getSectionPaint();
+        if (result != null) {
+            return result;
+        }
+        
+        // if not, check if there is a paint defined for the specified key
+        result = this.sectionPaintList.getPaint(section);
+        if (result != null) {
+            return result;
+        }
+        
+        // nothing defined - do we autoPopulate?
+        if (autoPopulate) {
+            DrawingSupplier ds = getDrawingSupplier();
+            if (ds != null) {
+                result = ds.getNextPaint();
+                this.sectionPaintList.setPaint(section, result);
+            }
+            else {
+                result = this.baseSectionPaint;
+            }
+        }
+        else {
+            result = this.baseSectionPaint;
+        }
+        return result;
+    }
+    
+    /**
      * Returns the paint for ALL sections in the plot.
      *
      * @return The paint (possibly <code>null</code>).
@@ -707,30 +779,10 @@
      * 
      * @param section  the section index (zero-based).
      * 
-     * @return The paint (never <code>null</code>).
+     * @return The paint (possibly <code>null</code>).
      */
     public Paint getSectionPaint(int section) {
-        
-        // return the override, if there is one...
-        if (this.sectionPaint != null) {
-            return this.sectionPaint;
-        }
-
-        // otherwise look up the paint list
-        Paint result = this.sectionPaintList.getPaint(section);
-        if (result == null) {
-            DrawingSupplier supplier = getDrawingSupplier();
-            if (supplier != null) {
-                Paint p = supplier.getNextPaint();
-                this.sectionPaintList.setPaint(section, p);
-                result = p;
-            }
-            else {
-                result = this.baseSectionPaint;
-            }
-        }
-        return result;
-       
+        return this.sectionPaintList.getPaint(section);       
     }
     
     /**
@@ -747,7 +799,7 @@
     
     /**
      * Returns the base section paint.  This is used when no other paint is 
-     * available.
+     * defined, which is rare.  The default value is <code>Color.gray</code>.
      * 
      * @return The paint (never <code>null</code>).
      */
@@ -756,7 +808,8 @@
     }
     
     /**
-     * Sets the base section paint.
+     * Sets the base section paint and sends a {@link PlotChangeEvent} to all
+     * registered listeners.
      * 
      * @param paint  the paint (<code>null</code> not permitted).
      */
@@ -794,6 +847,77 @@
     }
 
     /**
+     * Returns the outline paint for the specified section.  This is equivalent 
+     * to <code>lookupSectionPaint(section, false)</code>.
+     * 
+     * @param section  the section index.
+     * 
+     * @return The paint for the specified section.
+     * 
+     * @since 1.0.3
+     * 
+     * @see #lookupSectionOutlinePaint(int, boolean)
+     */
+    protected Paint lookupSectionOutlinePaint(int section) {
+        return lookupSectionOutlinePaint(section, false);        
+    }
+    
+    /**
+     * Returns the outline paint for the specified section.  The lookup 
+     * involves these steps:
+     * <ul>
+     * <li>if {@link #getSectionOutlinePaint()} is non-<code>null</code>, 
+     *         return it;</li>
+     * <li>otherwise, if {@link #getSectionOutlinePaint(int)} is 
+     *         non-<code>null</code> return it;</li>
+     * <li>if {@link #getSectionOutlinePaint(int)} is <code>null</code> but 
+     *         <code>autoPopulate</code> is <code>true</code>, attempt to fetch
+     *         a new outline paint from the drawing supplier 
+     *         ({@link #getDrawingSupplier()});
+     * <li>if all else fails, return {@link #getBaseSectionOutlinePaint()}.
+     * </ul> 
+     * 
+     * @param section  the section index.
+     * @param autoPopulate  a flag that controls whether the drawing supplier 
+     *     is used to auto-populate the section outline paint settings.
+     *     
+     * @return The paint.
+     * 
+     * @since 1.0.3
+     */
+    protected Paint lookupSectionOutlinePaint(int section, 
+            boolean autoPopulate) {
+        
+        // is there an override?
+        Paint result = getSectionOutlinePaint();
+        if (result != null) {
+            return result;
+        }
+        
+        // if not, check if there is a paint defined for the specified key
+        result = this.sectionOutlinePaintList.getPaint(section);
+        if (result != null) {
+            return result;
+        }
+        
+        // nothing defined - do we autoPopulate?
+        if (autoPopulate) {
+            DrawingSupplier ds = getDrawingSupplier();
+            if (ds != null) {
+                result = ds.getNextOutlinePaint();
+                this.sectionOutlinePaintList.setPaint(section, result);
+            }
+            else {
+                result = this.baseSectionOutlinePaint;
+            }
+        }
+        else {
+            result = this.baseSectionOutlinePaint;
+        }
+        return result;
+    }
+    
+    /**
      * Returns the outline paint for ALL sections in the plot.
      *
      * @return The paint (possibly <code>null</code>).
@@ -819,22 +943,10 @@
      * 
      * @param section  the section index (zero-based).
      * 
-     * @return The paint (never <code>null</code>).
+     * @return The paint (possibly <code>null</code>).
      */
     public Paint getSectionOutlinePaint(int section) {
-        
-        // return the override, if there is one...
-        if (this.sectionOutlinePaint != null) {
-            return this.sectionOutlinePaint;
-        }
-
-        // otherwise look up the paint list
-        Paint result = this.sectionOutlinePaintList.getPaint(section);
-        if (result == null) {
-            result = this.baseSectionOutlinePaint;
-        }
-        return result;
-       
+        return this.sectionOutlinePaintList.getPaint(section);
     }
     
     /**
@@ -875,6 +987,77 @@
     //// SECTION OUTLINE STROKE ///////////////////////////////////////////////
 
     /**
+     * Returns the outline stroke for the specified section.  This is equivalent 
+     * to <code>lookupSectionOutlineStroke(section, false)</code>.
+     * 
+     * @param section  the section index.
+     * 
+     * @return The stroke for the specified section.
+     * 
+     * @since 1.0.3
+     * 
+     * @see #lookupSectionOutlineStroke(int, boolean)
+     */
+    protected Stroke lookupSectionOutlineStroke(int section) {
+        return lookupSectionOutlineStroke(section, false);        
+    }
+    
+    /**
+     * Returns the outline stroke for the specified section.  The lookup 
+     * involves these steps:
+     * <ul>
+     * <li>if {@link #getSectionOutlineStroke()} is non-<code>null</code>, 
+     *         return it;</li>
+     * <li>otherwise, if {@link #getSectionOutlineStroke(int)} is 
+     *         non-<code>null</code> return it;</li>
+     * <li>if {@link #getSectionOutlineStroke(int)} is <code>null</code> but 
+     *         <code>autoPopulate</code> is <code>true</code>, attempt to fetch
+     *         a new outline stroke from the drawing supplier 
+     *         ({@link #getDrawingSupplier()});
+     * <li>if all else fails, return {@link #getBaseSectionOutlineStroke()}.
+     * </ul> 
+     * 
+     * @param section  the section index.
+     * @param autoPopulate  a flag that controls whether the drawing supplier 
+     *     is used to auto-populate the section outline stroke settings.
+     *     
+     * @return The stroke.
+     * 
+     * @since 1.0.3
+     */
+    protected Stroke lookupSectionOutlineStroke(int section, 
+            boolean autoPopulate) {
+        
+        // is there an override?
+        Stroke result = getSectionOutlineStroke();
+        if (result != null) {
+            return result;
+        }
+        
+        // if not, check if there is a stroke defined for the specified key
+        result = this.sectionOutlineStrokeList.getStroke(section);
+        if (result != null) {
+            return result;
+        }
+        
+        // nothing defined - do we autoPopulate?
+        if (autoPopulate) {
+            DrawingSupplier ds = getDrawingSupplier();
+            if (ds != null) {
+                result = ds.getNextOutlineStroke();
+                this.sectionOutlineStrokeList.setStroke(section, result);
+            }
+            else {
+                result = this.baseSectionOutlineStroke;
+            }
+        }
+        else {
+            result = this.baseSectionOutlineStroke;
+        }
+        return result;
+    }
+    
+    /**
      * Returns the outline stroke for ALL sections in the plot.
      *
      * @return The stroke (possibly <code>null</code>).
@@ -900,22 +1083,10 @@
      * 
      * @param section  the section index (zero-based).
      * 
-     * @return The stroke (never <code>null</code>).
+     * @return The stroke (possibly <code>null</code>).
      */
     public Stroke getSectionOutlineStroke(int section) {
-        
-        // return the override, if there is one...
-        if (this.sectionOutlineStroke != null) {
-            return this.sectionOutlineStroke;
-        }
-
-        // otherwise look up the paint list
-        Stroke result = this.sectionOutlineStrokeList.getStroke(section);
-        if (result == null) {
-            result = this.baseSectionOutlineStroke;
-        }
-        return result;
-       
+        return this.sectionOutlineStrokeList.getStroke(section);
     }
     
     /**
@@ -1710,12 +1881,12 @@
             }
             else if (currentPass == 1) {
 
-                Paint paint = getSectionPaint(section);
+                Paint paint = lookupSectionPaint(section, true);
                 g2.setPaint(paint);
                 g2.fill(arc);
 
-                Paint outlinePaint = getSectionOutlinePaint(section);
-                Stroke outlineStroke = getSectionOutlineStroke(section);
+                Paint outlinePaint = lookupSectionOutlinePaint(section);
+                Stroke outlineStroke = lookupSectionOutlineStroke(section);
                 if (this.sectionOutlinesVisible) {
                     g2.setPaint(outlinePaint);
                     g2.setStroke(outlineStroke);
@@ -1959,9 +2130,9 @@
                                 this.dataset, key);
                 }
                 String urlText = null;
-                Paint paint = getSectionPaint(section);
-                Paint outlinePaint = getSectionOutlinePaint(section);
-                Stroke outlineStroke = getSectionOutlineStroke(section);
+                Paint paint = lookupSectionPaint(section, true);
+                Paint outlinePaint = lookupSectionOutlinePaint(section);
+                Stroke outlineStroke = lookupSectionOutlineStroke(section);
 
                 LegendItem item = new LegendItem(label, description, 
                         toolTipText, urlText, true, shape, true, paint, 
Index: org/jfree/chart/plot/PiePlot3D.java
===================================================================
RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/plot/PiePlot3D.java,v
retrieving revision 1.10.2.2
diff -u -r1.10.2.2 PiePlot3D.java
--- org/jfree/chart/plot/PiePlot3D.java	25 Oct 2005 20:52:08 -0000	1.10.2.2
+++ org/jfree/chart/plot/PiePlot3D.java	27 Sep 2006 13:37:33 -0000
@@ -2,7 +2,7 @@
  * JFreeChart : a free chart library for the Java(tm) platform
  * ===========================================================
  *
- * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
+ * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
  *
  * Project Info:  http://www.jfree.org/jfreechart/index.html
  *
@@ -27,7 +27,7 @@
  * --------------
  * PiePlot3D.java
  * --------------
- * (C) Copyright 2000-2005, by Object Refinery and Contributors.
+ * (C) Copyright 2000-2006, by Object Refinery and Contributors.
  *
  * Original Author:  Tomer Peretz;
  * Contributor(s):   Richard Atkinson;
@@ -70,6 +70,9 @@
  *               Added pieIndex to PieSectionEntity (DG);
  * 15-Nov-2004 : Removed creation of default tool tip generator (DG);
  * 16-Jun-2005 : Added default constructor (DG);
+ * ------------- JFREECHART 1.0.0 ---------------------------------------------
+ * 27-Sep-2006 : Updated draw() method for new lookup methods (DG);
+ *
  * 
  */
 
@@ -385,7 +388,7 @@
         // draw the bottom circle
         int[] xs;
         int[] ys;
-        outlinePaint = getSectionOutlinePaint(0);
+        outlinePaint = lookupSectionOutlinePaint(0);
         arc = new Arc2D.Double(
             arcX, arcY + depth, pieArea.getWidth(), pieArea.getHeight() - depth,
             0, 360, Arc2D.PIE
@@ -398,9 +401,9 @@
             if (arc == null) {
                 continue;
             }
-            paint = getSectionPaint(categoryIndex);
-            outlinePaint = getSectionOutlinePaint(categoryIndex);
-            outlineStroke = getSectionOutlineStroke(categoryIndex);
+            paint = lookupSectionPaint(categoryIndex, true);
+            outlinePaint = lookupSectionOutlinePaint(categoryIndex);
+            outlineStroke = lookupSectionOutlineStroke(categoryIndex);
             g2.setPaint(paint);
             g2.fill(arc);
             g2.setPaint(outlinePaint);
@@ -439,9 +442,9 @@
         while (iterator.hasNext()) {
             Arc2D segment = (Arc2D) iterator.next();
             if (segment != null) {
-                paint = getSectionPaint(cat);
-                outlinePaint = getSectionOutlinePaint(cat);
-                outlineStroke = getSectionOutlineStroke(cat);
+                paint = lookupSectionPaint(cat, true);
+                outlinePaint = lookupSectionOutlinePaint(cat);
+                outlineStroke = lookupSectionOutlineStroke(cat);
                 drawSide(
                     g2, pieArea, segment, front, back, paint, 
                     outlinePaint, outlineStroke, 
@@ -457,9 +460,9 @@
         while (iterator.hasNext()) {
             Arc2D segment = (Arc2D) iterator.next();
             if (segment != null) {
-                paint = getSectionPaint(cat);
-                outlinePaint = getSectionOutlinePaint(cat);
-                outlineStroke = getSectionOutlineStroke(cat);
+                paint = lookupSectionPaint(cat);
+                outlinePaint = lookupSectionOutlinePaint(cat);
+                outlineStroke = lookupSectionOutlineStroke(cat);
                 drawSide(
                     g2, pieArea, segment, front, back, paint, 
                     outlinePaint, outlineStroke, 
@@ -484,9 +487,9 @@
                 arc.getAngleStart(), arc.getAngleExtent(), Arc2D.PIE
             );
             
-            paint = getSectionPaint(sectionIndex);
-            outlinePaint = getSectionOutlinePaint(sectionIndex);
-            outlineStroke = getSectionOutlineStroke(sectionIndex);
+            paint = lookupSectionPaint(sectionIndex, true);
+            outlinePaint = lookupSectionOutlinePaint(sectionIndex);
+            outlineStroke = lookupSectionOutlineStroke(sectionIndex);
             g2.setPaint(paint);
             g2.fill(upperArc);
             g2.setStroke(outlineStroke);
Index: org/jfree/chart/plot/RingPlot.java
===================================================================
RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/plot/RingPlot.java,v
retrieving revision 1.4.2.5
diff -u -r1.4.2.5 RingPlot.java
--- org/jfree/chart/plot/RingPlot.java	20 Dec 2005 17:26:12 -0000	1.4.2.5
+++ org/jfree/chart/plot/RingPlot.java	27 Sep 2006 13:37:33 -0000
@@ -2,7 +2,7 @@
  * JFreeChart : a free chart library for the Java(tm) platform
  * ===========================================================
  *
- * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
+ * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
  *
  * Project Info:  http://www.jfree.org/jfreechart/index.html
  *
@@ -27,7 +27,7 @@
  * -------------
  * RingPlot.java
  * -------------
- * (C) Copyright 2004, 2005, by Object Refinery Limited.
+ * (C) Copyright 2004-2006, by Object Refinery Limited.
  *
  * Original Author:  David Gilbert (for Object Refinery Limtied);
  * Contributor(s):   -
@@ -42,7 +42,8 @@
  *               GradientPaint (DG);
  * ------------- JFREECHART 1.0.0 ---------------------------------------------
  * 20-Dec-2005 : Fixed problem with entity shape (bug 1386328) (DG);
- * 
+ * 27-Sep-2006 : Updated drawItem() method for new lookup methods (DG);
+ *
  */
 
 package org.jfree.chart.plot;
@@ -334,11 +335,11 @@
             }
             else if (currentPass == 1) {
 
-                Paint paint = getSectionPaint(section);
+                Paint paint = lookupSectionPaint(section, true);
                 g2.setPaint(paint);
                 g2.fill(path);
-                Paint outlinePaint = getSectionOutlinePaint(section);
-                Stroke outlineStroke = getSectionOutlineStroke(section);
+                Paint outlinePaint = lookupSectionOutlinePaint(section);
+                Stroke outlineStroke = lookupSectionOutlineStroke(section);
                 if (outlinePaint != null && outlineStroke != null) {
                     g2.setPaint(outlinePaint);
                     g2.setStroke(outlineStroke);
Index: org/jfree/chart/plot/junit/PiePlotTests.java
===================================================================
RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/plot/junit/PiePlotTests.java,v
retrieving revision 1.7.2.5
diff -u -r1.7.2.5 PiePlotTests.java
--- org/jfree/chart/plot/junit/PiePlotTests.java	25 Oct 2005 20:52:35 -0000	1.7.2.5
+++ org/jfree/chart/plot/junit/PiePlotTests.java	27 Sep 2006 13:37:33 -0000
@@ -2,7 +2,7 @@
  * JFreeChart : a free chart library for the Java(tm) platform
  * ===========================================================
  *
- * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
+ * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
  *
  * Project Info:  http://www.jfree.org/jfreechart/index.html
  *
@@ -27,7 +27,7 @@
  * -----------------
  * PiePlotTests.java
  * -----------------
- * (C) Copyright 2003, 2004, by Object Refinery Limited and Contributors.
+ * (C) Copyright 2003, 2004, 2006, by Object Refinery Limited and Contributors.
  *
  * Original Author:  David Gilbert (for Object Refinery Limited);
  * Contributor(s):   -;
@@ -38,6 +38,7 @@
  * -------
  * 18-Mar-2003 : Version 1 (DG);
  * 10-May-2005 : Strengthened equals() test (DG);
+ * 27-Sep-2006 : Added tests for the getBaseSectionPaint() method (DG);
  *
  */
 
@@ -69,7 +70,7 @@
 import org.jfree.util.Rotation;
 
 /**
- * Tests for the {@link PiePlot} class.
+ * Some tests for the {@link PiePlot} class.
  */
 public class PiePlotTests extends TestCase {
 
@@ -184,19 +185,19 @@
         assertTrue(plot1.equals(plot2));
         
         // sectionOutlinePaintList
-        plot1.setSectionOutlinePaint(2, new GradientPaint(1.0f, 2.0f, Color.green, 
-                3.0f, 4.0f, Color.white));
+        plot1.setSectionOutlinePaint(2, new GradientPaint(1.0f, 2.0f, 
+                Color.green, 3.0f, 4.0f, Color.white));
         assertFalse(plot1.equals(plot2));
-        plot2.setSectionOutlinePaint(2, new GradientPaint(1.0f, 2.0f, Color.green, 
-                3.0f, 4.0f, Color.white));
+        plot2.setSectionOutlinePaint(2, new GradientPaint(1.0f, 2.0f, 
+                Color.green, 3.0f, 4.0f, Color.white));
         assertTrue(plot1.equals(plot2));
         
         // baseSectionOutlinePaint
-        plot1.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.gray, 
-                3.0f, 4.0f, Color.white));
+        plot1.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, 
+                Color.gray, 3.0f, 4.0f, Color.white));
         assertFalse(plot1.equals(plot2));
-        plot2.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.gray, 
-                3.0f, 4.0f, Color.white));
+        plot2.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, 
+                Color.gray, 3.0f, 4.0f, Color.white));
         assertTrue(plot1.equals(plot2));
         
         // sectionOutlineStroke
@@ -289,9 +290,11 @@
         assertTrue(plot1.equals(plot2));
         
         // labelGenerator
-        plot1.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}{1}{0}"));
+        plot1.setLabelGenerator(new StandardPieSectionLabelGenerator(
+                "{2}{1}{0}"));
         assertFalse(plot1.equals(plot2));
-        plot2.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}{1}{0}"));
+        plot2.setLabelGenerator(new StandardPieSectionLabelGenerator(
+                "{2}{1}{0}"));
         assertTrue(plot1.equals(plot2));
        
         // labelFont
@@ -451,4 +454,21 @@
         assertEquals(2, items.getItemCount());        
     }
     
+    /**
+     * Check that the default base section paint is not null, and that you 
+     * can never set it to null.
+     */
+    public void testGetBaseSectionPaint() {
+        PiePlot plot = new PiePlot();
+        assertNotNull(plot.getBaseSectionPaint());
+        
+        boolean pass = false;
+        try {
+            plot.setBaseSectionPaint(null);
+        }
+        catch (IllegalArgumentException e) {
+            pass = true;
+        }
+        assertTrue(pass);
+    }
 }
\ No newline at end of file
