I committed this patch attached to PR29010, after testing it:

2006-09-11  Cameron McCormack  <[EMAIL PROTECTED]>

        Fixes PR29010
        * java/text/AttributedString.java
        (AttributedString(AttributedCharacterIterator, int, int,
        AttributedCharacterIterator.Attribute[])): Fixed check for defined
        attribute.

Mauve tests will be committed shortly. I've assumed that the fix is small enough not to require FSF paperwork.

Regards,

Dave
Index: source/org/jfree/data/statistics/HistogramDataset.java
===================================================================
RCS file: 
/cvsroot/jfreechart/jfreechart/source/org/jfree/data/statistics/HistogramDataset.java,v
retrieving revision 1.9.2.6
diff -u -r1.9.2.6 HistogramDataset.java
--- source/org/jfree/data/statistics/HistogramDataset.java      3 Aug 2006 
10:37:53 -0000       1.9.2.6
+++ source/org/jfree/data/statistics/HistogramDataset.java      7 Sep 2006 
15:23:55 -0000
@@ -53,6 +53,7 @@
  * 22-Nov-2005 : Fixed cast in getSeriesKey() method - see patch 1329287 (DG);
  * ------------- JFREECHART 1.0.0 ---------------------------------------------
  * 03-Aug-2006 : Improved precision of bin boundary calculation (DG);
+ * 07-Sep-2006 : Fixed bug 1553088 (DG);
  * 
  */
 
@@ -192,6 +193,12 @@
                     fraction = 0.0;
                 }
                 binIndex = (int) (fraction * bins);
+                // rounding could result in binIndex being equal to bins
+                // which will cause an IndexOutOfBoundsException - see bug
+                // report 1553088
+                if (binIndex >= bins) {
+                    binIndex = bins - 1;
+                }
             }
             HistogramBin bin = (HistogramBin) binList.get(binIndex);
             bin.incrementCount();
Index: source/org/jfree/data/statistics/junit/HistogramDatasetTests.java
===================================================================
RCS file: 
/cvsroot/jfreechart/jfreechart/source/org/jfree/data/statistics/junit/HistogramDatasetTests.java,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 HistogramDatasetTests.java
--- source/org/jfree/data/statistics/junit/HistogramDatasetTests.java   3 Aug 
2006 10:37:54 -0000       1.4.2.3
+++ source/org/jfree/data/statistics/junit/HistogramDatasetTests.java   7 Sep 
2006 15:23:55 -0000
@@ -202,4 +202,21 @@
         assertTrue(values[0] < d.getEndXValue(0, 630));        
     }
 
+    /**
+     * Some checks for bug 1553088.  An IndexOutOfBoundsException is thrown 
+     * when a data value is *very* close to the upper limit of the last bin.
+     */
+    public void test1553088() {
+        double[] values = {-1.0, 0.0, -Double.MIN_VALUE, 3.0};
+        HistogramDataset d = new HistogramDataset();
+        d.addSeries("S1", values, 2, -1.0, 0.0);
+        assertEquals(-1.0, d.getStartXValue(0, 0), EPSILON);
+        assertEquals(-0.5, d.getEndXValue(0, 0), EPSILON);
+        assertEquals(1.0, d.getYValue(0, 0), EPSILON);
+        
+        assertEquals(-0.5, d.getStartXValue(0, 1), EPSILON);
+        assertEquals(0.0, d.getEndXValue(0, 1), EPSILON);
+        assertEquals(3.0, d.getYValue(0, 1), EPSILON);
+    }    
+    
 }
\ No newline at end of file

Reply via email to