changeset 6439:b02f3a948858

Enabled basedata datacage in fix analysis ls.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 26 Jun 2013 15:15:14 +0200
parents b9c5bb510b39
children 004b87755fa4
files artifacts/doc/conf/artifacts/fixanalysis.xml artifacts/doc/conf/meta-data.xml artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java
diffstat 3 files changed, 117 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/fixanalysis.xml	Wed Jun 26 14:54:48 2013 +0200
+++ b/artifacts/doc/conf/artifacts/fixanalysis.xml	Wed Jun 26 15:15:14 2013 +0200
@@ -204,6 +204,8 @@
                         <facet name="fix_analysis_events_ls" description="Average values for Ws in Q sectors."/>
                         <facet name="fix_reference_events_ls" description="Average values for Ws in Q sectors."/>
                         <facet name="fix_longitudinal_section_curve.manualpoints" description="Manual points"/>
+                        <facet name="other.wqkms.q"          description="W-Type of data" />
+                        <facet name="other.wqkms.w"          description="W-Type of data" />
                     </facets>
                 </outputmode>
                 <outputmode name="fix_derivate_curve" description="output.fix_derivate_curve" mine-type="image/png" type="chart">
@@ -268,6 +270,8 @@
                         <facet name="w_differences" description="facet.w_differences"/>
                         <facet name="other.wkms" description="facet.other.wkms"/>
                         <facet name="other.wqkms" description="facet.other.wqkms"/>
+                        <facet name="other.wqkms.q"          description="W-Type of data" />
+                        <facet name="other.wqkms.w"          description="W-Type of data" />
                         <facet name="heightmarks_points" description="facet.other.wkms.heightmarks_points"/>
                         <facet name="w_differences.manualpoints" description="Manuelle Punkte"/>
                         <facet name="longitudinal_section.manualpoints" description="Manuelle Punkte"/>
--- a/artifacts/doc/conf/meta-data.xml	Wed Jun 26 14:54:48 2013 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Wed Jun 26 15:15:14 2013 +0200
@@ -164,7 +164,7 @@
                     <dc:call-macro name="discharge_fix_wq"/>
                   </dc:when>
                   <dc:when test="$out = 'fix_longitudinal_section_curve'">
-                    <dc:call-macro name="annotations"/>
+                    <dc:call-macro name="longitudinal-section-prototype"/>
                   </dc:when>
                   <dc:when test="$out = 'map'">
                     <dc:call-macro name="flood-map-complete"/>
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java	Wed Jun 26 14:54:48 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java	Wed Jun 26 15:15:14 2013 +0200
@@ -12,23 +12,29 @@
 import java.awt.Color;
 
 import org.apache.log4j.Logger;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.WKms;
+import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.artifacts.model.fixings.AnalysisPeriod;
+import org.dive4elements.river.artifacts.model.fixings.QWD;
+import org.dive4elements.river.exports.ChartGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.exports.process.KMIndexProcessor;
+import org.dive4elements.river.exports.process.Processor;
+import org.dive4elements.river.exports.process.WOutProcessor;
+import org.dive4elements.river.jfree.RiverAnnotation;
+import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.utils.DataUtil;
+import org.dive4elements.river.utils.KMIndex;
+import org.dive4elements.river.utils.RiverUtils;
 import org.jfree.chart.plot.Marker;
 import org.jfree.chart.plot.ValueMarker;
 import org.jfree.data.xy.XYSeries;
 import org.w3c.dom.Document;
 
-import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
-import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.artifacts.model.fixings.AnalysisPeriod;
-import org.dive4elements.river.artifacts.model.fixings.QWD;
-import org.dive4elements.river.exports.ChartGenerator;
-import org.dive4elements.river.exports.process.KMIndexProcessor;
-import org.dive4elements.river.exports.process.Processor;
-import org.dive4elements.river.jfree.RiverAnnotation;
-import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
-import org.dive4elements.river.jfree.StyledXYSeries;
-import org.dive4elements.river.utils.KMIndex;
-
 public class FixLongitudinalSectionGenerator
 extends FixChartGenerator
 implements FacetTypes
@@ -57,8 +63,17 @@
     public static final String I18N_DW_YAXIS_LABEL =
             "chart.fixings.longitudinalsection.yaxis.label";
 
