Stepping through the code, with the data you supplied, I notice that the mean value is a long way outside the "regular value" range, and I think this might be the cause of the problem (attempting to fill/draw an Ellipse2D with extreme coordinates in Java2D space). 

This is my suggestion to fix the BoxAndWhiskerRenderer class (see further below for a similar fix for the XYBoxAndWhiskerRenderer class).  Please give this a try and see if it resolves your problem:


Index: /home/dgilbert/workspace/jfreechart-1.0.x-bugs/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java
===================================================================
--- /home/dgilbert/workspace/jfreechart-1.0.x-bugs/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java    (revision 623)
+++ /home/dgilbert/workspace/jfreechart-1.0.x-bugs/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java    (working copy)
@@ -63,6 +63,7 @@
  * 11-May-2007 : Added check for visibility in getLegendItem() (DG);
  * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG);
  * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG);
+ * 07-Dec-2007 : Check visibility of average marker before drawing it (DG);
  *
  */
 
@@ -475,10 +476,15 @@
             double xxMean = rangeAxis.valueToJava2D(xMean.doubleValue(), 
                     dataArea, location);
             aRadius = state.getBarWidth() / 4;
-            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxMean 
-                    - aRadius, yy + aRadius, aRadius * 2, aRadius * 2);
-            g2.fill(avgEllipse);
-            g2.draw(avgEllipse);
+            // here we check that the average marker will in fact be visible
+            // before drawing it...
+            if ((xxMean > (dataArea.getMinX() - aRadius)) 
+                    && (xxMean < (dataArea.getMaxX() + aRadius))) {
+                Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxMean 
+                        - aRadius, yy + aRadius, aRadius * 2, aRadius * 2);
+                g2.fill(avgEllipse);
+                g2.draw(avgEllipse);
+            }
         }
 
         // draw median...
@@ -628,10 +634,15 @@
             yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), 
                     dataArea, location);
             aRadius = state.getBarWidth() / 4;
-            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx + aRadius, 
-                    yyAverage - aRadius, aRadius * 2, aRadius * 2);
-            g2.fill(avgEllipse);
-            g2.draw(avgEllipse);
+            // here we check that the average marker will in fact be visible
+            // before drawing it...
+            if ((yyAverage > (dataArea.getMinY() - aRadius)) 
+                    && (yyAverage < (dataArea.getMaxY() + aRadius))) {
+                Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx + aRadius, 
+                        yyAverage - aRadius, aRadius * 2, aRadius * 2);
+                g2.fill(avgEllipse);
+                g2.draw(avgEllipse);
+            }
         }
 
         // draw median...

********************************************************

...and the same for XYBoxAndWhiskerRenderer.java

Index: /home/dgilbert/workspace/jfreechart-1.0.x-bugs/source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java
===================================================================
--- /home/dgilbert/workspace/jfreechart-1.0.x-bugs/source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java    (revision 624)
+++ /home/dgilbert/workspace/jfreechart-1.0.x-bugs/source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java    (working copy)
@@ -68,6 +68,7 @@
  * 05-Feb-2007 : Added event notifications and fixed drawing for horizontal 
  *               plot orientation (DG);
  * 13-Jun-2007 : Replaced deprecated method call (DG);
+ * 07-Dec-2007 : Check visibility of average marker before drawing it (DG);
  *
  */
 
@@ -440,11 +441,16 @@
         // draw average - SPECIAL AIMS REQUIREMENT
         if (yAverage != null) {
             double aRadius = width / 4;
-            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(
-                    yyAverage - aRadius, xx - aRadius, aRadius * 2, 
-                    aRadius * 2);
-            g2.fill(avgEllipse);
-            g2.draw(avgEllipse);
+            // here we check that the average marker will in fact be visible
+            // before drawing it...
+            if ((yyAverage > (dataArea.getMinX() - aRadius)) 
+                    && (yyAverage < (dataArea.getMaxX() + aRadius))) {
+                Ellipse2D.Double avgEllipse = new Ellipse2D.Double(
+                        yyAverage - aRadius, xx - aRadius, aRadius * 2, 
+                        aRadius * 2);
+                g2.fill(avgEllipse);
+                g2.draw(avgEllipse);
+            }
         }
         
         // FIXME: draw outliers
@@ -588,10 +594,15 @@
         // draw average - SPECIAL AIMS REQUIREMENT
         if (yAverage != null) {
             aRadius = width / 4;
-            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx - aRadius, 
-                    yyAverage - aRadius, aRadius * 2, aRadius * 2);
-            g2.fill(avgEllipse);
-            g2.draw(avgEllipse);
+            // here we check that the average marker will in fact be visible
+            // before drawing it...
+            if ((yyAverage > (dataArea.getMinY() - aRadius)) 
+                    && (yyAverage < (dataArea.getMaxY() + aRadius))) {
+                Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx - aRadius, 
+                        yyAverage - aRadius, aRadius * 2, aRadius * 2);
+                g2.fill(avgEllipse);
+                g2.draw(avgEllipse);
+            }
         }
 
         List outliers = new ArrayList();


Regards,

Dave


Paul Belleville wrote:
Dave:
Thanks for looking into this.  I have distilled it down to one set of data as an example that causes the problem.
Attached is a CSV.
If you simply plot the data in the "Value" column (column K) as a one category, one series boxplot and send that to a PDF it causes the problem.  I have also attached the PDF for reference.
 
Paul Belleville

----- Original Message ----
From: Dave Gilbert <david.gilbert@object-refinery.com>
To: Paul Belleville <pbelleville@telegentsystems.com>; jfreechart-developers@lists.sourceforge.net
Sent: Wednesday, December 5, 2007 11:35:16 AM
Subject: Re: [jfreechart-dev] Problem saving BoxPlot to PDF (Token type not recognized)

Paul Belleville wrote:
Dave:
Thanks.  Yes, Paulo mentioned some very large numbers in the PDF.
So, where do you think the issue is?  jFreeChart or iText?
Can you think of any work-around I can do now? before the patch comes?
 
Thanks
Paul Belleville

Java2D uses double primitives to specify geometric "shapes" (rectangles, lines, ellipses etc.) but, as far as I know, doesn't specify anywhere what the valid range of coordinates (at rendering time) is.  If there is some underlying limitation (as there appears to be in PDF) then I'd expect the Graphics2D implementation to "clip" shapes appropriately to avoid errors, so in that sense you could say it is a problem with the PDFGraphics2D class.  That said, there are similar problems in Java's own Graphics2D implementations, so it isn't a well-specified area (or, if it is, I've not seen the specification).  I suspect that providing a bullet-proof Graphics2D implementation might incur a performance penalty from checking and clipping every shape before it is drawn...but I don't really know, since I prefer to stay on the user-side of the API (the low level implementation of the API is very complex).

I think the problem needs attacking from both sides --- if we can make PDFGraphics2D more robust without harming performance too much, let's do it.  At the same time, I'd like JFreeChart to work as well as possible with existing versions of iText (since people are slow to upgrade libraries in my experience), so putting some workarounds into JFreeChart makes a lot of sense as well.  The type of workaround needed is to add some basic "clipping" to the JFreeChart renderer, so that it never sends really extreme coordinates to the Graphics2D implementation in the first place.

As a starting point, I'd like to look into your failing example, so if you are able to distill it into a self contained test case that would be great...

Regards,

Dave