Mercurial > dive4elements > river
changeset 2025:6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
flys-artifacts/trunk@3482 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 20 Dec 2011 09:01:29 +0000 |
parents | 2bb160b2768e |
children | 9d79f6ceefca |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java |
diffstat | 2 files changed, 50 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Dec 20 09:00:51 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Dec 20 09:01:29 2011 +0000 @@ -1,3 +1,10 @@ +2011-12-20 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/states/WQSelect.java: + Create all formatted string labels for Ws and Qs in this class, because + this class is the only instance that knows that there are double values + to format. + 2011-12-20 Felix Wolfsteller <felix.wolfsteller@intevation.de> Introduced new Facet that will deliver whatever getData returns via
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Tue Dec 20 09:00:51 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Tue Dec 20 09:01:29 2011 +0000 @@ -89,9 +89,6 @@ String mode = flys.getDataAsString(WQ_MODE); String free = flys.getDataAsString(WQ_FREE); - if (mode == null || mode.equals("W") || Boolean.valueOf(free)) { - return super.createStaticData(flys, creator, cc, name, value, type); - } WINFOArtifact winfo = (WINFOArtifact) flys; @@ -101,7 +98,17 @@ Element itemElement = creator.create("item"); creator.addAttr(itemElement, "value", value, true); - creator.addAttr(itemElement, "label", getLabel(winfo, cc, value), true); + + String label = ""; + + if (mode == null || mode.equals("W") || Boolean.valueOf(free)) { + label = getLabel(winfo, cc, value); + } + else { + label = getSpecialLabel(winfo, cc, value); + } + + creator.addAttr(itemElement, "label", label, true); dataElement.appendChild(itemElement); @@ -124,15 +131,45 @@ try { double v = Double.valueOf(value.trim()); + String formatted = nf.format(v); + + label = label != null ? label + " " + formatted : formatted; + } + catch (NumberFormatException nfe) { + // do nothing here + } + } + + return label; + } + + + protected static String getSpecialLabel( + WINFOArtifact winfo, + CallContext cc, + String raw + ) { + String[] values = raw.split(" "); + String label = null; + + NumberFormat nf = NumberFormat.getInstance( + Resources.getLocale(cc.getMeta())); + + for (String value: values) { + try { + double v = Double.valueOf(value.trim()); + String tmp = nf.format(v); String mv = FLYSUtils.getNamedMainValue(winfo.getGauge(),v); if (mv != null && mv.length() > 0) { String add = mv + ": " + tmp; - label = label != null ? label + ", " + add : add; + logger.debug("Add main value: '" + mv + "'"); + label = label != null ? label + " " + add : add; } else { - label = label != null ? label + ", " + tmp : tmp; + logger.debug("Add non main value: '" + tmp + "'"); + label = label != null ? label + " " + tmp : tmp; } } catch (NumberFormatException nfe) {