changeset 2134:024d986b4f5b

'New Chart' for duration curve. flys-artifacts/trunk@3710 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 18 Jan 2012 15:50:34 +0000
parents 767ce9d1991f
children 77cdc344ef77
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/chart.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java
diffstat 4 files changed, 84 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jan 18 14:45:24 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jan 18 15:50:34 2012 +0000
@@ -1,3 +1,15 @@
+2012-01-18  Raimund Renkert <raimund.renkert@intevation.de>
+
+	'New Chart' for duration curve.
+
+	* doc/conf/artifacts/chart.xml: Added state and transition for location input.
+
+	* src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java:
+	  Changed cast from WINFOArtifact to FLYSArtifact.
+
+	* src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java:
+	  Add an empty facet if the artifact is a ChartArtifact.
+
 2012-01-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Added accidentally ommitted HYKFacet, fixing build.
--- a/flys-artifacts/doc/conf/artifacts/chart.xml	Wed Jan 18 14:45:24 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/chart.xml	Wed Jan 18 15:50:34 2012 +0000
@@ -22,7 +22,7 @@
 
          <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
              <from state="state.chart.type"/>
-             <to state="state.chart.durationcurve"/>
+             <to state="state.chart.km"/>
              <condition data="chart_type" value="chart.new.durationcurve" operator="equal"/>
          </transition>
 
@@ -64,20 +64,7 @@
             </outputmodes>
         </state>
 
-        <state id="state.chart.durationcurve" description="state.winfo.durationcurve" state="de.intevation.flys.artifacts.states.DurationCurveState">
-            <outputmodes>
-                <outputmode name="duration_curve" description="output.duration_curve" mime-type="image/png" type="chart">
-                    <facets>
-                        <facet name="duration_curve.w" description="facet.duration_curve.w"/>
-                        <facet name="duration_curve.q" description="facet.duration_curve.q"/>
-                        <facet name="computed_discharge_curve.mainvalues.q" description="Q Main Values"/>
-                        <facet name="computed_discharge_curve.mainvalues.w" description="W Main Values"/>
-                    </facets>
-                </outputmode>
-            </outputmodes>
-        </state>
-
-        <state id="state.chart.waterlevel" description="state.winfo.waterlevel" state="de.intevation.flys.artifacts.states.WaterlevelState">
+       <state id="state.chart.waterlevel" description="state.winfo.waterlevel" state="de.intevation.flys.artifacts.states.WaterlevelState">
             <outputmodes>
                 <outputmode name="longitudinal_section" description="output.longitudinal_section" mime-type="image/png" type="chart">
                   <facets>
@@ -117,6 +104,12 @@
             <condition data="chart_type" value="chart.new.computeddischargecurve" operator="equal"/>
         </transition>
 
+        <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
+            <from state="state.chart.km"/>
+            <to state="state.chart.durationcurve"/>
+            <condition data="chart_type" value="chart.new.durationcurve" operator="equal"/>
+        </transition>
+
         <state id="state.chart.computeddischargecurve" description="state.chart.computeddischargecurve" state="de.intevation.flys.artifacts.states.ComputedDischargeCurveState">
             <outputmodes>
                 <outputmode name="computed_discharge_curve" description="output.computed_discharge_curve" mime-type="image/png" type="chart">
@@ -134,5 +127,20 @@
             </outputmodes>
         </state>
 
+        <state id="state.chart.durationcurve" description="state.winfo.durationcurve" state="de.intevation.flys.artifacts.states.DurationCurveState">
+            <outputmodes>
+                <outputmode name="duration_curve" description="output.duration_curve" mime-type="image/png" type="chart">
+                    <facets>
+                        <facet name="empty.facet" description="Empty"/>
+                        <facet name="duration_curve.w" description="facet.duration_curve.w"/>
+                        <facet name="duration_curve.q" description="facet.duration_curve.q"/>
+                        <facet name="computed_discharge_curve.mainvalues.q" description="Q Main Values"/>
+                        <facet name="computed_discharge_curve.mainvalues.w" description="W Main Values"/>
+                    </facets>
+                </outputmode>
+            </outputmodes>
+        </state>
+
+ 
     </states>
 </artifact>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Wed Jan 18 14:45:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Wed Jan 18 15:50:34 2012 +0000
