changeset 3039:7db919b1bc1e

Added new facet for analysis periods and updated facet names in fix analysis. flys-artifacts/trunk@4608 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 06 Jun 2012 12:06:59 +0000 (2012-06-06)
parents 6a37a0134409
children 79d1db7797e6
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/fixanalysis.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java
diffstat 6 files changed, 139 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 06 11:53:55 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jun 06 12:06:59 2012 +0000
@@ -1,3 +1,19 @@
+2012-06-06  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Added new facet for analysis periods and updated facet names.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java:
+	  New. Facet for analysis periods. Returns the date ranges for the analysis
+	  periods.
+
+	* doc/conf/artifacts/fixanalysis.xml,
+	  src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java:
+	  Added new facet and updated facet names.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java:
+	  Updated facet names.
+
 2012-06-06	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java:
--- a/flys-artifacts/doc/conf/artifacts/fixanalysis.xml	Wed Jun 06 11:53:55 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/fixanalysis.xml	Wed Jun 06 12:06:59 2012 +0000
@@ -132,7 +132,9 @@
                 <outputmode name="fix_wq_curve" description="output.fix_wq_curve" mine-type="image/png" type="chart">
                     <facets>
                         <facet name="fix_sector_average" description="Average values for Ws in Q sectors."/>
-                        <facet name="fix_events" description="Raw event values used in the calculation"/>
+                        <facet name="fix_analysis_events" description="Raw event values used in the calculation"/>
+                        <facet name="fix_reference_events" description="Raw event values used in the calculation"/>
+                        <facet name="fix_analysis_periods" description="Dateranges of analysis periods."/>
                         <facet name="fix_wq_curve" description="WQ curve"/>
                         <facet name="fix_outlier" description="The outliers"/>
                     </facets>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Jun 06 11:53:55 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Jun 06 12:06:59 2012 +0000
@@ -158,9 +158,11 @@
 
     String RELATIVE_POINT = "relativepoint";
 
-    String FIX_EVENTS = "fix_events";
+    String FIX_ANALYSIS_EVENTS = "fix_analysis_events";
+    String FIX_REFERENCE_EVENTS = "fix_reference_events";
     String FIX_SECTOR_AVERAGE = "fix_sector_average";
     String FIX_WQ_CURVE = "fix_wq_curve";
     String FIX_OUTLIER = "fix_outlier";
+    String FIX_ANALYSIS_PERIODS = "fix_analysis_periods";
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java	Wed Jun 06 11:53:55 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java	Wed Jun 06 12:06:59 2012 +0000
@@ -38,7 +38,12 @@
      * @param name
      */
     public FixAnalysisEventsFacet(int index, String description) {
-        super(index, FIX_EVENTS, description, ComputeType.ADVANCE, null, null);
+        super(index,
+             FIX_ANALYSIS_EVENTS,
+             description,
+             ComputeType.ADVANCE,
+             null,
+             null);
     }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java	Wed Jun 06 12:06:59 2012 +0000
@@ -0,0 +1,105 @@
+package de.intevation.flys.artifacts.model.fixings;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.flys.utils.KMIndex;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.FixationArtifactAccess;
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.DataFacet;
+import de.intevation.flys.artifacts.model.CalculationResult;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+
+/**
+ * Facet to show W values for Q values at km for a date.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class FixAnalysisPeriodsFacet
+extends      DataFacet
+implements   FacetTypes {
+
+    /** House logger. */
+    private static Logger logger = Logger.getLogger(FixAnalysisPeriodsFacet.class);
+
+    /** Trivial Constructor. */
+    public FixAnalysisPeriodsFacet() {
+    }
+
+
+    /**
+     * @param name
+     */
+    public FixAnalysisPeriodsFacet(int index, String description) {
+        super(index,
+            FIX_ANALYSIS_PERIODS,
+            description,
+            ComputeType.ADVANCE,
+            null,
+            null);
+    }
+
+
+    /**
+     * Returns the data this facet requires.
+     *
+     * @param artifact the owner artifact.
+     * @param context  the CallContext (ignored).
+     *
+     * @return the data.
+     */
+    @Override
+    public Object getData(Artifact artifact, CallContext context) {
+        logger.debug("FixAnalysisPeriodsFacet.getData");
+
+        if (artifact instanceof FLYSArtifact) {
+            FLYSArtifact flys = (FLYSArtifact)artifact;
+            FixationArtifactAccess access = new FixationArtifactAccess(flys);
+
+            CalculationResult res =
+                (CalculationResult) flys.compute(context,
+                                                 ComputeType.ADVANCE,
+                                                 false);
+
+            FixResult result = (FixResult) res.getData();
+
+            double km = access.getCurrentKm();
+
+            KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods();
+            AnalysisPeriod[] periods = kmPeriods.binarySearch(km).getValue();
+
+            if (periods == null) {
+                return null;
+            }
+            DateRange[] dates = new DateRange[periods.length];
+            for (int i = 0; i < periods.length; i++) {
+                dates[i] = periods[i].getDateRange();
+            }
+            return dates;
+        }
+        else {
+            logger.debug("Not an instance of FixationArtifact.");
+            return null;
+        }
+    }
+
+
+    /**
+     * Create a deep copy of this Facet.
+     * @return a deep copy.
+     */
+    @Override
+    public FixAnalysisPeriodsFacet deepCopy() {
+        FixAnalysisPeriodsFacet copy = new FixAnalysisPeriodsFacet();
+        copy.set(this);
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java	Wed Jun 06 11:53:55 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java	Wed Jun 06 12:06:59 2012 +0000
@@ -38,7 +38,12 @@
      * @param name
      */
     public FixReferenceEventsFacet(int index, String description) {
-        super(index, FIX_EVENTS, description, ComputeType.ADVANCE, null, null);
+        super(index,
+             FIX_REFERENCE_EVENTS,
+             description,
+             ComputeType.ADVANCE,
+             null,
+             null);
     }
 
 

http://dive4elements.wald.intevation.org