changeset 3809:cc83b8e42dbe

Picked rev3347-rev3351 from trunk. flys-artifacts/tags/pre2.6-2011-12-05@3352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 05 Dec 2011 09:48:44 +0000
parents 37a7b3841565
children b6431052a694
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 10 files changed, 101 insertions(+), 196 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Dec 05 09:48:44 2011 +0000
@@ -1,3 +1,39 @@
+2011-12-05  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java:
+	  Bugfix: Evaluate the correct parameter whether to set the floodplain or
+	  not. In addition, the scenario parameter used by WSPLGEN is now set
+	  correctly.
+
+2011-12-05	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Allow longitudinal_section.q facets in wdiff states output.
+
+	* doc/conf/artifacts/winfo.xml: Added longitudinal_section.q facets
+	  to w-diff states out compatibility- matrix.
+
+2011-12-05	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Refactored Longitudinal*/WDiff-*Generator hierarchy and change axis
+	ordering, resolved label-i18n TODO.
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java:
+	  Merge, avoid duplicate code, fix axis ordering in w-diff diagram,
+	  label in ls-diagramm.
+
+2011-12-05  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Added missing state titles.
+
+2011-12-05	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java:
+	  Do not include zero on first axis.
+
 2011-12-02	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Mon Dec 05 09:48:44 2011 +0000
@@ -166,6 +166,7 @@
             <outputmodes>
                 <outputmode name="w_differences" description="output.w_differences" mime-type="image/png" type="chart">
                     <facets>
+                        <facet name="longitudinal_section.q" description="facet.longitudinal_section.q"/>
                         <facet name="longitudinal_section.w" description="facet.longitudinal_section.w"/>
                         <facet name="w_differences" description="facet.w_differences"/>
                         <facet name="other.wkms" description="facet.other.wkms"/>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Mon Dec 05 09:48:44 2011 +0000
@@ -287,17 +287,21 @@
 
 
     protected void setGel(FLYSArtifact artifact, WSPLGENJob job) {
-        String gel = artifact.getDataAsString("use_floodplain");
-
-        if (gel != null && gel.length() > 0) {
-            boolean use = Boolean.parseBoolean(gel);
+        String gel = artifact.getDataAsString("scenario");
 
-            if (use) {
-                job.setGel(WSPLGENJob.GEL_SPERRE);
-            }
-            else {
-                job.setGel(WSPLGENJob.GEL_NOSPERRE);
-            }
+        logger.debug("Selected gel = '" + gel + "'");
+
+        if (gel == null || gel.length() == 0) {
+            job.setGel(WSPLGENJob.GEL_NOSPERRE);
+        }
+        else if (gel.equals("scenario.current")) {
+            job.setGel(WSPLGENJob.GEL_SPERRE);
+        }
+        else if (gel.equals("scenario.scenario")) {
+            job.setGel(WSPLGENJob.GEL_SPERRE);
+        }
+        else {
+            job.setGel(WSPLGENJob.GEL_NOSPERRE);
         }
     }
 
@@ -347,6 +351,8 @@
             new Object[] { "typ", String.class }
         };
 
