changeset 2251:c9c788eea200

Improved reference curve. flys-artifacts/trunk@3900 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 03 Feb 2012 13:49:16 +0000
parents 40608c82e9cb
children 28ba4889a3c1
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/EnterLocationState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/InputDoubleState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.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, 177 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 03 13:49:16 2012 +0000
@@ -1,3 +1,33 @@
+2012-02-03  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Improved Reference Curves.
+
+	* doc/conf/artifacts/winfo.xml: Add start/end input step for reference
+	  curves.
+
+	* doc/conf/themes.xml: Add theme for reference curve.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java:
+	  Disable start/end point-hack for reference curve. Go with 'live'
+	  values.
+
+	* src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java:
+	  i18n.
+
+	* src/main/java/de/intevation/flys/artifacts/states/EnterLocationState.java:
+	  New. State to enter location.
+
+	* src/main/java/de/intevation/flys/artifacts/states/InputDoubleState.java:
+	  New.
+
+	* src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java:
+	  Take WW name to display in themepanel.
+
+	* 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 translations.
+
 2012-02-03  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/Calculation6.java: Use
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Fri Feb 03 13:49:16 2012 +0000
@@ -64,7 +64,7 @@
 
         <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
             <from state="state.winfo.calculation_mode"/>
-            <to state="state.winfo.reference.curve.input"/>
+            <to state="state.winfo.reference.curve.input.start"/>
             <condition data="calculation_mode" value="calc.reference.curve" operator="equal"/>
         </transition>
 
@@ -173,13 +173,24 @@
             <data name="diffids" type="String" />
         </state>
 
-        <state id="state.winfo.reference.curve.input" description="state.winfo.reference.curve.input" state="de.intevation.flys.artifacts.states.LocationSelect">
-        <!--state="de.intevation.flys.artifacts.states.ReferenceCurveInputState">-->
-            <data name="ld_locations" type="Double[]"/>
-            <!--data name="reference_start" type="Double"/-->
-            <!--data name="reference_end"   type="Double[]"/-->
+        <state id="state.winfo.reference.curve.input.start" description="state.winfo.reference.curve.input (start)" state="de.intevation.flys.artifacts.states.EnterLocationState">
+            <data name="reference.startpoint" type="Double[]"/>
         </state>
 
+        <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
+            <from state="state.winfo.reference.curve.input.start"/>
+            <to   state="state.winfo.reference.curve.input.end"/>
+        </transition>
+
+        <state id="state.winfo.reference.curve.input.end" description="state.winfo.reference.curve.input (end)" state="de.intevation.flys.artifacts.states.EnterLocationState">
+            <data name="reference.endpoint" type="Double[]"/>
+        </state>
+
+        <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
+            <from state="state.winfo.reference.curve.input.end"/>
+            <to state="state.winfo.reference.curve"/>
+        </transition>
+
         <state id="state.winfo.reference.curve" description="state.winfo.reference.curve" state="de.intevation.flys.artifacts.states.ReferenceCurveState">
             <outputmodes>
                 <outputmode name="reference_curve" mime-type="image/png" type="chart">
@@ -190,11 +201,6 @@
             </outputmodes>
         </state>
 
-        <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
-            <from state="state.winfo.reference.curve.input"/>
-            <to state="state.winfo.reference.curve"/>
-        </transition>
-
         <state id="state.winfo.w_differences" description="state.winfo.w_differences" state="de.intevation.flys.artifacts.states.WDifferencesState">
 
             <outputmodes>
--- a/flys-artifacts/doc/conf/themes.xml	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Fri Feb 03 13:49:16 2012 +0000
@@ -602,6 +602,16 @@
         </fields>
     </theme>
 
+    <!-- Reference Curves -->
+    <theme name="ReferenceCurve">
+        <inherits>
+            <inherit from="HiddenColorLines"/>
+            <inherit from="MinMaxPoints"/>
+        </inherits>
+       <fields>
+         <field name="linecolor" type="Color" display="Linienfarbe" default="204, 204, 204"/>
+       </fields>
+    </theme>
 
     <!-- General -->
     <theme name="WKms">
@@ -958,5 +968,6 @@
         <mapping from="hyk" to="Hyk"/>
         <mapping from="longitudinal_section.area" to="Area"/>
         <mapping from="manualpoints" to="ManualPoints"/>
+        <mapping from="reference_curve" to="ReferenceCurve"/>
     </mappings>
 </themes>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Feb 03 13:49:16 2012 +0000
@@ -685,19 +685,18 @@
     }
 
 
