changeset 8183:baa7df019df3

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 04 Sep 2014 11:15:34 +0200
parents 0b4cd7a5f079 (diff) 00066d3add94 (current diff)
children 143b24546b26 407c9598352f
files
diffstat 7 files changed, 447 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/conf.xml	Wed Sep 03 18:21:35 2014 +0200
+++ b/artifacts/doc/conf/conf.xml	Thu Sep 04 11:15:34 2014 +0200
@@ -18,6 +18,7 @@
     <!ENTITY longitudinal-diagrams SYSTEM "generators/longitudinal-diagrams.xml">
     <!ENTITY sqrelation-defaults SYSTEM "generators/sqrelation-diagram-defaults.xml">
     <!ENTITY longitudinal-defaults SYSTEM "generators/longitudinal-diagram-defaults.xml">
+    <!ENTITY discharge-defaults SYSTEM "generators/discharge-diagram-defaults.xml">
 ]>
 <artifact-database>
     <export-secret>YOUR_SECRET</export-secret>
--- a/artifacts/doc/conf/generators/discharge-diagram-defaults.xml	Wed Sep 03 18:21:35 2014 +0200
+++ b/artifacts/doc/conf/generators/discharge-diagram-defaults.xml	Thu Sep 04 11:15:34 2014 +0200
@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <discharge-defaults>
-   <axis name="W"/>
-   <domain-axis key="chart.wq.xaxis.label" default="KEY NOT FOUND"/>
-   <subtitle key="chart.computed.discharge.curve.subtitle" default="-">
-     <arg expr="artifact.river"/>
-     <arg expr="artifact.ld_locations" type="double"/>
-   </subtitle>
+    <axis name="W"/>
+    <domain-axis key="chart.discharge.xaxis.label" default="Q [m\u00b3/s]"/>
+    <subtitle key="chart.computed.discharge.curve.subtitle" default="-">
+        <arg expr="artifact.river"/>
+        <arg expr="artifact.ld_locations" type="double"/>
+    </subtitle>
+    <processor class="org.dive4elements.river.exports.process.DischargeProcessor" axis="W"/>
+    <processor class="org.dive4elements.river.exports.process.MiscDischargeProcessor" axis="W"/>
+    <processor class="org.dive4elements.river.exports.process.ComputedDischargeProcessor" axis="W"/>
 </discharge-defaults>
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java	Wed Sep 03 18:21:35 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java	Thu Sep 04 11:15:34 2014 +0200
@@ -17,6 +17,7 @@
 import org.dive4elements.river.artifacts.model.WKms;
 import org.dive4elements.river.artifacts.model.WQKms;
 import org.dive4elements.river.exports.process.DischargeProcessor;
+import org.dive4elements.river.exports.process.MiscDischargeProcessor;
 import org.dive4elements.river.jfree.RiverAnnotation;
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
 import org.dive4elements.river.jfree.StyledXYSeries;
@@ -113,7 +114,7 @@
             return;
         }
 
-        DischargeProcessor dProcessor = new DischargeProcessor(getRange()[0]);
+        MiscDischargeProcessor dProcessor = new MiscDischargeProcessor(getRange()[0]);
         if (dProcessor.canHandle(name)) {
             dProcessor.doOut(this, artifactFacet, attr, visible, YAXIS.W.idx);
         }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Wed Sep 03 18:21:35 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Thu Sep 04 11:15:34 2014 +0200
@@ -16,6 +16,7 @@
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WQKms;
 import org.dive4elements.river.exports.process.DischargeProcessor;
+import org.dive4elements.river.exports.process.MiscDischargeProcessor;
 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
 import org.dive4elements.river.jfree.Bounds;
 import org.dive4elements.river.jfree.DoubleBounds;
@@ -260,7 +261,7 @@
         String name = artifactFacet.getFacetName();
         logger.debug("DischargeCurveGenerator.doOut: " + name);
 
