changeset 921:610d0e0f4f85

#159 Modifications in the transition model to support a state with a kilometer range input only. flys-artifacts/trunk@2270 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 30 Jun 2011 11:32:17 +0000
parents a618dd6d80ea
children 95356252c309
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputationRangeState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DistanceSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 12 files changed, 381 insertions(+), 217 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jun 30 11:32:17 2011 +0000
@@ -1,3 +1,38 @@
+2011-06-30  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue159 (WINFO: Radiobutton - Ortsauswahl bei "W für ungleichwertigen Abflusslängsschnitt" entfernen)
+
+	* doc/conf/artifacts/winfo.xml: Changed the kilometer range input for
+	  calculation 4. This calculation type requires a kilometer range. So,
+	  after choosing the calculation 4, the transition model leads to a state
+	  that just allows the input of a kilometer range with no option to
+	  enter locations.
+
+	* src/main/java/de/intevation/flys/artifacts/states/ComputationRangeState.java:
+	  New. A base state for the kilometer selection for calculations. The
+	  target of this state is to provide facets for the duration curves.
+
+	* src/main/java/de/intevation/flys/artifacts/states/DistanceSelect.java:
+	  New. This state is used to enter a kilometer range. The difference to
+	  the LocationDistanceSelect state is, that there is no option to enter
+	  locations.
+
+	* src/main/java/de/intevation/flys/artifacts/states/RangeState.java:
+	  Improved this state to be the base state for calculation ranges.
+
+	* src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java
+	  src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java
+
+	* src/main/java/de/intevation/flys/artifacts/states/WQSelect.java: This
+	  state no longer inherits from RangeState which now is used as base
+	  state for kilometer ranges.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Added new i18n strings for
+	  the DistanceSelect state.
+
 2011-06-28  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* pom.xml: Downgraded Trove to 1.1-beta-5, because the new
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Jun 30 11:32:17 2011 +0000
@@ -35,7 +35,7 @@
 
         <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
             <from state="state.winfo.calculation_mode"/>
-            <to state="state.winfo.location_distance"/>
+            <to state="state.winfo.distance"/>
             <condition data="calculation_mode" value="calc.discharge.longitudinal.section" operator="equal"/>
         </transition>
 
@@ -52,6 +52,20 @@
             </outputmodes>
         </state>
 
+        <state id="state.winfo.distance" description="state.winfo.distance" state="de.intevation.flys.artifacts.states.DistanceSelect">
+            <data name="ld_from" type="Double" />
+            <data name="ld_to"   type="Double" />
+            <data name="ld_step" type="Double" />
+
+            <outputmodes>
+                <outputmode name="discharge_curve" description="output.discharge_curve" mime-type="image/png">
+                    <facets>
+                        <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
+                    </facets>
+                </outputmode>
+            </outputmodes>
+        </state>
+
         <state id="state.winfo.location_distance" description="state.winfo.location_distance" state="de.intevation.flys.artifacts.states.LocationDistanceSelect">
             <data name="ld_mode" type="String" />
             <data name="ld_locations" type="Double[]" />
@@ -69,6 +83,11 @@
             </outputmodes>
         </state>
 
+        <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
+            <from state="state.winfo.distance"/>
+            <to state="state.winfo.wq_adapted"/>
+        </transition>
+
         <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
             <from state="state.winfo.location_distance"/>
             <to state="state.winfo.wq"/>
@@ -76,12 +95,6 @@
         </transition>
 
         <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
-            <from state="state.winfo.location_distance"/>
-            <to state="state.winfo.wq_adapted"/>
-            <condition data="calculation_mode" value="calc.discharge.longitudinal.section" operator="equal"/>
-        </transition>
-
-        <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
             <from state="state.winfo.location"/>
             <to state="state.winfo.durationcurve"/>
             <condition data="calculation_mode" value="calc.duration.curve" operator="equal"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputationRangeState.java	Thu Jun 30 11:32:17 2011 +0000
