changeset 2422:44dc117aa2b7

Picked rev 4058,4063,4065,4068,4069 from trunk. flys-artifacts/tags/2.6.1@4077 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 17 Feb 2012 11:29:41 +0000
parents 59047dfed8be
children ac528b883b47
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKms.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java
diffstat 11 files changed, 166 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 17 11:29:41 2012 +0000
@@ -1,3 +1,41 @@
+2012-02-17  Ingo Weinzierl <ingo@intevation.de>
+
+	Part II/III flys/issue497 (Diagrammeigenschaften in Zeitseriendiagrammen)
+
+	* src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java:
+	  Apply legend specific settings (show/hide).
+
+2012-02-17  Ingo Weinzierl <ingo@intevation.de>
+
+	Part I/III flys/issue497 (Diagrammeigenschaften in Zeitseriendiagrammen)
+
+	* src/main/java/de/intevation/flys/exports/ChartGenerator.java,
+	  src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Moved
+	  adjustPlot() from XYChartGenerator to ChartGenerator which enables the
+	  TimeseriesChartGenerator to call this method as well.
+
+	* src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java:
+	  Call adjustPlot() in generateChart() to apply the settings specific to
+	  gridlines in the timeseries plot.
+
+2012-02-16  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Refactored the wq data fields.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java,
+	  src/main/java/de/intevation/flys/artifacts/states/WQSelect.java:
+	  Changed the wq data fields to boolean values.
+
+	* src/main/java/de/intevation/flys/utils/FLYSUtils.java:
+	  Changed the wq data fields to boolean values and added method that
+	  returns the km input mode.
+
+2012-02-16  Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/Calculation4.java:
+	  Fixed W->Q conversion for "W fuer ungleichwertige Abflusslaengsschnitte."
+
 2012-02-16  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue509 (Dauerlinie: Q-Achse sollte bei 0 beginnen)
@@ -8,6 +46,12 @@
 
 2012-02-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
+	* src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WKms.java:
+	  (guessWaterIncreasing): Removed from interface.
+
+2012-02-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
 	Fix flys/issue150 (exposure of gravitational anomalies)
 
 	* src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Feb 17 11:29:41 2012 +0000
@@ -1119,11 +1119,12 @@
         StateData dMode      = getData("wq_mode");
         StateData dSelection = getData("wq_selection");
 
-        String mode = dMode != null ? (String) dMode.getValue() : "";
-        String sel  = dSelection != null ? (String)dSelection.getValue() : null;
+        boolean isRange = dSelection != null
+            ? Boolean.valueOf((String)dSelection.getValue())
+            : false;
 