+    public static final String I18N_W_YAXIS_LABEL =
+        "chart.longitudinal.section.yaxis.label";
+
+    public static final String I18N_Q_YAXIS_LABEL =
+        "chart.longitudinal.section.yaxis.second.label";
+
+    public static final String I18N_W_YAXIS_LABEL_DEFAULT  = "W [NN + m]";
+    public static final String I18N_Q_YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]";
+
     public static enum YAXIS {
-        dW(0);
+        dW(0), W(1), Q(2);
         public int idx;
         private YAXIS(int c) {
             idx = c;
@@ -71,12 +86,23 @@
         logger.debug("FixLongitudinalSectionGenerator: doOut: " + name);
 
         Processor processor = new KMIndexProcessor();
+        Processor wProcessor = new WOutProcessor();
         if (name.contains(FIX_SECTOR_AVERAGE_LS_DEVIATION)) {
             doSectorAverageDeviationOut(aaf, doc, visible);
         }
         else if (processor.canHandle(name)) {
             processor.doOut(this, aaf, doc, visible, YAXIS.dW.idx);
         }
+        else if (wProcessor.canHandle(name)) {
+            wProcessor.doOut(this, aaf, doc, visible, YAXIS.W.idx);
+        }
+        else if (name.equals(STATIC_WQKMS_Q)) {
+            doQOut(
+                (WQKms) aaf.getData(context),
+                aaf,
+                doc,
+                visible);
+        }
         else if (name.equals(FIX_DEVIATION_LS)) {
             doReferenceDeviationOut(aaf, doc, visible);
         }
@@ -97,6 +123,64 @@
         }
     }
 
+    /**
+     * Process the output for Q facets in a longitudinal section curve.
+     *
+     * @param wqkms An array of WQKms values.
+     * @param aandf The facet and artifact. This facet does NOT support any data objects. Use
+     * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports
+     * data.
+     * @param theme The theme that contains styling information.
+     * @param visible The visibility of the curve.
+     */
+    protected void doQOut(
+        WQKms    wqkms,
+        ArtifactAndFacet aandf,
+        Document theme,
+        boolean  visible
+    ) {
+        logger.debug("LongitudinalSectionGenerator.doQOut");
+
+        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
+
+        StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);
+
+        addAxisSeries(series, YAXIS.Q.idx, visible);
+
+        if (needInvertAxis(wqkms)) {
+            setInverted(true);
+        }
+    }
+
+    /**
+     * This method determines - taking JFreeCharts auto x value ordering into
+     * account - if the x axis need to be inverted. Waterlines in these charts
+     * should decrease.
+     *
+     * @param wkms The data object that stores the x and y values used for this
+     * chart.
+     */
+    public boolean needInvertAxis(WKms wkms) {
+        boolean wsUp = wkms.guessWaterIncreasing();
+        boolean kmUp = DataUtil.guessWaterIncreasing(wkms.allKms());
+        boolean inv = (wsUp && kmUp) || (!wsUp && !kmUp);
+
+        int size = wkms.size();
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("(Wkms)Values  : " + size);
+            if (size > 0) {
+                logger.debug("Start km: " + wkms.getKm(0));
+                logger.debug("End   km: " + wkms.getKm(size-1));
+            }
+            logger.debug("wsUp: " + wsUp);
+            logger.debug("kmUp: " + kmUp);
+            logger.debug("inv:  " + inv);
+        }
+
+        return inv;
+    }
+
     @SuppressWarnings("unchecked")
     protected void doSectorAverageDeviationOut(
             ArtifactAndFacet aaf,
@@ -199,7 +283,21 @@
 
     @Override
     protected String getDefaultYAxisLabel(int pos) {
-        return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT);
+        if (pos == YAXIS.dW.idx) {
+            return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT);
+        }
+        else if (pos == YAXIS.W.idx) {
+            D4EArtifact flys = (D4EArtifact) master;
+            String unit = RiverUtils.getRiver(flys).getWstUnit().getName();
+            return msg(
+                I18N_W_YAXIS_LABEL,
+                I18N_W_YAXIS_LABEL_DEFAULT,
+                new Object[] { unit });
+        }
+        else if (pos == YAXIS.Q.idx) {
+            return msg(I18N_Q_YAXIS_LABEL, I18N_Q_YAXIS_LABEL_DEFAULT);
+        }
+        return "";
     }
 
     @Override

http://dive4elements.wald.intevation.org