Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 2205:a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
flys-artifacts/trunk@3829 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 30 Jan 2012 13:29:07 +0000 |
parents | 19518116a49a |
children | 4cd0eb2ebb3b |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Mon Jan 30 13:23:40 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Mon Jan 30 13:29:07 2012 +0000 @@ -112,10 +112,13 @@ return; } - logger.debug("Append element '" + name + "' (" + value + ")"); + String type = data.getType(); - Element e = createStaticData( - flys, cr, context, name, value, data.getType()); + logger.debug( + "Append element " + type + "'" + + name + "' (" + value + ")"); + + Element e = createStaticData(flys, cr, context, name, value, type); ui.appendChild(e); @@ -141,8 +144,6 @@ String value, String type ) { - CallMeta meta = cc.getMeta(); - Element dataElement = creator.create("data"); creator.addAttr(dataElement, "name", name, true); creator.addAttr(dataElement, "type", type, true); @@ -150,7 +151,34 @@ Element itemElement = creator.create("item"); creator.addAttr(itemElement, "value", value, true); - String attrValue = ""; + creator.addAttr( + itemElement, + "label", + getLabelFor(cc, name, value, type), + true); + + dataElement.appendChild(itemElement); + + return dataElement; + } + + + /** + * @param cc + * @param name + * @param value + * @param type + * + * @return + */ + protected String getLabelFor( + CallContext cc, + String name, + String value, + String type + ) { + CallMeta meta = cc.getMeta(); + try { // XXX A better way to format the output would be to use the // 'type' value of the data objects. @@ -158,16 +186,11 @@ Locale l = Resources.getLocale(meta); NumberFormat nf = NumberFormat.getInstance(l); - attrValue = nf.format(doubleVal); + return nf.format(doubleVal); } catch (NumberFormatException nfe) { - attrValue = Resources.getMsg(meta, value, value); + return Resources.getMsg(meta, value, value); } - - creator.addAttr(itemElement, "label", attrValue, true); - dataElement.appendChild(itemElement); - - return dataElement; } @@ -356,11 +379,15 @@ public StateData transform( FLYSArtifact flys, CallContext cc, + StateData stateData, String name, String val ) { logger.debug("Transform data ('" + name + "','" + val + "')"); - return new DefaultStateData(name, null, null, val); + + stateData.setValue(val); + + return stateData; }