-        if (mode.equals("Q")) {
-            if (sel != null && sel.equals("single")) {
+        if (isQ()) {
+            if (!isRange) {
                 return getSingleWQValues();
             }
             else {
@@ -1139,12 +1140,24 @@
 
     public boolean isQ() {
         StateData mode = getData("wq_mode");
-        return mode != null && mode.getValue().equals("Q");
+        String value = (mode != null) ? (String) mode.getValue() : null;
+        return value != null ? Boolean.valueOf(value) : false;
+    }
+
+    public boolean isW() {
+        StateData mode = getData("wq_mode");
+        String value = (mode != null) ? (String) mode.getValue() : null;
+        return value != null ? !Boolean.valueOf(value) : false;
     }
 
     public boolean isFreeW() {
-        StateData mode = getData("wq_mode");
-        return mode != null && mode.getValue().equals("WFREE");
+        if(!isW()) {
+            return false;
+        }
+        StateData mode = getData("wq_free");
+        String value =  (mode != null) ? (String) mode.getValue() : null;
+
+        return value != null ? Boolean.valueOf(value) : false;
     }
 
 
@@ -1157,6 +1170,9 @@
      * false and the calculation is bound to a gauge.
      */
     public boolean isFreeQ() {
+        if(!isQ()) {
+            return false;
+        }
         StateData mode  = getData("wq_free");
         String    value = (mode != null) ? (String) mode.getValue() : null;
 
@@ -1175,11 +1191,8 @@
      */
     public double[] getQs(double[] range) {
         StateData dMode   = getData("wq_mode");
-        StateData dValues = getData("wq_values");
 
-        String mode = (dMode != null) ? (String) dMode.getValue() : "";
-
-        if (mode.equals("Q")) {
+        if (isQ()) {
             return getWQForDist(range);
         }
 
@@ -1196,12 +1209,7 @@
      * @return an array of W values.
      */
     public double[] getWs(double[] range) {
-        StateData dMode   = getData("wq_mode");
-        StateData dValues = getData("wq_values");
-
-        String mode = (dMode != null) ? (String) dMode.getValue() : "";
-
-        if (mode.equals("W")) {
+        if (isW()) {
             return getWQForDist(range);
         }
 
@@ -1216,12 +1224,9 @@
      * @return the selected W values or null, if no W values are selected.
      */
     public double[] getWs() {
-        StateData dMode   = getData("wq_mode");
         StateData dSingle = getData("wq_single");
 
-        String mode = (dMode != null) ? (String) dMode.getValue() : "";
-
-        if (mode.equals("W") || mode.equals("WFREE")) {
+        if (isW()) {
             if (dSingle != null) {
                 return getSingleWQValues();
             }
@@ -1230,7 +1235,7 @@
             }
         }
         else {
-            logger.warn("You try to get Qs, but W has been inserted.");
+            logger.warn("You try to get Ws, but Q has been inserted.");
             return null;
         }
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java	Fri Feb 17 11:29:41 2012 +0000
@@ -9,6 +9,7 @@
 
 import de.intevation.flys.model.River;
 import de.intevation.flys.model.Gauge;
+import de.intevation.flys.model.DischargeTable;
 
 import de.intevation.flys.artifacts.model.WstValueTable.QPosition;
 
@@ -77,17 +78,21 @@
 
             // convert to Q if needed
             if (!isQ && gauge != null) {
-                double [][] table = new DischargeTables(
-                    river.getName(), gauge.getName()).getFirstTable();
+
+                DischargeTable dt = gauge.fetchMasterDischargeTable();
+
+                double [][] table =
+                    DischargeTables.loadDischargeTableValues(dt, 1);
 
                 // need the original values for naming
                 segment.backup();
 
                 for (int i = 0; i < values.length; ++i) {
-                    double w = values[i] * 100;
+                    double w = values[i] / 100.0;
                     double [] qs = DischargeTables.getQsForW(table, w);
                     if (qs.length == 0) {
                         logger.warn("No Qs found for W = " + values[i]);
+                        addProblem("cannot.find.w.for.q", values[i]);
                         values[i] = Double.NaN;
                     }
                     else {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKms.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKms.java	Fri Feb 17 11:29:41 2012 +0000
@@ -16,7 +16,5 @@
     TDoubleArrayList allWs();
 
     public boolean guessWaterIncreasing();
-
-    public boolean guessWaterIncreasing(float factor);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java	Fri Feb 17 11:29:41 2012 +0000
@@ -77,8 +77,7 @@
         return guessWaterIncreasing(0.05f);
     }
 
-    @Override
-    public boolean guessWaterIncreasing(float factor) {
+    protected boolean guessWaterIncreasing(float factor) {
         return DataUtil.guessWaterIncreasing(ws, factor);
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java	Fri Feb 17 11:29:41 2012 +0000
@@ -282,11 +282,14 @@
         StateData    data = getData(flys, FIELD_WQ_MODE);
 
         String mode = data != null ? (String) data.getValue() : null;
+        boolean isQ = mode != null
+            ? Boolean.valueOf(mode)
+            : false;
 
-        if (mode != null && mode.equals("W")) {
+        if (!isQ) {
             return validateW(artifact);
         }
-        else if (mode != null && mode.equals("Q")) {
+        else if (isQ) {
             return validateQ(artifact);
         }
         else {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Fri Feb 17 11:29:41 2012 +0000
@@ -89,8 +89,8 @@
             return super.createStaticData(flys, creator, cc, name, value, type);
         }
 
-        String mode = flys.getDataAsString(WQ_MODE);
-        String free = flys.getDataAsString(WQ_FREE);
+        boolean isQ = flys.getDataAsBoolean(WQ_MODE);
+        boolean isFree = flys.getDataAsBoolean(WQ_FREE);
 
         WINFOArtifact winfo = (WINFOArtifact) flys;
 
@@ -103,7 +103,7 @@
 
         String label;
 
-        if (mode == null || mode.equals("W") || Boolean.valueOf(free)) {
+        if (!isQ || isFree) {
             label = getLabel(winfo, cc, value);
         }
         else {
@@ -454,9 +454,11 @@
         WINFOArtifact flys = (WINFOArtifact) artifact;
 
         StateData data       = getData(flys, WQ_SELECTION);
-        String selectionMode = data != null ? (String) data.getValue() : null;
+        boolean isRange = data != null 
+            ? Boolean.valueOf((String) data.getValue())
+            : false;
 
-        if (selectionMode == null || selectionMode.equals("single")) {
+        if (!isRange) {
             return validateSingle(artifact);
         }
         else {
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Feb 17 11:29:41 2012 +0000
@@ -1,8 +1,10 @@
 package de.intevation.flys.exports;
 
+import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Font;
 import java.awt.Paint;
+import java.awt.Stroke;
 import java.awt.TexturePaint;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
@@ -33,6 +35,7 @@
 import org.jfree.data.Range;
 import org.jfree.data.general.Series;
 import org.jfree.data.xy.XYDataset;
+import org.jfree.ui.RectangleInsets;
 
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
@@ -908,6 +911,36 @@
 
 
     /**
+     * Adjust some Stroke/Grid parameters for <i>plot</i>. The chart
+     * <i>Settings</i> are applied in this method.
+     *
+     * @param plot The XYPlot which is adapted.
+     */
+    protected void adjustPlot(XYPlot plot) {
+        Stroke gridStroke = new BasicStroke(
+            DEFAULT_GRID_LINE_WIDTH,
+            BasicStroke.CAP_BUTT,
+            BasicStroke.JOIN_MITER,
+            3.0f,
+            new float[] { 3.0f },
+            0.0f);
+
+        ChartSettings      cs = getChartSettings();
+        boolean isGridVisible = cs != null ? isGridVisible(cs) : true;
+
+        plot.setDomainGridlineStroke(gridStroke);
+        plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR);
+        plot.setDomainGridlinesVisible(isGridVisible);
+
+        plot.setRangeGridlineStroke(gridStroke);
+        plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR);
+        plot.setRangeGridlinesVisible(isGridVisible);
+
+        plot.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d));
+    }
+
+
+    /**
      * This helper mehtod is used to extract the current locale from instance
      * vairable <i>context</i>.
      *
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Fri Feb 17 11:29:41 2012 +0000
@@ -156,18 +156,17 @@
             getXAxisLabel(),
             getYAxisLabel(0),
             null,
-            true,
+            isLegendVisible(),
             false,
             false);
 
-        logger.warn("TODO: IMPLEMENT ME!");
-
         XYPlot plot = (XYPlot) chart.getPlot();
 
         chart.setBackgroundPaint(Color.WHITE);
         plot.setBackgroundPaint(Color.WHITE);
 
         addSubtitles(chart);
+        adjustPlot(plot);
         addDatasets(plot);
 
         adaptZoom(plot);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Feb 17 11:29:41 2012 +0000
@@ -33,7 +33,6 @@
 import org.jfree.data.xy.XYSeriesCollection;
 import org.jfree.data.xy.XYDataset;
 
-import org.jfree.ui.RectangleInsets;
 import org.jfree.ui.TextAnchor;
 
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
@@ -886,33 +885,6 @@
 
 
     /**
-     * Set some Stroke/Grid defaults.
-     */
-    protected void adjustPlot(XYPlot plot) {
-        Stroke gridStroke = new BasicStroke(
-            DEFAULT_GRID_LINE_WIDTH,
-            BasicStroke.CAP_BUTT,
-            BasicStroke.JOIN_MITER,
-            3.0f,
-            new float[] { 3.0f },
-            0.0f);
-
-        ChartSettings      cs = getChartSettings();
-        boolean isGridVisible = cs != null ? isGridVisible(cs) : true;
-
-        plot.setDomainGridlineStroke(gridStroke);
-        plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR);
-        plot.setDomainGridlinesVisible(isGridVisible);
-
-        plot.setRangeGridlineStroke(gridStroke);
-        plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR);
-        plot.setRangeGridlinesVisible(isGridVisible);
-
-        plot.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d));
-    }
-
-
-    /**
      * This method walks over all axes (domain and range) of <i>plot</i> and
      * calls localizeDomainAxis() for domain axes or localizeRangeAxis() for
      * range axes.
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Thu Feb 16 12:35:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Fri Feb 17 11:29:41 2012 +0000
@@ -57,6 +57,12 @@
      */
     public static enum WQ_MODE { QFREE, QGAUGE, WFREE, WGAUGE, NONE };
 
+    /**
+     * An enum that represents the 4 possible WQ input modes in FLYS. The 4
+     * values are
+     * <i>ADAPTED</i> <i>SINGLE</i> <i>RANGE</i> and <i>NONE</i>.
+     */
+    public static enum WQ_INPUT { ADAPTED, SINGLE, RANGE, NONE };
 
     public static final Pattern NUMBERS_PATTERN =
         Pattern.compile("\\D*(\\d++.\\d*)\\D*");
@@ -169,16 +175,20 @@
             return WQ_MODE.NONE;
         }
 
-        String  mode = flys.getDataAsString("wq_mode");
-        Boolean free = flys.getDataAsBoolean("wq_free");
-
-        free = free != null ? free : false;
+        String values = flys.getDataAsString("wq_values");
+        Boolean isQ    = flys.getDataAsBoolean("wq_mode");
 
-        if (mode != null && mode.equals("Q")) {
-            return free ? WQ_MODE.QFREE : WQ_MODE.QGAUGE;
+        if (values != null) {
+            return isQ ? WQ_MODE.QGAUGE : WQ_MODE.WGAUGE;
         }
-        else if (mode != null && mode.equals("W")) {
-            return free ? WQ_MODE.WFREE : WQ_MODE.WGAUGE;
+
+        Boolean isFree = flys.getDataAsBoolean("wq_free");
+
+        if (isQ) {
+            return isFree ? WQ_MODE.QFREE : WQ_MODE.QGAUGE;
+        }
+        else if (!isQ) {
+            return isFree ? WQ_MODE.WFREE : WQ_MODE.WGAUGE;
         }
         else {
             return WQ_MODE.NONE;
@@ -186,6 +196,26 @@
     }
 
 
+    public static WQ_INPUT getWQInputMode(FLYSArtifact flys) {
+        if (flys == null) {
+            return WQ_INPUT.NONE;
+        }
+
+        Boolean selection = flys.getDataAsBoolean("wq_selection");
+        String adapted = flys.getDataAsString("wq_values");
+
+        if(adapted != null && adapted.length() > 0) {
+            return WQ_INPUT.ADAPTED;
+        }
+
+        if (selection != null && selection) {
+            return WQ_INPUT.RANGE;
+        }
+        else {
+            return WQ_INPUT.SINGLE;
+        }
+    }
+
     public static KM_MODE getKmRangeMode(FLYSArtifact flys) {
         String mode = flys.getDataAsString("ld_mode");
 
@@ -337,11 +367,9 @@
      * @return the Ws.
      */
     public static double[] getWs(FLYSArtifact flys) {
-        double[] kmRange = getKmRange(flys);
-
         // XXX this is not nice!
         if (flys instanceof WINFOArtifact) {
-            return ((WINFOArtifact) flys).getWs(kmRange);
+            return ((WINFOArtifact) flys).getWs();
         }
 
         logger.warn("This method currently supports WINFOArtifact only!");

http://dive4elements.wald.intevation.org