changeset 5344:f987d25627aa

Show some Q mainvalues in DischargeTablesOverview.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 20 Mar 2013 12:27:45 +0100
parents 61f4d4164a30
children 75c13f65b539
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java
diffstat 2 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java	Wed Mar 20 12:25:25 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java	Wed Mar 20 12:27:45 2013 +0100
@@ -79,6 +79,12 @@
         return v;
     }
 
+
+    public Map<String, Double> getMainValues() {
+        return mainValues;
+    }
+
+
     public void buildClasses() {
         Double mnq = getMainValue("MNQ");
         Double mq  = getMainValue("MQ");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java	Wed Mar 20 12:25:25 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java	Wed Mar 20 12:27:45 2013 +0100
@@ -8,11 +8,13 @@
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.hibernate.Session;
 import org.jfree.chart.ChartFactory;
 import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.Marker;
 import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.chart.plot.XYPlot;
 import org.jfree.data.xy.XYSeries;
@@ -24,6 +26,9 @@
 import de.intevation.artifacts.CallMeta;
 import de.intevation.artifacts.GlobalContext;
 import de.intevation.flys.artifacts.model.DischargeTables;
+import de.intevation.flys.artifacts.model.GaugeFinder;
+import de.intevation.flys.artifacts.model.GaugeFinderFactory;
+import de.intevation.flys.artifacts.model.GaugeRange;
 import de.intevation.flys.artifacts.model.GaugesFactory;
 import de.intevation.flys.artifacts.resources.Resources;
 import de.intevation.flys.backend.SessionHolder;
@@ -124,6 +129,12 @@
         plot.setDomainGridlinesVisible(true);
         plot.setRangeGridlinesVisible(true);
 
+        applyMainValueMarkers(
+            plot,
+            gauge.getRiver().getName(),
+            gauge.getStation().doubleValue(),
+            callMeta);
+
         return chart;
     }
 
@@ -149,6 +160,44 @@
         return series;
     }
 
+
+    /** Add domain markers to plot that indicate (only some Q) mainvalues. */
+    protected static void applyMainValueMarkers(
+        XYPlot   plot,
+        String   river,
+        double   km,
+        CallMeta meta
+    ) {
+        GaugeFinderFactory ggf = GaugeFinderFactory.getInstance();
+        GaugeFinder        gf  = ggf.getGaugeFinder(river);
+
+        if (gf == null) {
+            log.warn("No gauge finder found for river '" + river + "'");
+            return;
+        }
+
+        GaugeRange gr = gf.find(km);
+        if (gr == null) {
+            log.debug("No gauge range found for km "
+                + km + " on river " + river + ".");
+            return;
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug(gr);
+        }
+
+        for (Map.Entry<String, Double> entry: gr.getMainValues().entrySet()) {
+            Marker m = FixingsKMChartService.createQSectorMarker(
+                entry.getValue(),
+                entry.getKey());
+
+            if (m != null) {
+                plot.addDomainMarker(m);
+            }
+        }
+    }
+
     protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt)
         throws IllegalArgumentException {
         TimeInterval timeInterval = dt.getTimeInterval();

http://dive4elements.wald.intevation.org