@@ -0,0 +1,223 @@
+package de.intevation.flys.artifacts.states;
+
+import java.util.List;
+
+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.artifactdatabase.state.Facet;
+
+import de.intevation.flys.model.River;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.RiverFactory;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
+import de.intevation.flys.artifacts.model.WQKms;
+import de.intevation.flys.artifacts.resources.Resources;
+
+/**
+ * @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 name of the 'from' field. */
+    public static final String FROM = "ld_from";
+
+    /** The name of the 'to' field. */
+    public static final String TO = "ld_to";
+
+    /** The name of the 'step' field. */
+    public static final String STEP = "ld_step";
+
+    /** 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);
+
+        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
+    public Object computeFeed(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets,
+        Object       old
+    ) {
+        logger.debug("computeFeed");
+
+        WINFOArtifact winfo = (WINFOArtifact)artifact;
+
+        CalculationResult res = old instanceof CalculationResult
+            ? (CalculationResult)old
+            : winfo.getDischargeCurveData();
+
+        if (facets == null) {
+            logger.debug("generate no facets");
+            return res;
+        }
+
+        WQKms [] wqkms = (WQKms [])res.getData();
+
+        logger.debug("generate " + wqkms.length + " facets.");
+
+        String stateID = winfo.getCurrentStateId();
+
+        for (int i = 0; i < wqkms.length; ++i) {
+            String name = wqkms[i].getName();
+            facets.add(new WaterlevelFacet(
+                i, DISCHARGE_CURVE, name, ComputeType.FEED, stateID, hash));
+        }
+
+
+        return res;
+    }
+
+
+    @Override
+    protected double[] getMinMax(Artifact artifact) {
+        FLYSArtifact flysArtifact = (FLYSArtifact) artifact;
+        StateData    data         = getData(flysArtifact, "river");
+
+        String name = data != null ? (String) data.getValue() : "";
+
+        logger.debug("Search for the min/max distances of '" + name + "'");
+
+        River river = RiverFactory.getRiver(name);
+
+        return river != null ? river.determineMinMaxDistance() : null;
+    }
+
+
+    protected double getDefaultStep() {
+        return DEFAULT_STEP;
+    }
+
+
+    @Override
+    protected String getLowerField() {
+        return FROM;
+    }
+
+
+    @Override
+    protected String getUpperField() {
+        return TO;
+    }
+
+
+    @Override
+    protected String getStepField() {
+        return STEP;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DistanceSelect.java	Thu Jun 30 11:32:17 2011 +0000
@@ -0,0 +1,24 @@
+package de.intevation.flys.artifacts.states;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class DistanceSelect extends ComputationRangeState {
+
+    /** The logger used in this class.*/
+    private static Logger logger = Logger.getLogger(DistanceSelect.class);
+
+
+    public DistanceSelect() {
+    }
+
+
+    @Override
+    protected String getUIProvider() {
+        return "distance_panel";
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Thu Jun 30 11:32:17 2011 +0000
@@ -1,64 +1,34 @@
 package de.intevation.flys.artifacts.states;
 
-import java.util.List;
-
 import org.apache.log4j.Logger;
 
-import org.w3c.dom.Element;
-
 import gnu.trove.TDoubleArrayList;
 
 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.artifactdatabase.state.Facet;
-
-import de.intevation.flys.model.River;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.WINFOArtifact;
 
-import de.intevation.flys.artifacts.model.RiverFactory;
-import de.intevation.flys.artifacts.model.WQKms;
-import de.intevation.flys.artifacts.model.CalculationResult;
-import de.intevation.flys.artifacts.model.WaterlevelFacet;
-import de.intevation.flys.artifacts.model.FacetTypes;
-
-import de.intevation.flys.artifacts.resources.Resources;
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class LocationDistanceSelect
-extends      RangeState
-implements   FacetTypes
+extends      ComputationRangeState
 {
 
     /** The logger used in this class.*/
     private static Logger logger = Logger.getLogger(LocationDistanceSelect.class);
 
 
-    /** The default step width.*/
-    public static final String DEFAULT_STEP = "100";
-
     /** The name of the 'mode' field. */
     public static final String MODE = "ld_mode";
 
     /** The name of the 'locations' field.*/
     public static final String LOCATIONS = "ld_locations";
 
-    /** The name of the 'from' field. */
-    public static final String FROM = "ld_from";
-
-    /** The name of the 'to' field. */
-    public static final String TO = "ld_to";
-
-    /** The name of the 'step' field. */
-    public static final String STEP = "ld_step";
 
     /**
      * The default constructor that initializes an empty State object.
@@ -66,92 +36,6 @@
     public LocationDistanceSelect() {
     }
 
-    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);
-
-        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 = getMinMaxDistance(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", DEFAULT_STEP});
-            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 String getUIProvider() {
@@ -159,20 +43,6 @@
     }
 
 
-    protected double[] getMinMaxDistance(Artifact artifact) {
-        FLYSArtifact flysArtifact = (FLYSArtifact) artifact;
-        StateData    data         = getData(flysArtifact, "river");
-
-        String name = data != null ? (String) data.getValue() : "";
-
-        logger.debug("Search for the min/max distances of '" + name + "'");
-
-        River river = RiverFactory.getRiver(name);
-
-        return river != null ? river.determineMinMaxDistance() : null;
-    }
-
-
     @Override
     public boolean validate(Artifact artifact, CallContext context)
     throws IllegalArgumentException
@@ -182,7 +52,7 @@
         FLYSArtifact flys = (FLYSArtifact) artifact;
 
         if (flys.isRange()) {
-            return validateRange(flys, context);
+            return super.validate(flys, context);
         }
         else {
             return validateLocations(flys, context);
@@ -200,7 +70,7 @@
             throw new IllegalArgumentException("error_empty_state");
         }
 
-        double[] absMinMax = getMinMaxDistance(flys);
+        double[] absMinMax = getMinMax(flys);
         double[] relMinMax = getMinMaxFromString(values);
 
         if (relMinMax[0] < absMinMax[0] || relMinMax[0] > absMinMax[1]) {
@@ -215,36 +85,6 @@
     }
 
 
-    protected boolean validateRange(FLYSArtifact flys, CallContext context)
-    throws    IllegalArgumentException
-    {
-        StateData dFrom = getData(flys, FROM);
-        StateData dTo   = getData(flys, TO);
-        StateData dStep = getData(flys, STEP);
-
-        String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
-        String toStr   = dTo != null ? (String) dTo.getValue() : null;
-        String stepStr = dStep != null ? (String) dStep.getValue() : null;
-
-        if (fromStr == null || toStr == null || stepStr == null) {
-            throw new IllegalArgumentException("error_empty_state");
-        }
-
-        try {
-            double from = Double.parseDouble(fromStr);
-            double to   = Double.parseDouble(toStr);
-            double step = Double.parseDouble(stepStr);
-
-            double[] minmaxDist = getMinMaxDistance(flys);
-
-            return validateBounds(minmaxDist[0], minmaxDist[1], from, to, step);
-        }
-        catch (NumberFormatException nfe) {
-            throw new IllegalArgumentException("error_invalid_double_value");
-        }
-    }
-
-
     /**
      * Extracts the min/max values from String <i>s</i>. An
      * IllegalArgumentException is thrown if there is a value that throws a
@@ -303,43 +143,5 @@
 
         return values.toNativeArray();
     }
-
-
-    @Override
-    public Object computeFeed(
-        FLYSArtifact artifact,
-        String       hash,
-        CallContext  context,
-        List<Facet>  facets,
-        Object       old
-    ) {
-        logger.debug("computeFeed");
-
-        WINFOArtifact winfo = (WINFOArtifact)artifact;
-
-        CalculationResult res = old instanceof CalculationResult
-            ? (CalculationResult)old
-            : winfo.getDischargeCurveData();
-
-        if (facets == null) {
-            logger.debug("generate no facets");
-            return res;
-        }
-
-        WQKms [] wqkms = (WQKms [])res.getData();
-
-        logger.debug("generate " + wqkms.length + " facets.");
-
-        String stateID = winfo.getCurrentStateId();
-
-        for (int i = 0; i < wqkms.length; ++i) {
-            String name = wqkms[i].getName();
-            facets.add(new WaterlevelFacet(
-                i, DISCHARGE_CURVE, name, ComputeType.FEED, stateID, hash));
-        }
-
-
-        return res;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java	Thu Jun 30 11:32:17 2011 +0000
@@ -50,7 +50,7 @@
         String      name,
         CallContext context)
     {
-        double[] minmax = getMinMaxDistance(artifact);
+        double[] minmax = getMinMax(artifact);
 
         double minVal = Double.MIN_VALUE;
         double maxVal = Double.MAX_VALUE;
@@ -95,7 +95,7 @@
             throw new IllegalArgumentException("error_empty_state");
         }
 
-        double[] minmax = getMinMaxDistance(artifact);
+        double[] minmax = getMinMax(artifact);
         double[] mm     = extractLocations(locationStr);
 
         logger.debug("Inserted min location: " + mm[0]);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java	Thu Jun 30 11:32:17 2011 +0000
@@ -2,6 +2,13 @@
 
 import org.apache.log4j.Logger;
 
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.data.StateData;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -9,13 +16,19 @@
 public abstract class RangeState extends DefaultState {
 
     /** The logger that is used in this class.*/
-    private static Logger logger = Logger.getLogger(RangeState.class);
+    private Logger logger = Logger.getLogger(RangeState.class);
 
 
     public RangeState() {
     }
 
 
+    protected abstract String   getLowerField();
+    protected abstract String   getUpperField();
+    protected abstract String   getStepField();
+    protected abstract double[] getMinMax(Artifact artifact);
+
+
     /**
      * Validates a given range with a given valid range.
      *
@@ -44,13 +57,41 @@
                 "Invalid 'to'. " + to + " is bigger than " + toValid);
             throw new IllegalArgumentException("error_feed_to_out_of_range");
         }
-        /*
-        else if (from > to) {
-            throw new IllegalArgumentException("error_feed_from_bigger_to");
-        }
-        */
 
         return true;
     }
+
+
+    @Override
+    public boolean validate(Artifact artifact, CallContext context)
+    throws IllegalArgumentException
+    {
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+
+        StateData dFrom = getData(flys, getLowerField());
+        StateData dTo   = getData(flys, getUpperField());
+        StateData dStep = getData(flys, getStepField());
+
+        String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
+        String toStr   = dTo   != null ? (String) dTo.getValue()   : null;
+        String stepStr = dStep != null ? (String) dStep.getValue() : null;
+
+        if (fromStr == null || toStr == null || stepStr == null) {
+            throw new IllegalArgumentException("error_empty_state");
+        }
+
+        try {
+            double from = Double.parseDouble(fromStr);
+            double to   = Double.parseDouble(toStr);
+            double step = Double.parseDouble(stepStr);
+
+            double[] minmax = getMinMax(flys);
+
+            return validateBounds(minmax[0], minmax[1], from, to, step);
+        }
+        catch (NumberFormatException nfe) {
+            throw new IllegalArgumentException("error_invalid_double_value");
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Thu Jun 30 11:32:17 2011 +0000
@@ -25,7 +25,7 @@
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class WQSelect extends RangeState {
+public class WQSelect extends DefaultState {
 
     /** The logger used in this class.*/
     private static Logger logger = Logger.getLogger(WQSelect.class);
@@ -219,6 +219,28 @@
     }
 
 
+    protected boolean validateBounds(
+        double fromValid, double toValid,
+        double from,      double to,      double step)
+    throws IllegalArgumentException
+    {
+        logger.debug("RangeState.validateRange");
+
+        if (from < fromValid) {
+            logger.error(
+                "Invalid 'from'. " + from + " is smaller than " + fromValid);
+            throw new IllegalArgumentException("error_feed_from_out_of_range");
+        }
+        else if (to > toValid) {
+            logger.error(
+                "Invalid 'to'. " + to + " is bigger than " + toValid);
+            throw new IllegalArgumentException("error_feed_to_out_of_range");
+        }
+
+        return true;
+    }
+
+
     protected boolean validateSingle(Artifact artifact, CallContext context)
     throws    IllegalArgumentException
     {
--- a/flys-artifacts/src/main/resources/messages.properties	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Thu Jun 30 11:32:17 2011 +0000
@@ -4,6 +4,7 @@
 state.winfo.wq = Input for W/Q data
 state.winfo.wq_adapted = Input for W/Q data
 state.winfo.location = Choose the location
+state.winfo.distance = Choose the range
 
 calc.surface.curve = Water Level/Surface Curve
 calc.flood.map = Flood Plain
--- a/flys-artifacts/src/main/resources/messages_de.properties	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Thu Jun 30 11:32:17 2011 +0000
@@ -4,6 +4,7 @@
 state.winfo.wq = Eingabe f\u00fcr W/Q Daten
 state.winfo.wq_adapted = Eingabe f\u00fcr W/Q Daten
 state.winfo.location = Wahl des Berechnungsortes
+state.winfo.distance = Wahl der Berechnungsstrecke
 
 calc.surface.curve = Wasserstand/Wasserspiegellage
 calc.flood.map = \u00dcberschwemmungsfl\u00e4che
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Thu Jun 30 11:32:17 2011 +0000
@@ -4,6 +4,7 @@
 state.winfo.wq = Eingabe f\u00fcr W/Q Daten
 state.winfo.wq_adapted = Eingabe f\u00fcr W/Q Daten
 state.winfo.location = Wahl des Berechnungsortes
+state.winfo.distance = Wahl der Berechnungsstrecke
 
 calc.surface.curve = Wasserstand/Wasserspiegellage
 calc.flood.map = \u00dcberschwemmungsfl\u00e4che
--- a/flys-artifacts/src/main/resources/messages_en.properties	Wed Jun 29 09:00:31 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Thu Jun 30 11:32:17 2011 +0000
@@ -4,6 +4,7 @@
 state.winfo.wq = Input for W/Q data
 state.winfo.wq_adapted = Input for W/Q data
 state.winfo.location = Choose the location
+state.winfo.distance = Choose the range
 
 calc.surface.curve = Water Level/Surface Curve
 calc.flood.map = Flood Plain

http://dive4elements.wald.intevation.org