changeset 7124:49ceab5f2263

Configure Longitudinal section diagram to use the new way.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 24 Sep 2013 18:37:41 +0200
parents 1a20738e9a21
children 2237bb25a8f2
files artifacts/doc/conf/generators.xml artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionInfoGenerator.java
diffstat 4 files changed, 31 insertions(+), 309 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/generators.xml	Tue Sep 24 18:36:43 2013 +0200
+++ b/artifacts/doc/conf/generators.xml	Tue Sep 24 18:37:41 2013 +0200
@@ -6,7 +6,8 @@
     <output-generator names="cross_section_chartinfo" class="org.dive4elements.river.exports.CrossSectionInfoGenerator"/>
     <output-generator names="computed_discharge_curve" class="org.dive4elements.river.exports.ComputedDischargeCurveGenerator"/>
     <output-generator names="computed_discharge_curve_chartinfo" class="org.dive4elements.river.exports.ComputedDischargeCurveInfoGenerator"/>
-    <output-generator names="longitudinal_section,longitudinal_section_chartinfo,discharge_longitudinal_section,discharge_longitudinal_section_chartinfo"
+    <output-generator
+        names="longitudinal_section,longitudinal_section_chartinfo,discharge_longitudinal_section,discharge_longitudinal_section_chartinfo"
         class="org.dive4elements.river.exports.LongitudinalSectionGenerator2"
         converter="org.dive4elements.river.exports.DiagramAttributes">
         <axis name="W"/>
@@ -34,7 +35,8 @@
              You have to ensure that there is a W and Q axis accordingly -->
         <processor class="org.dive4elements.river.exports.process.AreaProcessor" axis="none"/>
     </output-generator>
-    <output-generator names="w_differences,w_differences_chartinfo"
+    <output-generator
+        names="w_differences,w_differences_chartinfo"
         class="org.dive4elements.river.exports.DiagramGenerator"
         converter="org.dive4elements.river.exports.DiagramAttributes">
         <axis name="W"/>
@@ -58,6 +60,30 @@
         <processor class="org.dive4elements.river.exports.process.ManualPointsProcessor" axis="W"/>
         <processor class="org.dive4elements.river.exports.process.AreaProcessor" axis="none"/>
     </output-generator>
+    <output-generator
+        names="fix_longitudinal_section_curve,fix_longitudinal_section_curve_chartinfo"
+        class="org.dive4elements.river.exports.DiagramGenerator"
+        converter="org.dive4elements.river.exports.DiagramAttributes">
+        <axis name="dW"/>
+        <axis name="W"/>
+        <axis name="D"/>
+        <axis name="Q" include-zero="true"/>
+        <axis name="" type="X"/>
+        <title key="chart.fixings.longitudinalsection.title" default="Fixierungsanalyse"/>
+        <domain-axis key="chart.fixings.longitudinalsection.xaxis.label" default="[km]">
+            <arg expr="artifact.river"/>
+        </domain-axis>
+        <processor class="org.dive4elements.river.exports.process.DeltaWProcessor" axis="dW"/>
+        <processor class="org.dive4elements.river.exports.process.AnnotationProcessor" axis="none"/>
+        <processor class="org.dive4elements.river.exports.process.ManualPointsProcessor" axis="W"/>
+        <processor class="org.dive4elements.river.exports.process.AreaProcessor" axis="none"/>
+        <processor class="org.dive4elements.river.exports.process.WDiffProcessor" axis="D"/>
+        <processor class="org.dive4elements.river.exports.process.WOutProcessor" axis="W"/>
+        <processor class="org.dive4elements.river.exports.process.QOutProcessor" axis="Q"/>
+        <processor class="org.dive4elements.river.exports.process.BedheightProcessor" axis="W"/>
+        <processor class="org.dive4elements.river.exports.process.BedDiffYearProcessor" axis="W"/>
+        <processor class="org.dive4elements.river.exports.process.BedDiffHeightYearProcessor" axis="W"/>
+    </output-generator>
     <output-generator names="duration_curve" class="org.dive4elements.river.exports.DurationCurveGenerator"/>
     <output-generator names="duration_curve_chartinfo" class="org.dive4elements.river.exports.DurationCurveInfoGenerator"/>
     <output-generator names="waterlevel_export" class="org.dive4elements.river.exports.WaterlevelExporter"/>