+    /** Get reference (start) km. */
     protected Double getReferenceStartKm() {
-        if (true) {
-            return FLYSUtils.getLocations(this)[0];
-        }
-
-        StateData sd = getData("reference_start");
+        StateData sd = getData("reference.startpoint");
 
         if (sd == null) {
             logger.warn("no reference start given.");
             return null;
         }
 
-        String input = (String)sd.getValue();
+        logger.debug("Reference start km given: " + sd.getValue());
+
+        String input = (String) sd.getValue();
 
         if (input == null | (input = input.trim()).length() == 0) {
             logger.warn("reference start string is empty.");
@@ -714,18 +713,19 @@
         return null;
     }
 
+
     protected double [] getReferenceEndKms() {
-        StateData sd = getData("reference_end");
-
-        if(true)
-        return new double[] {getReferenceStartKm() + 2.0d};
+        StateData sd = getData("reference.endpoint");
 
         if (sd == null) {
             logger.warn("no reference end given.");
             return null;
         }
+        else {
+            logger.debug("Reference end km : " + sd.getValue());
+        }
 
-        String input = (String)sd.getValue();
+        String input = (String) sd.getValue();
 
         if (input == null | (input = input.trim()).length() == 0) {
             logger.warn("reference end string is empty.");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/EnterLocationState.java	Fri Feb 03 13:49:16 2012 +0000
@@ -0,0 +1,53 @@
+package de.intevation.flys.artifacts.states;
+
+import java.util.Calendar;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.hibernate.Session;
+import org.hibernate.SQLQuery;
+import org.hibernate.type.StandardBasicTypes;
+
+import de.intevation.flys.model.Gauge;
+import de.intevation.flys.backend.SessionHolder;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.utils.FLYSUtils;
+
+
+/**
+ * Get me a double startpoint.
+ */
+public class EnterLocationState extends InputDoubleState {
+
+    private static final Logger logger =
+        Logger.getLogger(EnterLocationState.class);
+
+
+    @Override
+    protected String getUIProvider() {
+        return "location_panel";
+    }
+
+
+    @Override
+    protected Object getLower(FLYSArtifact flys) {
+        double[] lowerUpper = FLYSUtils.getRiverMinMax(flys);
+
+        return lowerUpper != null
+            ? lowerUpper[0]
+            : 0;
+    }
+
+
+    @Override
+    protected Object getUpper(FLYSArtifact flys) {
+        double[] lowerUpper = FLYSUtils.getRiverMinMax(flys);
+
+        return lowerUpper != null
+            ? lowerUpper[1]
+            : 0;
+    }
+}
+// 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/InputDoubleState.java	Fri Feb 03 13:49:16 2012 +0000
@@ -0,0 +1,39 @@
+package de.intevation.flys.artifacts.states;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+
+
+/**
+ * State to keep a double value and validate it against a range
+ */
+public class InputDoubleState extends MinMaxState {
+
+    private static final Logger logger = Logger.getLogger(InputDoubleState.class);
+
+
+    @Override
+    protected String getUIProvider() {
+        return "location_panel";
+    }
+
+
+    @Override
+    protected Object getLower(FLYSArtifact flys) {
+        return 0;
+    }
+
+
+    @Override
+    protected Object getUpper(FLYSArtifact flys) {
+        return 0;
+    }
+
+
+    @Override
+    protected String getType() {
+        return "double";
+    }
+}
+// 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/ReferenceCurveState.java	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java	Fri Feb 03 13:49:16 2012 +0000
@@ -13,10 +13,13 @@
 import de.intevation.flys.artifacts.model.ReportFacet;
 import de.intevation.flys.artifacts.model.WW;
 
+import de.intevation.flys.artifacts.resources.Resources;
+
 import java.util.List;
 
 import org.apache.log4j.Logger;
 
+
 public class ReferenceCurveState
 extends      DefaultState
 implements   FacetTypes
@@ -52,8 +55,9 @@
         WW [] wws = (WW [])res.getData();
 
         for (int i = 0; i < wws.length; ++i) {
-            // TODO: Add data facets.
-             facets.add(new ReferenceCurveFacet(i, REFERENCE_CURVE, REFERENCE_CURVE));
+            facets.add(new ReferenceCurveFacet(i,
+                REFERENCE_CURVE,
+                Resources.getMsg(context.getMeta(), REFERENCE_CURVE, REFERENCE_CURVE)));
         }
 
         if (wws.length > 0) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java	Fri Feb 03 13:49:16 2012 +0000
@@ -178,9 +178,9 @@
         Document theme,
         boolean  visible
     ) {
-        XYSeries series = new StyledXYSeries("TODO-RCG", theme);
+        ApplyFunctionIterator iter = (ApplyFunctionIterator) data;
 
-        ApplyFunctionIterator iter = (ApplyFunctionIterator)data;
+        XYSeries series = new StyledXYSeries(iter.getWW().getName(), theme);
 
         double [] values = new double[2];
 
--- a/flys-artifacts/src/main/resources/messages.properties	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Fri Feb 03 13:49:16 2012 +0000
@@ -42,6 +42,8 @@
 
 cross_section = Cross Section
 
+reference_curve = Reference Curve
+
 scenario.current = Current
 scenario.potentiel = Potentiel
 scenario.scenario = Scenario
--- a/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 03 13:49:16 2012 +0000
@@ -42,6 +42,8 @@
 
 cross_section = Querprofil
 
+reference_curve = Bezugslinie
+
 scenario.current = Aktuell
 scenario.potentiel = Potentiell
 scenario.scenario = Szenario
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 03 13:49:16 2012 +0000
@@ -42,6 +42,8 @@
 
 cross_section = Querprofil
 
+reference_curve = Bezugslinie
+
 scenario.current = Aktuell
 scenario.potentiel = Potentiell
 scenario.scenario = Szenario
--- a/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 03 13:46:03 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 03 13:49:16 2012 +0000
@@ -40,6 +40,8 @@
 
 cross_section = Cross Section
 
+reference_curve = Reference Curve
+
 scenario.current = Current
 scenario.potentiel = Potentiel
 scenario.scenario = Scenario

http://dive4elements.wald.intevation.org