[Schmitzm-commits] r480 - branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 20 13:54:54 CEST 2009


Author: alfonx
Date: 2009-10-20 13:54:52 +0200 (Tue, 20 Oct 2009)
New Revision: 480

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
Log:
* GP-Feature: ChartStyle centering improved

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java	2009-10-20 11:04:43 UTC (rev 479)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java	2009-10-20 11:54:52 UTC (rev 480)
@@ -449,34 +449,31 @@
 		  plot.removeRangeMarker(VALUE_MARKER);
 		}
 		
-		// plot.setDomainPannable(true);
-		// plot.setRangePannable(true);
+		 plot.setDomainPannable(true);
+		 plot.setRangePannable(true);
 
 		if (isCenterOriginSymetrically()) {
 			plot.getRangeAxis().setAutoRange(false);
 			plot.getDomainAxis().setAutoRange(false);
-			// Calc the min/max values
-			plot.getRangeAxis().centerRange(0);
-			plot.getDomainAxis().centerRange(0);
+			
+			{
+				// Domain
+				Range range = plot.getDomainAxis().getRange();
+				
+				double absMax = Math.max(Math.abs(range.getUpperBound()), Math
+						.abs(range.getLowerBound())) * 1.1;
+				plot.getDomainAxis().setRange(-absMax, absMax);
+			}
 
-			if (plot.getDataset() instanceof XYSeriesCollection) {
-				XYSeries series0 = ((XYSeriesCollection) plot.getDataset()).getSeries(0);
-				double absMaxX = Math.max(
-				    Math.abs(series0.getMinX()), 
-				    Math.abs(series0.getMaxX())
-				) * 1.1;
-				plot.getDomainAxis().setRange(new Range(-absMaxX, absMaxX));
+			{
+				// Range
+				Range range = plot.getRangeAxis().getRange();
 
-				double absMaxY = Math.max(
-				    Math.abs(series0.getMinY()), 
-				    Math.abs(series0.getMaxY())
-				) * 1.1;
-				plot.getRangeAxis().setRange(new Range(-absMaxY, absMaxY));
-			} else {
-				LOGGER.warn("CenterOriginSymetrically can ATM only be applied to datasets of type XYSeriesCollection. Autorange is activated.");
-				plot.getRangeAxis().setAutoRange(true);
-				plot.getDomainAxis().setAutoRange(true);
+				double absMax = Math.max(Math.abs(range.getUpperBound()), Math
+						.abs(range.getLowerBound())) * 1.1;
+				plot.getRangeAxis().setRange(-absMax, absMax);
 			}
+		
 		} else {
 			plot.getRangeAxis().setAutoRange(true);
 			plot.getDomainAxis().setAutoRange(true);
@@ -501,8 +498,8 @@
 		// );
 		// plot.getRangeAxis().setRange(-rangeAbsMax, rangeAbsMax);
 
-		// plot.getDomainAxis().centerRange(0);
-		// plot.getRangeAxis().centerRange(0);
+//		 plot.getDomainAxis().centerRange(0);
+//		 plot.getRangeAxis().centerRange(0);
 		//    
 		// plot.getDomainAxis().setAutoRange(false);
 		// plot.getRangeAxis().setAutoRange(false);



More information about the Schmitzm-commits mailing list