-        DischargeProcessor dProcessor = new DischargeProcessor(getRange()[0]);
+        MiscDischargeProcessor dProcessor = new MiscDischargeProcessor(getRange()[0]);
         if (dProcessor.canHandle(name)) {
             // In Base DischargeCurveGenerator, always at gauge, use WCm axis.
             dProcessor.doOut(this, artifactFacet, theme, visible, YAXIS.WCm.idx);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java	Thu Sep 04 11:15:34 2014 +0200
@@ -0,0 +1,72 @@
+package org.dive4elements.river.exports.process;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.themes.ThemeDocument;
+import org.jfree.data.xy.XYSeries;
+
+
+public class ComputedDischargeProcessor
+extends DefaultProcessor
+implements FacetTypes
+{
+    private static Logger logger =
+        Logger.getLogger(ComputedDischargeProcessor.class);
+
+
+    @Override
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible
+    ) {
+        CallContext context = generator.getCallContext();
+        Object data = bundle.getData(context);
+        if (data instanceof WQKms) {
+            doDischargeOut(generator, bundle, theme, visible);
+        }
+    }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        return null;
+    }
+
+    /**
+     * Returns true if the Processor class is able to generate output for a facet type
+     *
+     * @param facettype Name of the facet type
+     * @return true if the facettype can be processed
+     */
+    @Override
+    public boolean canHandle(String facettype) {
+        return COMPUTED_DISCHARGE_Q.equals(facettype);
+    }
+
+    private void doDischargeOut(
+        DiagramGenerator generator,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible
+    ) {
+        CallContext context = generator.getCallContext();
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        Object data = bundle.getData(context);
+        WQKms wqkms = (WQKms) data;
+        double[][] wqData = new double[2][wqkms.size()];
+        for (int i = 0; i < wqkms.size(); i++) {
+            wqData[0][i] = wqkms.getQ(i);
+            wqData[1][i] = wqkms.getW(i);
+        }
+        StyledSeriesBuilder.addPoints(series, wqData, false);
+        generator.addAxisSeries(series, axisName, visible);
+        
+    }
+}
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java	Wed Sep 03 18:21:35 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java	Thu Sep 04 11:15:34 2014 +0200
@@ -12,22 +12,27 @@
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.jfree.chart.annotations.XYTextAnnotation;
 import org.jfree.data.xy.XYSeries;
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.DischargeCurveGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.exports.XYChartGenerator;
 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
 import org.dive4elements.river.jfree.RiverAnnotation;
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
 import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.model.Gauge;
+import org.dive4elements.river.model.River;
 import org.dive4elements.river.themes.ThemeDocument;
 
-import org.jfree.chart.annotations.XYTextAnnotation;
-
 
 /** Helper for data handling in discharge diagrams. */
 public class DischargeProcessor
@@ -44,7 +49,7 @@
 
 
     /** This processor needs to be constructed with a given km. */