@@ -140,7 +140,7 @@
     @Override
     protected void initialize(Artifact artifact, Object context, CallMeta meta) {
         logger.debug("MainValuesArtifact.initialize");
-        WINFOArtifact winfo = (WINFOArtifact) artifact;
+        FLYSArtifact winfo = (FLYSArtifact) artifact;
         double [] locations = FLYSUtils.getLocations(winfo);
         if (locations != null) {
             double location = locations[0];
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java	Wed Jan 18 14:45:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java	Wed Jan 18 15:50:34 2012 +0000
@@ -10,6 +10,7 @@
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.ChartArtifact;
 
 import de.intevation.flys.artifacts.model.DurationCurveFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
@@ -17,6 +18,7 @@
 
 import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.ReportFacet;
+import de.intevation.flys.artifacts.model.EmptyFacet;
 import de.intevation.flys.artifacts.model.CalculationResult;
 
 import de.intevation.flys.artifacts.resources.Resources;
@@ -49,50 +51,58 @@
         List<Facet>  facets,
         Object       old
     ) {
-        WINFOArtifact winfo = (WINFOArtifact)artifact;
-
-        CalculationResult res;
-
-        if (old instanceof CalculationResult) {
-            res = (CalculationResult)old;
-        }
-        else {
-            res = winfo.getDurationCurveData();
-        }
-
-        WQDay wqday = (WQDay)res.getData();
-
-        if (wqday != null && facets != null) {
-            Object[] args = new Object[] {
-                FLYSUtils.getRiver(winfo).getName()
-            };
+        if (artifact instanceof WINFOArtifact) {
+            WINFOArtifact winfo = (WINFOArtifact)artifact;
 
-            String nameW = Resources.getMsg(
-                context.getMeta(),
-                "chart.duration.curve.curve.w",
-                "",
-                args);
-
-            String nameQ = Resources.getMsg(
-                context.getMeta(),
-                "chart.duration.curve.curve.q",
-                "",
-                args);
+            CalculationResult res;
 
-            Facet w = new DurationCurveFacet(DURATION_W, nameW);
-            Facet q = new DurationCurveFacet(DURATION_Q, nameQ);
-
-            facets.add(w);
-            facets.add(q);
+            if (old instanceof CalculationResult) {
+                res = (CalculationResult)old;
+            }
+            else {
+                res = winfo.getDurationCurveData();
+            }
 
-            facets.add(new DataFacet(CSV, "CSV data"));
+            WQDay wqday = (WQDay)res.getData();
 
-            if (res.getReport().hasProblems()) {
-                facets.add(new ReportFacet());
+            if (wqday != null && facets != null) {
+                Object[] args = new Object[] {
+                    FLYSUtils.getRiver(winfo).getName()
+                };
+
+                String nameW = Resources.getMsg(
+                    context.getMeta(),
+                    "chart.duration.curve.curve.w",
+                    "",
+                    args);
+
+                String nameQ = Resources.getMsg(
+                    context.getMeta(),
+                    "chart.duration.curve.curve.q",
+                    "",
+                    args);
+
+                Facet w = new DurationCurveFacet(DURATION_W, nameW);
+                Facet q = new DurationCurveFacet(DURATION_Q, nameQ);
+
+                facets.add(w);
+                facets.add(q);
+
+                facets.add(new DataFacet(CSV, "CSV data"));
+
+                if (res.getReport().hasProblems()) {
+                    facets.add(new ReportFacet());
+                }
             }
+
+            return res;
         }
-
-        return res;
+        else if (artifact instanceof ChartArtifact) {
+            ChartArtifact chart = (ChartArtifact)artifact;
+            facets.add(new EmptyFacet());
+            return null;
+        }
+        return null;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org