@@ -116,8 +142,6 @@
     <output-generator names="fix_deltawt_export" class="org.dive4elements.river.exports.fixings.DeltaWtExporter"/>
     <output-generator names="fix_deltawt_curve" class="org.dive4elements.river.exports.fixings.FixDeltaWtGenerator"/>
     <output-generator names="fix_deltawt_curve_chartinfo" class="org.dive4elements.river.exports.fixings.FixDeltaWtInfoGenerator"/>
-    <output-generator names="fix_longitudinal_section_curve" class="org.dive4elements.river.exports.fixings.FixLongitudinalSectionGenerator"/>
-    <output-generator names="fix_longitudinal_section_curve_chartinfo" class="org.dive4elements.river.exports.fixings.FixLongitudinalSectionInfoGenerator"/>
     <output-generator names="fix_derivate_curve" class="org.dive4elements.river.exports.fixings.FixDerivedCurveGenerator"/>
     <output-generator names="fix_derivate_curve_chartinfo" class="org.dive4elements.river.exports.fixings.FixDerivedCurveInfoGenerator"/>
     <output-generator names="fix_waterlevel_export" class="org.dive4elements.river.exports.WaterlevelExporter"/>
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Tue Sep 24 18:36:43 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Tue Sep 24 18:37:41 2013 +0200
@@ -465,6 +465,9 @@
         addAxisSeries(series, diagramAttributes.getAxisIndex(axisName), visible);
     }
 
