Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputationRangeState.java @ 5827:e308d4ecd35a
Fixed pom for etl process.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 11:48:36 +0200 |
parents | 1358d0c8481c |
children |
line wrap: on
line source
package de.intevation.flys.artifacts.states; import org.apache.log4j.Logger; import org.w3c.dom.Element; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifactdatabase.ProtocolUtils; import de.intevation.artifactdatabase.data.StateData; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.utils.FLYSUtils; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ComputationRangeState extends RangeState implements FacetTypes { private static Logger logger = Logger.getLogger(ComputationRangeState.class); /** The default step width. */ public static final int DEFAULT_STEP = 100; public ComputationRangeState() { } @Override protected Element createData( XMLUtils.ElementCreator cr, Artifact artifact, StateData data, CallContext context) { Element select = ProtocolUtils.createArtNode( cr, "select", null, null); cr.addAttr(select, "name", data.getName(), true); Element label = ProtocolUtils.createArtNode( cr, "label", null, null); // XXX: DEAD CODE /* Element choices = ProtocolUtils.createArtNode( cr, "choices", null, null); */ label.setTextContent(Resources.getMsg( context.getMeta(), data.getName(), data.getName())); select.appendChild(label); return select; } @Override protected Element[] createItems( XMLUtils.ElementCreator cr, Artifact artifact, String name, CallContext context) { double[] minmax = getMinMax(artifact); double minVal = Double.MIN_VALUE; double maxVal = Double.MAX_VALUE; if (minmax != null) { minVal = minmax[0]; maxVal = minmax[1]; } else { logger.warn("Could not read min/max distance values!"); } if (name.equals("ld_from")) { Element min = createItem( cr, new String[] {"min", new Double(minVal).toString()}); return new Element[] { min }; } else if (name.equals("ld_to")) { Element max = createItem( cr, new String[] {"max", new Double(maxVal).toString()}); return new Element[] { max }; } else { Element step = createItem( cr, new String[] {"step", String.valueOf(getDefaultStep())}); return new Element[] { step }; } } protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { Element item = ProtocolUtils.createArtNode(cr, "item", null, null); Element label = ProtocolUtils.createArtNode(cr, "label", null, null); Element value = ProtocolUtils.createArtNode(cr, "value", null, null); String[] arr = (String[]) obj; label.setTextContent(arr[0]); value.setTextContent(arr[1]); item.appendChild(label); item.appendChild(value); return item; } @Override protected double[] getMinMax(Artifact artifact) { FLYSArtifact flysArtifact = (FLYSArtifact) artifact; return FLYSUtils.getRiverMinMax(flysArtifact); } protected double getDefaultStep() { return DEFAULT_STEP; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :