[Schmitzm-commits] r954 - trunk/src/schmitzm/jfree

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Aug 5 16:02:24 CEST 2010


Author: alfonx
Date: 2010-08-05 16:02:23 +0200 (Thu, 05 Aug 2010)
New Revision: 954

Modified:
   trunk/src/schmitzm/jfree/JFreeChartUtil.java
Log:
Eine m?\195?\182gliche Exception bei der regressionsLinie bei "schlechten" Daten umschifft:


		// Create Regression line
		if (regressionLine) {

			// only if there is at least one series with at least 2 items, otherwise we would get a
			// IllegalArgumentException, or a " Series index out of bounds" exception
			XYSeriesCollection xySeriesCollection = (XYSeriesCollection) dataset;
			if ((xySeriesCollection.getSeriesCount() > 0) && (xySeriesCollection.getItemCount(0) >= 2)) {
				// create sample data for curve (plot function directly is not
				// yet available)
				XYDataset regressionData = createRegressionLineDataset(
						(XYSeriesCollection) dataset, 0, title
								+ " "+RESOURCE.getString("regressionline"), 2);
				if (regressionData != null)
					addRegressionLineToPlot(plot, regressionData, Color.blue);
			} else {
				LOGGER
						.info("Not enought items in the series to create a regression line.");
			}
		}

Modified: trunk/src/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/JFreeChartUtil.java	2010-07-28 19:23:54 UTC (rev 953)
+++ trunk/src/schmitzm/jfree/JFreeChartUtil.java	2010-08-05 14:02:23 UTC (rev 954)
@@ -770,9 +770,10 @@
 		// Create Regression line
 		if (regressionLine) {
 
-			// only if there are at least 2 items, otherwise we would get a
-			// IllegalArgumentException
-			if (((XYSeriesCollection) dataset).getItemCount(0) >= 2) {
+			// only if there is at least one series with at least 2 items, otherwise we would get a
+			// IllegalArgumentException, or a " Series index out of bounds" exception
+			XYSeriesCollection xySeriesCollection = (XYSeriesCollection) dataset;
+			if ((xySeriesCollection.getSeriesCount() > 0) && (xySeriesCollection.getItemCount(0) >= 2)) {
 				// create sample data for curve (plot function directly is not
 				// yet available)
 				XYDataset regressionData = createRegressionLineDataset(



More information about the Schmitzm-commits mailing list