Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 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 | 17e18948fe5e |
children | 5b51f5232661 |
comparison
equal
deleted
inserted
replaced
1933:9e9cfc036a3f | 1934:e4a516ca2e86 |
---|---|
22 import org.jfree.chart.ChartFactory; | 22 import org.jfree.chart.ChartFactory; |
23 import org.jfree.chart.JFreeChart; | 23 import org.jfree.chart.JFreeChart; |
24 import org.jfree.chart.LegendItem; | 24 import org.jfree.chart.LegendItem; |
25 import org.jfree.chart.LegendItemCollection; | 25 import org.jfree.chart.LegendItemCollection; |
26 import org.jfree.chart.annotations.XYTextAnnotation; | 26 import org.jfree.chart.annotations.XYTextAnnotation; |
27 import org.jfree.chart.axis.AxisLocation; | |
27 import org.jfree.chart.axis.NumberAxis; | 28 import org.jfree.chart.axis.NumberAxis; |
28 import org.jfree.chart.axis.ValueAxis; | 29 import org.jfree.chart.axis.ValueAxis; |
29 import org.jfree.chart.plot.PlotOrientation; | 30 import org.jfree.chart.plot.PlotOrientation; |
30 import org.jfree.chart.plot.XYPlot; | 31 import org.jfree.chart.plot.XYPlot; |
31 import org.jfree.chart.renderer.xy.XYItemRenderer; | 32 import org.jfree.chart.renderer.xy.XYItemRenderer; |
282 annotations.add(annotation); | 283 annotations.add(annotation); |
283 } | 284 } |
284 | 285 |
285 | 286 |
286 /** | 287 /** |
287 * Create y-axes. | 288 * Create y-axes, ensure that the first axis (with data) is on the left. |
288 */ | 289 */ |
289 public void createAxes(XYPlot plot) { | 290 public void createAxes(XYPlot plot) { |
290 logger.debug("XYChartGenerator.createAxes"); | 291 logger.debug("XYChartGenerator.createAxes"); |
292 | |
291 Integer last = datasets.lastKey(); | 293 Integer last = datasets.lastKey(); |
294 int i = 0; | |
295 int firstVisible = 0; | |
292 | 296 |
293 if (last != null) { | 297 if (last != null) { |
294 for (int i = last; i >= 0; --i) { | 298 firstVisible = i = last; |
299 for (; i >= 0; --i) { | |
295 if (datasets.containsKey(i)) { | 300 if (datasets.containsKey(i)) { |
296 plot.setRangeAxis(i, createYAxis(i)); | 301 plot.setRangeAxis(i, createYAxis(i)); |
302 firstVisible = i; | |
297 } | 303 } |
298 } | 304 } |
305 plot.setRangeAxisLocation(firstVisible, AxisLocation.TOP_OR_LEFT); | |
299 } | 306 } |
300 } | 307 } |
301 | 308 |
302 /** | 309 /** |
303 * Create Y (range) axis for given index. | 310 * Create Y (range) axis for given index. |