+        String scenario = job.getGel();
+
         boolean l = GeometryUtils.writeShapefile(
             shapeLines,
             GeometryUtils.buildFeatureType("lines", srs, LineString.class, obj),
@@ -356,7 +362,13 @@
             logger.debug(
                 "Successfully created barrier line shapefile. " +
                 "Write shapefile path into WSPLGEN job.");
-            job.addLin(shapeLines.getAbsolutePath());
+
+            if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) {
+                logger.debug("WSPLGEN will not use barrier features.");
+            }
+            else {
+                job.addLin(shapeLines.getAbsolutePath());
+            }
         }
 
         boolean p = GeometryUtils.writeShapefile(
@@ -368,7 +380,13 @@
             logger.debug(
                 "Successfully created barrier polygon shapefile. " +
                 "Write shapefile path into WSPLGEN job.");
-            job.addLin(shapePolys.getAbsolutePath());
+
+            if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) {
+                logger.debug("WSPLGEN will not use barrier features.");
+            }
+            else {
+                job.addLin(shapePolys.getAbsolutePath());
+            }
         }
 
         if (p || l) {
@@ -581,6 +599,12 @@
 
 
     protected void setArea(FLYSArtifact artifact, File dir, WSPLGENJob job) {
+        String useFloodplain = artifact.getDataAsString("use_floodplain");
+        if (!Boolean.valueOf(useFloodplain)) {
+            logger.debug("WSPLGEN will not use floodplain.");
+            return;
+        }
+
         String river = artifact.getDataAsString("river");
         String srid  = FLYSUtils.getRiverSrid(artifact);
         String srs   = "EPSG:" + srid;
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Mon Dec 05 09:48:44 2011 +0000
@@ -94,6 +94,9 @@
             //label = msg(get2YAxisLabelKey(), get2YAxisDefaultLabel());
         }
         NumberAxis axis = new NumberAxis(label);
+        if (index == YAXIS.W.idx) {
+            axis.setAutoRangeIncludesZero(false);
+        }
         axis.setLabelFont(labelFont);
         return axis;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Mon Dec 05 09:48:44 2011 +0000
@@ -13,6 +13,7 @@
 
 import org.w3c.dom.Document;
 
+import de.intevation.artifactdatabase.state.ArtifactAndFacet;
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -23,8 +24,6 @@
 
 import de.intevation.flys.jfree.FLYSAnnotation;
 
-import de.intevation.artifactdatabase.state.ArtifactAndFacet;
-
 import de.intevation.flys.utils.FLYSUtils;
 import de.intevation.flys.utils.DataUtil;
 
@@ -38,7 +37,7 @@
 extends      XYChartGenerator
 implements   FacetTypes
 {
-    public static enum YAXIS {
+    public enum YAXIS {
         W(0),
         Q(1),
         D(2);
@@ -84,6 +83,11 @@
     public static final String I18N_YAXIS_LABEL_DEFAULT  = "W [NN + m]";
     public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]";
 
+    public final static String I18N_WDIFF_YAXIS_LABEL =
+        "chart.w_differences.yaxis.label";
+
+    public final static String I18N_WDIFF_YAXIS_LABEL_DEFAULT = "m";
+
     /** Whether or not the plot is inverted (left-right). */
     protected boolean inverted;
 
@@ -154,10 +158,15 @@
     }
 
 
+    @Override
+    protected String getYAxisLabel() {
+        return getWAxisLabel();
+    }
+
     /**
      * Get internationalized label for the y axis.
      */
-    protected String getYAxisLabel() {
+    protected String getWAxisLabel() {
         FLYSArtifact flys = (FLYSArtifact) master;
 
         String unit = FLYSUtils.getRiver(flys).getWstUnit().getName();
@@ -178,14 +187,13 @@
         Font labelFont = new Font("Tahoma", Font.BOLD, 14);
         String label = "default";
         if (index == YAXIS.W.idx) {
-            label = getYAxisLabel();
+            label = getWAxisLabel();
         }
         else if (index == YAXIS.Q.idx) {
-            label = msg(get2YAxisLabelKey(), get2YAxisDefaultLabel());
+            label = msg(getQAxisLabelKey(), getQAxisDefaultLabel());
         }
         else if (index == YAXIS.D.idx) {
-            // TODO: diff label
-            label = "TODO: diff";
+            label = msg(I18N_WDIFF_YAXIS_LABEL, I18N_WDIFF_YAXIS_LABEL_DEFAULT);
         }
         NumberAxis axis = new NumberAxis(label);
         // "Q" Axis shall include 0.
@@ -203,7 +211,7 @@
      * Get default value for the second Y-Axis' label (if no translation was
      * found).
      */
-    protected String get2YAxisDefaultLabel() {
+    protected String getQAxisDefaultLabel() {
         return I18N_2YAXIS_LABEL_DEFAULT;
     }
 
@@ -211,7 +219,7 @@
     /**
      * Get key for internationalization of the second Y-Axis' label.
      */
-    protected String get2YAxisLabelKey() {
+    protected String getQAxisLabelKey() {
         return I18N_2YAXIS_LABEL;
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Mon Dec 05 09:48:44 2011 +0000
@@ -6,21 +6,10 @@
 
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.plot.XYPlot;
-import org.jfree.data.xy.XYSeries;
 
-import org.w3c.dom.Document;
-
-import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WKms;
 
-import de.intevation.artifactdatabase.state.ArtifactAndFacet;
-
-import de.intevation.flys.artifacts.model.WQKms;
-import de.intevation.flys.utils.DataUtil;
-import de.intevation.flys.utils.FLYSUtils;
-
-import de.intevation.flys.jfree.FLYSAnnotation;
 
 /**
  * An OutGenerator that generates w differences curves.
@@ -29,9 +18,9 @@
 extends      LongitudinalSectionGenerator
 implements   FacetTypes
 {
-    public static enum YAXIS {
-        D(0),
-        W(1),
+    public enum YAXIS {
+        W(0),
+        D(1),
         Q(2);
         protected int idx;
         private YAXIS(int c) {
@@ -49,21 +38,9 @@
     /** Default for internationalized title (when no translation found). */
     public final static String I18N_WDIFF_TITLE_DEFAULT = "Differences";
 
-    /** Key for internationalized title of WDiff charts. */
-    public final static String I18N_WDIFF_2YAXIS_LABEL =
-        "chart.w_differences.yaxis.second.label";
-
-    /** Default for label for second Y-Axis when no translation found. */
-    public final static String I18N_WDIFF_2YAXIS_LABEL_DEFAULT = "W [NN + m]";
-
     public final static String I18N_WDIFF_SUBTITLE =
         "chart.w_differences.subtitle";
 
-    public final static String I18N_WDIFF_YAXIS_LABEL =
-        "chart.w_differences.yaxis.label";
-
-    public final static String I18N_WDIFF_YAXIS_LABEL_DEFAULT = "m";
-
 
     /**
      * Get internationalized title for chart.
@@ -76,17 +53,6 @@
 
 
     /**
-     * Get default value for the second Y-Axis' label (if no translation was
-     * found).
-     * @return default value for second y-axis label.
-     */
-    @Override
-    protected String get2YAxisDefaultLabel() {
-        return I18N_WDIFF_2YAXIS_LABEL_DEFAULT;
-    }
-
-
-    /**
      * Gets key to look up internationalized String for the charts subtitle.
      * @return key to look up translated subtitle.
      */
@@ -97,108 +63,6 @@
 
 
     /**
-     * Get key for internationalization of the second Y-Axis' label.
-     * @return internationalized second y-axis.
-     */
-    @Override
-    protected String get2YAxisLabelKey() {
-        return I18N_WDIFF_2YAXIS_LABEL;
-    }
-
-
-    /**
-     * Get internationalized label for the y axis.
-     * @return internationalized label for y axos.
-     */
-    @Override
-    protected String getYAxisLabel() {
-        FLYSArtifact flys = (FLYSArtifact) master;
-
-        String unit = FLYSUtils.getRiver(flys).getWstUnit().getName();
-
-        return msg(
-            I18N_WDIFF_YAXIS_LABEL,
-            I18N_WDIFF_YAXIS_LABEL_DEFAULT,
-            new Object[] { unit });
-    }
-
-
-    /**
-     * Add (themed) data for chart generation.
-     */
-    @Override
-    public void doOut(
-        ArtifactAndFacet artifactAndFacet,
-        Document         attr,
-        boolean          visible
-    ) {
-        String name = artifactAndFacet.getFacetName();
-
-        logger.debug("WDifferencesCurveGenerator.doOut: " + name);
-
-        if (name == null) {
-            logger.error("No facet name for doOut(). No output generated!");
-            return;
-        }
-
-        if (name.equals(W_DIFFERENCES)) {
-            doWDifferencesOut(
-                (WKms) artifactAndFacet.getData(context),
-                artifactAndFacet.getFacetDescription(),
-                attr,
-                visible);
-        }
-        else if (name.equals(LONGITUDINAL_W)) {
-            doWOut((WQKms) artifactAndFacet.getData(context),
-                artifactAndFacet.getFacetDescription(), attr, visible);
-        }
-        else if (name.equals(STATIC_WKMS) || name.equals(HEIGHTMARKS_POINTS)) {
-            doWOut((WKms) artifactAndFacet.getData(context),
-                artifactAndFacet.getFacetDescription(), attr, visible);
-        }
-        else if (name.equals(LONGITUDINAL_ANNOTATION)) {
-            doAnnotations((FLYSAnnotation) artifactAndFacet.getData(context),
-                 artifactAndFacet.getFacet(), attr, visible);
-        }
-        else {
-            logger.warn("Unknown facet name: " + name);
-            return;
-        }
-    }
-
-
-    /**
-     * Add the waterlevel-curves (the "absolutes" from which
-     * differences were calculated).
-     *
-     * @param wqkms The wqkms to add to the diagram.
-     * @param theme The theme that contains styling information.
-     */
-    protected void doWOut(
-        WKms     wkms,
-        String   description,
-        Document theme,
-        boolean  visible
-    ) {
-        logger.debug("WDifferencesCurveGenerator.doWOut");
-
-        XYSeries series = new StyledXYSeries(description, theme);
-
-        StyledSeriesBuilder.addPoints(series, wkms);
-
-        // Note: the only difference in the super-implementation
-        //  (in LongitudinalSectionGenerator) is here (adds with
-        //  addFirstAxisSeries() .
-        addAxisSeries(series, YAXIS.W.idx, visible);
-
-        if (wkms instanceof WQKms) {
-            if (needInvertAxis((WQKms) wkms)) {
-                setInverted(true);
-            }
-        }
-    }
-
-    /**
      * Add (internationalized) subtitle to chart.
      * Overridden to avoid trying to access the range of masterartifact.
      * @see getChartSubtitleKey
@@ -218,41 +82,6 @@
 
 
     /**
-     * Add items to dataseries which describes the differences.
-     */
-    protected void doWDifferencesOut(
-        WKms     wkms,
-        String   description,
-        Document theme,
-        boolean  visible
-    ) {
-        logger.debug("WDifferencesCurveGenerator.doWDifferencesOut");
-        if (wkms == null) {
-            logger.warn("No data to add to WDifferencesChart.");
-            return;
-         }
-
-        XYSeries series = new StyledXYSeries(description, theme);
-
-        if (logger.isDebugEnabled()) {
-            if (wkms.size() > 0) {
-                logger.debug("Generate series: " + series.getKey());
-                logger.debug("Start km: " + wkms.getKm(0));
-                logger.debug("End   km: " + wkms.getKm(wkms.size()-1));
-                logger.debug("Values  : " + wkms.size());
-            }
-        }
-
-        StyledSeriesBuilder.addPoints(series, wkms);
-
-        addAxisSeries(series, YAXIS.D.idx, visible);
-        if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
-            setInverted(true);
-        }
-    }
-
-
-    /**
      * 
      */
     @Override
--- a/flys-artifacts/src/main/resources/messages.properties	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Mon Dec 05 09:48:44 2011 +0000
@@ -5,6 +5,7 @@
 state.winfo.wq_adapted = Input for W/Q data
 state.winfo.location = Choose the location
 state.winfo.distance = Choose the range
+state.winfo.distance_only = Range selection
 state.winfo.uesk.wsp = Choose the waterlevel
 state.winfo.uesk.dgm = Digital Terrain Model
 state.winfo.uesk.profiles = Interpolated Profiles
--- a/flys-artifacts/src/main/resources/messages_de.properties	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Mon Dec 05 09:48:44 2011 +0000
@@ -5,6 +5,7 @@
 state.winfo.wq_adapted = Eingabe f\u00fcr W/Q Daten
 state.winfo.location = Wahl des Berechnungsortes
 state.winfo.distance = Wahl der Berechnungsstrecke
+state.winfo.distance_only = Wahl der Berechnungsstrecke
 state.winfo.uesk.wsp = Wahl der Wasserspiegellage
 state.winfo.uesk.dgm = Digitales Gel\u00e4ndemodell
 state.winfo.uesk.profiles = Interpolierte Profile
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Mon Dec 05 09:48:44 2011 +0000
@@ -5,6 +5,7 @@
 state.winfo.wq_adapted = Eingabe f\u00fcr W/Q Daten
 state.winfo.location = Wahl des Berechnungsortes
 state.winfo.distance = Wahl der Berechnungsstrecke
+state.winfo.distance_only = Wahl der Berechnungsstrecke
 state.winfo.uesk.wsp = Wahl der Wasserspiegellage
 state.winfo.uesk.dgm = Digitales Gel\u00e4ndemodell
 state.winfo.uesk.profiles = Interpolierte Profile
--- a/flys-artifacts/src/main/resources/messages_en.properties	Fri Dec 02 11:01:11 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Mon Dec 05 09:48:44 2011 +0000
@@ -5,6 +5,7 @@
 state.winfo.wq_adapted = Input for W/Q data
 state.winfo.location = Choose the location
 state.winfo.distance = Choose the range
+state.winfo.distance_only = Range selection
 state.winfo.uesk.wsp = Choose the waterlevel
 state.winfo.uesk.dgm = Digital Terrain Model
 state.winfo.uesk.profiles = Interpolated Profiles

http://dive4elements.wald.intevation.org