+    public void addAxisDataset(XYDataset dataset, String axisName, boolean visible) {
+        addAxisDataset(dataset, diagramAttributes.getAxisIndex(axisName), visible);
+    }
 
     /**
      * Add the given vertical marker to the chart.
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java	Tue Sep 24 18:36:43 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.exports.fixings;
-
-import java.awt.BasicStroke;
-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.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.themes.ThemeDocument;
-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;
-
-public class FixLongitudinalSectionGenerator
-extends FixChartGenerator
-implements FacetTypes
-{
-    private static Logger logger =
-            Logger.getLogger(FixLongitudinalSectionGenerator.class);
-
-    public static final String I18N_CHART_TITLE =
-            "chart.fixings.longitudinalsection.title";
-
-    public static final String I18N_CHART_SUBTITLE =
-            "chart.fixings.longitudinalsection.subtitle";
-
-    public static final String I18N_XAXIS_LABEL =
-            "chart.fixings.longitudinalsection.xaxis.label";
-
-    public static final String I18N_CHART_TITLE_DEFAULT  =
-            "Fixierungsanalyse";
-
-    public static final String I18N_XAXIS_LABEL_DEFAULT  =
-            "[km]";
-
-    public static final String I18N_DW_YAXIS_LABEL_DEFAULT  =
-            "delta W [cm]";
-
-    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), W(1), Q(2);
-        public int idx;
-        private YAXIS(int c) {
-            idx = c;
-        }
-    }
-
-    @Override
-    public void doOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) {
-        String name = aaf.getFacetName();
-        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);
-        }
-        else if (name.equals(LONGITUDINAL_ANNOTATION)) {
-            doAnnotations(
-                    (RiverAnnotation) aaf.getData(context),
-                    aaf,
-                    doc,
-                    visible);
-        }
-        else if (FacetTypes.IS.MANUALPOINTS(name)) {
-            doPoints (aaf.getData(context),
-                    aaf,
-                    doc, visible, YAXIS.dW.idx);
-        }
-        else {
-            logger.warn("Unknown facet name " + name);
-        }
-    }
-
-    /**
-     * 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,
-        ThemeDocument theme,
-        boolean  visible
-    ) {
-        logger.debug("LongitudinalSectionGenerator.doQOut");
-
-        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
-
-        StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);
-
-        addAxisSeries(series, YAXIS.Q.idx, visible);
-
-        setInverted(wqkms.guessRTLData());
-    }
-
-    @SuppressWarnings("unchecked")
-    protected void doSectorAverageDeviationOut(
-            ArtifactAndFacet aaf,
-            ThemeDocument doc,
-            boolean visible)
-    {
-        logger.debug("doSectorAverageOut" + aaf.getFacet().getIndex());
-
-        int index = aaf.getFacet().getIndex();
-        int sectorNdx = index & 3;
-
-        KMIndex<AnalysisPeriod> kms =
-                (KMIndex<AnalysisPeriod>)aaf.getData(context);
-
-        if(kms == null) {
-            return;
-        }
-
-        StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(doc);
-        XYSeries upper =
-                new StyledXYSeries(aaf.getFacetDescription(), false, doc);
-        XYSeries lower =
-                new StyledXYSeries(aaf.getFacetDescription() + " ", false, doc);
-
-        for (KMIndex.Entry<AnalysisPeriod> entry: kms) {
-            double km = entry.getKm();
-            AnalysisPeriod ap = entry.getValue();
-            QWD qwd = ap.getQSectorAverages()[sectorNdx];
-            double dev = ap.getQSectorStdDev(sectorNdx);
-            logger.debug("std-dev: " + dev);
-            if (qwd == null) {
-                continue;
-            }
-            double deltaW = qwd.getDeltaW();
-            double up = deltaW + dev;
-            double lo = deltaW - dev;
-            upper.add(km, up);
-            lower.add(km, lo);
-        }
-        area.addSeries(upper);
-        area.addSeries(lower);
-
-        addAreaSeries(area, 0, visible);
-    }
-
-
-    @SuppressWarnings("unchecked")
-    protected void doReferenceDeviationOut(
-            ArtifactAndFacet aaf,
-            ThemeDocument doc,
-            boolean visible)
-    {
-        logger.debug("doReferenceOut");
-
-        KMIndex<double[]> kms =
-                (KMIndex<double[]>)aaf.getData(context);
-
-        if(kms == null) {
-            return;
-        }
-
-        StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(doc);
-        XYSeries upper =
-                new StyledXYSeries(aaf.getFacetDescription(), false, doc);
-        XYSeries lower =
-                new StyledXYSeries(aaf.getFacetDescription() + " ", false, doc);
-
-
-        for (KMIndex.Entry<double[]> entry: kms) {
-            double km = entry.getKm();
-            double[] devArray = entry.getValue();
-            if (devArray == null) {
-                continue;
-            }
-            double dev = devArray[0];
-            double up = dev;
-            double lo = -dev;
-            upper.add(km, up, false);
-            lower.add(km, lo, false);
-        }
-        area.addSeries(upper);
-        area.addSeries(lower);
-
-        Marker marker = new ValueMarker(0);
-        marker.setStroke(new BasicStroke(2));
-        marker.setPaint(Color.BLACK);
-        addValueMarker(marker);
-        addAreaSeries(area, 0, visible);
-    }
-
-    @Override
-    protected String getDefaultChartTitle() {
-        return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
-    }
-
-    @Override
-    protected String getDefaultXAxisLabel() {
-        return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
-    }
-
-    @Override
-    protected String getDefaultYAxisLabel(int pos) {
-        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
-    protected ChartGenerator.YAxisWalker getYAxisWalker() {
-        return new YAxisWalker() {
-            @Override
-            public int length() {
-                return YAXIS.values().length;
-            }
-
-            @Override
-            public String getId(int idx) {
-                YAXIS[] yaxes = YAXIS.values();
-                return yaxes[idx].toString();
-            }
-        };
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionInfoGenerator.java	Tue Sep 24 18:36:43 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.exports.fixings;
-
-import org.dive4elements.river.exports.ChartInfoGenerator;
-
-public class FixLongitudinalSectionInfoGenerator extends ChartInfoGenerator {
-
-    public FixLongitudinalSectionInfoGenerator() {
-        super(new FixLongitudinalSectionGenerator());
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org