Mercurial > dive4elements > river
changeset 1664:71d5abde92f2
Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
flys-artifacts/trunk@2869 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 30 Sep 2011 08:02:21 +0000 |
parents | 4fbd43061315 |
children | 0ebce697adcc |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java |
diffstat | 2 files changed, 75 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Sep 30 05:31:34 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Sep 30 08:02:21 2011 +0000 @@ -1,3 +1,11 @@ +2011-09-29 Ingo Weinzierl <ingo@intevation.de> + + flys/issue176 (Diagramm: Benennung eines Abflusses bei gewählter Höhe am Pegel) + flys/issue349 (W-INFO / Wasserspiegellagenberechnung, Längsschnittdiagramm) + + * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java: + Create titles for W and Q waterlevel facets with proper fractions. + 2011-09-30 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Fri Sep 30 05:31:34 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Fri Sep 30 08:02:21 2011 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts.states; +import java.text.NumberFormat; import java.util.List; import org.apache.log4j.Logger; @@ -10,15 +11,15 @@ import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.WINFOArtifact; +import de.intevation.flys.artifacts.model.DataFacet; +import de.intevation.flys.artifacts.model.CrossSectionFacet; +import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; +import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.ReportFacet; import de.intevation.flys.artifacts.model.WaterlevelFacet; import de.intevation.flys.artifacts.model.WQKms; - -import de.intevation.flys.artifacts.model.DataFacet; -import de.intevation.flys.artifacts.model.CrossSectionFacet; -import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; -import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.flys.utils.Formatter; public class WaterlevelState @@ -37,6 +38,7 @@ protected Object compute( WINFOArtifact winfo, + CallContext cc, String hash, List<Facet> facets, Object old @@ -54,17 +56,11 @@ WQKms [] wqkms = (WQKms [])res.getData(); for (int i = 0; i < wqkms.length; i++) { - String nameW = null; - String nameQ = null; + String name = wqkms[i].getName(); + boolean isQ = winfo.isQ(); - if (winfo.isQ()) { - nameQ = wqkms[i].getName(); - nameW = "W(" + nameQ + ")"; - } - else { - nameW = wqkms[i].getName(); - nameQ = "Q(" + nameQ + ")"; - } + String nameW = createWTitle(cc, name, isQ); + String nameQ = createQTitle(cc, name, isQ); logger.debug("Create facet: " + nameW); logger.debug("Create facet: " + nameQ); @@ -100,6 +96,60 @@ } + public static String createWTitle(CallContext cc, String name, boolean isQ) { + String[] parts = name.split("="); + + NumberFormat nf = Formatter.getWaterlevelW(cc); + + double v; + + try { + v = Double.valueOf(parts[1]); + } + catch (NumberFormatException nfe) { + logger.warn("Cannot parse Double of: '" + parts[1] + "'"); + return name; + } + + String prefix = null; + + if (isQ) { + prefix = "Q="; + } + + return prefix == null + ? "W(" + nf.format(v) + ")" + : "W(" + prefix + nf.format(v) + ")"; + } + + + public static String createQTitle(CallContext cc, String name, boolean isQ) { + String[] parts = name.split("="); + + NumberFormat nf = Formatter.getWaterlevelQ(cc); + + double v; + + try { + v = Double.valueOf(parts[1]); + } + catch (NumberFormatException nfe) { + logger.warn("Cannot parse Double of: '" + parts[1] + "'"); + return name; + } + + String prefix = null; + + if (!isQ) { + prefix = "W="; + } + + return prefix == null + ? "Q(" + nf.format(v) + ")" + : "Q(" + prefix + nf.format(v) + ")"; + } + + /** * @param context Ignored. */ @@ -111,7 +161,7 @@ List<Facet> facets, Object old ) { - return compute((WINFOArtifact) artifact, hash, facets, old); + return compute((WINFOArtifact) artifact, context, hash, facets, old); } @@ -127,7 +177,7 @@ List<Facet> facets, Object old ) { - return compute((WINFOArtifact) artifact, hash, facets, old); + return compute((WINFOArtifact) artifact, context, hash, facets, old); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :