[Dive4elements-commits] [PATCH 4 of 4] Show some Q mainvalues in DischargeTablesOverview

Wald Commits scm-commit at wald.intevation.org
Wed Mar 20 12:20:21 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1363778865 -3600
# Node ID f987d25627aac009a0a550fbd6c027a5397b20e5
# Parent  61f4d4164a30d46999cf101a7e33e9970f4fd5d3
Show some Q mainvalues in DischargeTablesOverview.

diff -r 61f4d4164a30 -r f987d25627aa flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java
--- 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");
diff -r 61f4d4164a30 -r f987d25627aa flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java
--- 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();


More information about the Dive4elements-commits mailing list