changeset 1141:bcba246d9c03

Fix various issues like i18n in cross section diagrams. flys-artifacts/trunk@2662 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 07 Sep 2011 10:37:14 +0000
parents 96d7842e80ee
children 01d42a2454f6
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java
diffstat 3 files changed, 52 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Sep 07 09:26:34 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Sep 07 10:37:14 2011 +0000
@@ -1,3 +1,22 @@
+2011-09-07  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Fix various display-issues like i18n in cross-section diagram.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java:
+	  Set description of facets to expected values.
+
+	* src/main/java/de/intevation/flys/artifacts/exports/CrossSectionGenerator.java:
+	  Fix i18n of chart title. Set subtitle to expected value, pass facets
+	  description to StyledSeries to see expected legend.
+
+2011-09-07  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Cosmetics, resolved refactoring todo.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java
+	  (compute, computeAdvance, computeFeed): Refactored, extracted method,
+	  resolving duplicate code and TODO.
+
 2011-09-07  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Fix waterline "calculation" at given km. Chosen approach is
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Wed Sep 07 09:26:34 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Wed Sep 07 10:37:14 2011 +0000
@@ -94,8 +94,9 @@
         }
 
         // Also register the CrossSectionFacet (added to respective out).
-        facets.add(new CrossSectionFacet("facet.cross_section"));
-        facets.add(new CrossSectionWaterLineFacet("facet.cross_section_water_line"));
+        facets.add(new CrossSectionFacet(winfo.getCrossSectionName()));
+        // Assume to be in wq_single mode.
+        facets.add(new CrossSectionWaterLineFacet("Q=" + winfo.getDataAsString("wq_single")));
         return res;
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Wed Sep 07 09:26:34 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Wed Sep 07 10:37:14 2011 +0000
@@ -17,6 +17,7 @@
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
 
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQKms;
@@ -61,7 +62,10 @@
      */
     protected String getChartTitle() {
         // TODO get river etc for localized heading
-        return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
+        Object[] i18n_msg_args = new Object[] {
+            getRiverName()
+        };
+        return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, i18n_msg_args);
     }
 
 
@@ -74,8 +78,7 @@
 
         Object[] args = new Object[] {
             getRiverName(),
-            dist[0],
-            dist[1]
+            getKm()
         };
 
         String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
@@ -92,6 +95,21 @@
 
 
     /**
+     * Get cross_section.km data from artifact.
+     */
+    protected Double getKm() {
+        try {
+            WINFOArtifact winfo = (WINFOArtifact) master;
+            return Double.parseDouble(winfo.getDataAsString("cross_section.km"));
+        }
+        catch (Exception e) {
+            logger.error("Cannot convert cross_section.km to double");
+            return 0.0d;
+        }
+    }
+
+
+    /**
      * Get localized Y Axis label.
      */
     protected String getYAxisLabel() {
@@ -144,10 +162,10 @@
         }
 
         if (name.equals(CROSS_SECTION)) {
-            doCrossSectionOut(f.getData(artifact, context), attr);
+            doCrossSectionOut(f.getData(artifact, context), f.getDescription(), attr);
         }
         else if (name.equals(CROSS_SECTION_WATER_LINE)) {
-            doCrossSectionWaterLineOut(f.getData(artifact, context), attr);
+            doCrossSectionWaterLineOut(f.getData(artifact, context), f.getDescription(), attr);
         }
         else {
             logger.warn("CrossSection.doOut: Unknown facet name: " + name);
@@ -159,12 +177,13 @@
     /**
      * Do cross sections waterline out.
      *
+     * @param seriesName name of the data (line) to display in legend.
      * @param theme Theme for the data series.
      */
-    protected void doCrossSectionWaterLineOut(Object o, Document theme) {
+    protected void doCrossSectionWaterLineOut(Object o, String seriesName, Document theme) {
         logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut");
-        // TODO Series should get name like "Q=22.0"
-        XYSeries series = new StyledXYSeries("Q= ... ", theme);
+
+        XYSeries series = new StyledXYSeries(seriesName, theme);
 
         double[][] a = (double [][]) o;
         double [] pxs = a[0];
@@ -178,15 +197,13 @@
     /**
      * Do cross sections out.
      *
+     * @param seriesName name of the data (line) to display in legend.
      * @param theme Theme for the data series.
      */
-    protected void doCrossSectionOut(Object o, Document theme) {
+    protected void doCrossSectionOut(Object o, String seriesName, Document theme) {
         logger.debug("CrossSectionGenerator.doCrossSectionOut");
 
-        // TODO Series should get name of selected cross-section (e.g. 
-        // "0-93.1(1990-2002).PRF") (exposed as getCrossSectionName in
-        //  WINFOArtifact)
-        XYSeries series = new StyledXYSeries("aliquide", theme);
+        XYSeries series = new StyledXYSeries(seriesName, theme);
 
         double[][] a = (double [][]) o;
         double [] pxs = a[0];

http://dive4elements.wald.intevation.org