-    private DischargeProcessor() {
+    public DischargeProcessor() {
         km = Double.NaN;
     }
 
@@ -57,28 +62,20 @@
     /** Process data, add it to plot. */
     @Override
     public void doOut(
-            XYChartGenerator generator,
+            DiagramGenerator generator,
             ArtifactAndFacet bundle,
             ThemeDocument theme,
-            boolean visible,
-            int axisIndex
+            boolean visible
     ) {
         CallContext context = generator.getCallContext();
         Object data = bundle.getData(context);
         if (data instanceof WQKms) {
-            doWQKmsPointOut(
-                generator, (WQKms) data, bundle, theme, visible, axisIndex);
-            return;
-        }
-        else if (data instanceof RiverAnnotation) {
-            doRiverAnnotationOut(
-                generator, (RiverAnnotation) data, bundle, theme, visible);
-            return;
-        }
-        else if (data instanceof double[][]) {
-            doMarksOut(
-                generator, (double[][]) data, bundle, theme, visible);
-            return;
+            doDischargeOut(
+                generator,
+                bundle,
+                bundle.getFacetName(),
+                theme,
+                visible);
         }
         else {
             logger.error("Can't process "
@@ -87,16 +84,11 @@
         }
     }
 
-
     /** True if this processor knows how to deal with facetType. */
     @Override
     public boolean canHandle(String facetType) {
-        return STATIC_WQKMS_W.equals(facetType)
-            || COMPUTED_DISCHARGE_MAINVALUES_Q.equals(facetType)
-            || MAINVALUES_Q.equals(facetType)
-            || COMPUTED_DISCHARGE_MAINVALUES_W.equals(facetType)
-            || MAINVALUES_W.equals(facetType)
-            || STATIC_W_INTERPOL.equals(facetType);
+        return DISCHARGE_CURVE.equals(facetType)
+            || GAUGE_DISCHARGE_CURVE.equals(facetType);
     }
 
 
@@ -105,97 +97,44 @@
         return km;
     }
 
-
-    /** Handle WQKms data by finding w/q values at given km. */
-    protected void doWQKmsPointOut(XYChartGenerator generator,
-        WQKms wqkms,
+    /**
+     * Add series with discharge curve to diagram.
+     */
+    protected void doDischargeOut(
+        DiagramGenerator generator,
         ArtifactAndFacet bundle,
+        String        name,
         ThemeDocument theme,
-        boolean visible,
-        int axidx
-    ) {
-        logger.debug("doWQKmsPointOut");
-        String title = bundle.getFacetDescription();
-        XYSeries series = new StyledXYSeries(
-            title,
-            theme);
-
-        double[] kms = wqkms.getKms();
-
-        for (int i = 0 ; i< kms.length; i++) {
-            if (Math.abs(kms[i] - getKm()) <= KM_EPSILON) {
-                series.add(wqkms.getQ(i), wqkms.getW(i));
-                generator.addAxisSeries(series, axidx, visible);
-                if(visible && theme.parseShowPointLabel()) {
-                    List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
-                    XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
-                            title,
-                            wqkms.getQ(i),
-                            // TODO add a percentage to the extend of W axis
-                            wqkms.getW(i));
-                    textAnnos.add(anno);
-                    RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme);
-                    flysAnno.setTextAnnotations(textAnnos);
-                    generator.addAnnotations(flysAnno);
-                }
-                return;
-            }
+        boolean       visible)
+    {
+        logger.debug("DischargeCurveGenerator.doDischargeOut");
+        CallContext context = generator.getCallContext();
+        WQKms data = (WQKms)bundle.getData(context);
+        XYSeries series = new StyledXYSeries(name, theme);
+        double[][] wqData = new double[2][data.size()];
+        for (int i = 0; i < data.size(); i++) {
+            wqData[0][i] = data.getQ(i);
+            wqData[1][i] = data.getW(i);
         }
+        StyledSeriesBuilder.addPoints(series, wqData, false);
 
-        logger.warn("No WQ found for km " + getKm());
-    }
-
-    protected void doRiverAnnotationOut(XYChartGenerator generator,
-        RiverAnnotation annotations,
-        ArtifactAndFacet bundle,
-        ThemeDocument theme,
-        boolean visible
-    ) {
-        if (!(generator instanceof DischargeCurveGenerator)) {
-            logger.error("DischargeProcessor can only be used in " +
-                " in DischargeCurveGenerator-classes.");
-            return;
-        }
-        logger.debug("doRiverAnnotationOut");
-        DischargeCurveGenerator dGenerator =
-            (DischargeCurveGenerator) generator;
+        String gaugeName = data.getName();
+        RiverAccess access = new RiverAccess((D4EArtifact)bundle.getArtifact());
+        River river = access.getRiver();
 
-        dGenerator.translateRiverAnnotation(annotations);
-        dGenerator.doAnnotations(
-            annotations,
-            bundle, theme, visible);
-    }
-
-
-    /**
-     * Put Sticky Axis Markers to Y-axis for each value.
-     * @param data [[-,y1],[-,y2],...] ('x'-coordinates ignored)
-     */
-    protected void doMarksOut(XYChartGenerator generator,
-        double[][] data,
-        ArtifactAndFacet bundle,
-        ThemeDocument theme,
-        boolean visible
-    ) {
-        logger.debug("doMarksOut");
-
-        if (!visible) {
+        if (river == null) {
+            logger.debug("no river found");
             return;
         }
 
-        // TODO subtract gauge null point if at gauge.
-        String title = bundle.getFacetDescription();
-        List<StickyAxisAnnotation> yMarks = new ArrayList<StickyAxisAnnotation>();
+        Gauge gauge = river.determineGaugeByName(gaugeName);
 
-        for (double yPos: data[1]) {
-            yMarks.add(new StickyAxisAnnotation(
-                title,
-                (float) yPos,
-                StickyAxisAnnotation.SimpleAxis.Y_AXIS));
+        if (gauge == null) {
+            logger.debug("no gauge found");
+            return;
         }
 
-        generator.doAnnotations(new RiverAnnotation(title, yMarks),
-            bundle, theme, visible);
+        generator.addAxisSeries(series, axisName, visible);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java	Thu Sep 04 11:15:34 2014 +0200
@@ -0,0 +1,316 @@
+/* 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.process;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.DischargeCurveGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
+import org.dive4elements.river.jfree.RiverAnnotation;
+import org.dive4elements.river.jfree.StickyAxisAnnotation;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.themes.ThemeDocument;
+
+import org.jfree.chart.annotations.XYTextAnnotation;
+
+
+/** Helper for data handling in discharge diagrams. */
+public class MiscDischargeProcessor
+extends DefaultProcessor implements FacetTypes {
+
+    private final static Logger logger =
+            Logger.getLogger(MiscDischargeProcessor.class);
+
+    /** Station for which the diagram is shown. */
+    private double km;
+
+    /** Tolerance for comparison of kilometers. */
+    public static final double KM_EPSILON = 0.001d;
+
+
+    /** This processor needs to be constructed with a given km. */
+    public MiscDischargeProcessor() {
+        km = Double.NaN;
+    }
+
+
+    public MiscDischargeProcessor(double km) {
+        this.km = km;
+    }
+
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible) {
+        CallContext context = generator.getCallContext();
+        Object data = bundle.getData(context);
+        if (data instanceof WQKms) {
+            doWQKmsPointOut(
+                generator, (WQKms) data, bundle, theme, visible);
+            return;
+        }
+        else if (data instanceof RiverAnnotation) {
+            doRiverAnnotationOut(
+                generator, (RiverAnnotation)data, bundle, theme, visible);
+            return;
+        }
+        else if (data instanceof double[][]) {
+            doPointsOut(generator, (double[][])data, bundle, theme, visible);
+        }
+        else {
+            logger.error("Can't process "
+                + data.getClass().getName() + " objects of facet "
+                + bundle.getFacetName());
+        }
+    }
+
+    /** Process data, add it to plot. */
+    @Override
+    public void doOut(
+            XYChartGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument theme,
+            boolean visible,
+            int axisIndex
+    ) {
+        CallContext context = generator.getCallContext();
+        Object data = bundle.getData(context);
+        /* TODO: Remove the first case.*/
+        if (bundle.getFacetName().equals(STATIC_WQ)) {
+            doPointOut(
+                generator, bundle, theme, visible, axisIndex);
+        }
+        else if (data instanceof WQKms) {
+            doWQKmsPointOut(
+                generator, (WQKms) data, bundle, theme, visible, axisIndex);
+            return;
+        }
+        else if (data instanceof RiverAnnotation) {
+            doRiverAnnotationOut(
+                generator, (RiverAnnotation) data, bundle, theme, visible);
+            return;
+        }
+        else if (data instanceof double[][]) {
+            doMarksOut(
+                generator, (double[][]) data, bundle, theme, visible);
+            return;
+        }
+        else {
+            logger.error("Can't process "
+                + data.getClass().getName() + " objects of facet "
+                + bundle.getFacetName());
+        }
+    }
+
+    private void doPointOut(XYChartGenerator generator,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible,
+        int axisIndex
+    ) {
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        Object wq = bundle.getData(generator.getCallContext());
+        if (wq instanceof double[][]) {
+            double [][] data = (double [][]) wq;
+            StyledSeriesBuilder.addPoints(series, data, true);
+        } else if (wq instanceof WQKms) {
+            WQKms wqkms = (WQKms) wq;
+            StyledSeriesBuilder.addPointsQW(series, (WQKms) wq);
+        }
+
+        generator.addAxisSeries(series, axisIndex, visible);
+    }
+
+    /** Handle WQKms data by finding w/q values at given km. */
+    protected void doWQKmsPointOut(XYChartGenerator generator,
+        WQKms wqkms,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible,
+        int axidx
+    ) {
+        logger.debug("doWQKmsPointOut");
+        String title = bundle.getFacetDescription();
+        XYSeries series = new StyledXYSeries(
+            title,
+            theme);
+
+        double[] kms = wqkms.getKms();
+
+        for (int i = 0 ; i< kms.length; i++) {
+            if (Math.abs(kms[i] - getKm()) <= KM_EPSILON) {
+                series.add(wqkms.getQ(i), wqkms.getW(i));
+                generator.addAxisSeries(series, axidx, visible);
+                if(visible && theme.parseShowPointLabel()) {
+                    List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
+                    XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
+                            title,
+                            wqkms.getQ(i),
+                            // TODO add a percentage to the extend of W axis
+                            wqkms.getW(i));
+                    textAnnos.add(anno);
+                    RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme);
+                    flysAnno.setTextAnnotations(textAnnos);
+                    generator.addAnnotations(flysAnno);
+                }
+                return;
+            }
+        }
+
+        logger.warn("No WQ found for km " + getKm());
+    }
+
+    protected void doRiverAnnotationOut(XYChartGenerator generator,
+        RiverAnnotation annotations,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible
+    ) {
+        if (!(generator instanceof DischargeCurveGenerator)) {
+            logger.error("DischargeProcessor can only be used in " +
+                " in DischargeCurveGenerator-classes.");
+            return;
+        }
+        logger.debug("doRiverAnnotationOut");
+        DischargeCurveGenerator dGenerator =
+            (DischargeCurveGenerator) generator;
+
+        dGenerator.translateRiverAnnotation(annotations);
+        dGenerator.doAnnotations(
+            annotations,
+            bundle, theme, visible);
+    }
+
+
+    /**
+     * Put Sticky Axis Markers to Y-axis for each value.
+     * @param data [[-,y1],[-,y2],...] ('x'-coordinates ignored)
+     */
+    protected void doMarksOut(XYChartGenerator generator,
+        double[][] data,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible
+    ) {
+        logger.debug("doMarksOut");
+
+        if (!visible) {
+            return;
+        }
+
+        // TODO subtract gauge null point if at gauge.
+        String title = bundle.getFacetDescription();
+        List<StickyAxisAnnotation> yMarks = new ArrayList<StickyAxisAnnotation>();
+
+        for (double yPos: data[1]) {
+            yMarks.add(new StickyAxisAnnotation(
+                title,
+                (float) yPos,
+                StickyAxisAnnotation.SimpleAxis.Y_AXIS));
+        }
+
+        generator.doAnnotations(new RiverAnnotation(title, yMarks),
+            bundle, theme, visible);
+    }
+
+    /** True if this processor knows how to deal with facetType. */
+    @Override
+    public boolean canHandle(String facetType) {
+        return STATIC_WQKMS_W.equals(facetType)
+            || COMPUTED_DISCHARGE_MAINVALUES_Q.equals(facetType)
+            || MAINVALUES_Q.equals(facetType)
+            || COMPUTED_DISCHARGE_MAINVALUES_W.equals(facetType)
+            || MAINVALUES_W.equals(facetType)
+            || STATIC_W_INTERPOL.equals(facetType)
+            || STATIC_WQ.equals(facetType)
+            || STATIC_WQ_ANNOTATIONS.equals(facetType);
+    }
+
+
+    /** The station of the current calculation/view. */
+    protected double getKm() {
+        return km;
+    }
+
+    private void doPointsOut(
+        DiagramGenerator generator,
+        double[][] data,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible
+    ) {
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        StyledSeriesBuilder.addPoints(series, data, true);
+        generator.addAxisSeries(series, axisName, visible);
+    }
+
+    /** Handle WQKms data by finding w/q values at given km. */
+    protected void doWQKmsPointOut(
+        DiagramGenerator generator,
+        WQKms wqkms,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible
+    ) {
+        logger.debug("doWQKmsPointOut");
+        String title = bundle.getFacetDescription();
+        XYSeries series = new StyledXYSeries(
+            title,
+            theme);
+
+        double[] kms = wqkms.getKms();
+
+        for (int i = 0 ; i< kms.length; i++) {
+            if (Math.abs(kms[i] - getKm()) <= KM_EPSILON) {
+                series.add(wqkms.getQ(i), wqkms.getW(i));
+                generator.addAxisSeries(series, axisName, visible);
+                if(visible && theme.parseShowPointLabel()) {
+                    List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
+                    XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
+                            title,
+                            wqkms.getQ(i),
+                            // TODO add a percentage to the extend of W axis
+                            wqkms.getW(i));
+                    textAnnos.add(anno);
+                    RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme);
+                    flysAnno.setTextAnnotations(textAnnos);
+                    generator.addAnnotations(flysAnno);
+                }
+                return;
+            }
+        }
+
+        logger.warn("No WQ found for km " + getKm());
+    }
+
+    protected void doRiverAnnotationOut(DiagramGenerator generator,
+        RiverAnnotation annotations,
+        ArtifactAndFacet bundle,
+        ThemeDocument theme,
+        boolean visible
+    ) {
+        if (visible) {
+            annotations.setTheme(theme);
+            generator.addAnnotations(annotations);
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org