changeset 1934:e4a516ca2e86

When having axis in diagrams, always have one on the left. flys-artifacts/trunk@3315 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 25 Nov 2011 08:42:44 +0000
parents 9e9cfc036a3f
children 5b51f5232661
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Nov 24 11:03:33 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Nov 25 08:42:44 2011 +0000
@@ -1,3 +1,11 @@
+2011-11-25  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Let first visible axis be always on the left.
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  (createAxes): When creating axes, keep track of which is the first
+			one. Set its location to "left".
+
 2011-11-24  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Use multiple axis in relevant generators.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Thu Nov 24 11:03:33 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Nov 25 08:42:44 2011 +0000
@@ -24,6 +24,7 @@
 import org.jfree.chart.LegendItem;
 import org.jfree.chart.LegendItemCollection;
 import org.jfree.chart.annotations.XYTextAnnotation;
+import org.jfree.chart.axis.AxisLocation;
 import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.plot.PlotOrientation;
@@ -284,18 +285,24 @@
 
 
     /**
-     * Create y-axes.
+     * Create y-axes, ensure that the first axis (with data) is on the left.
      */
     public void createAxes(XYPlot plot) {
         logger.debug("XYChartGenerator.createAxes");
+
         Integer last = datasets.lastKey();
+        int i            = 0;
+        int firstVisible = 0;
 
         if (last != null) {
-            for (int i = last; i >= 0; --i) {
+            firstVisible = i = last;
+            for (; i >= 0; --i) {
                 if (datasets.containsKey(i)) {
                     plot.setRangeAxis(i, createYAxis(i));
+                    firstVisible = i;
                 }
             }
+            plot.setRangeAxisLocation(firstVisible, AxisLocation.TOP_OR_LEFT);
         }
     }
 

http://dive4elements.wald.intevation.org