diff flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 375:60f63539d004

Ws and Qs of a longitudinal section chart are mapped to an own range axis now. flys-artifacts/trunk@1785 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 02 May 2011 09:41:22 +0000
parents 2ce7b473620e
children e07d1c3f7667
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Sun May 01 10:58:38 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Mon May 02 09:41:22 2011 +0000
@@ -2,7 +2,9 @@
 
 import org.apache.log4j.Logger;
 
-import org.jfree.data.xy.XYDataset;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.plot.XYPlot;
 import org.jfree.data.xy.XYSeries;
 import org.jfree.data.xy.XYSeriesCollection;
 
@@ -33,14 +35,18 @@
         "longitudinal_section.q";
 
 
-    /** The storage for the series to be drawn in this chart.*/
-    protected XYSeriesCollection dataset;
+    /** The storage for the W series to be drawn in this chart.*/
+    protected XYSeriesCollection w;
+
+    /** The storage for the Q series to be drawn in this chart.*/
+    protected XYSeriesCollection q;
 
 
     public LongitudinalSectionGenerator() {
         super();
 
-        this.dataset = new XYSeriesCollection();
+        this.w = new XYSeriesCollection();
+        this.q = new XYSeriesCollection();
     }
 
 
@@ -60,8 +66,21 @@
     }
 
 
-    protected XYDataset getXYDataset() {
-        return dataset;
+    protected void addDatasets(JFreeChart chart) {
+        XYPlot plot = (XYPlot) chart.getPlot();
+
+        plot.setDataset(0, w);
+        plot.setDataset(1, q);
+    }
+
+
+    protected void adjustAxes(XYPlot plot) {
+        super.adjustAxes(plot);
+
+        NumberAxis qAxis = new NumberAxis("Q [m³/s]");
+
+        plot.setRangeAxis(2, qAxis);
+        plot.mapDatasetToRangeAxis(1, 2);
     }
 
 
@@ -133,7 +152,7 @@
                 series.add(target[2], target[0]);
             }
 
-            dataset.addSeries(series);
+            w.addSeries(series);
         }
     }
 
@@ -168,7 +187,7 @@
                 series.add(target[2], target[1]);
             }
 
-            dataset.addSeries(series);
+            q.addSeries(series);
         }
     }
 

http://dive4elements.wald.intevation.org