changeset 4362:17251b058bf1

ExtremeWQCurveGenerator: Reuse prerpareChartData, handle new extreme_wq_curve_base facet.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 02 Nov 2012 12:09:50 +0100
parents 7302c635dfda
children 9dfec327acc6
files flys-artifacts/src/main/java/de/intevation/flys/exports/extreme/ExtremeWQCurveGenerator.java
diffstat 1 files changed, 34 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/extreme/ExtremeWQCurveGenerator.java	Fri Nov 02 12:09:03 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/extreme/ExtremeWQCurveGenerator.java	Fri Nov 02 12:09:50 2012 +0100
@@ -7,6 +7,7 @@
 import org.jfree.chart.plot.Marker;
 import org.jfree.chart.plot.ValueMarker;
 import org.jfree.chart.title.TextTitle;
+import org.jfree.data.xy.XYSeries;
 import org.w3c.dom.Document;
 
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
@@ -16,8 +17,9 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.extreme.Curve;
 import de.intevation.flys.artifacts.model.extreme.ExtremeCurveFacet;
+import de.intevation.flys.artifacts.resources.Resources;
 import de.intevation.flys.exports.fixings.FixWQCurveGenerator;
-import de.intevation.flys.artifacts.resources.Resources;
+import de.intevation.flys.exports.StyledSeriesBuilder;
 import de.intevation.flys.exports.ChartGenerator;
 import de.intevation.flys.jfree.JFreeUtil;
 import de.intevation.flys.jfree.StyledXYSeries;
@@ -58,25 +60,43 @@
     public static final String I18N_YAXIS_LABEL_DEFAULT  =
             "W [NN + m]";
 
-    @Override
-    public void doOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
-        super.doOut(aaf, doc, visible);
 
-        String name = aaf.getFacetName();
-        logger.debug("doOut: " + name);
+    @Override
+    public boolean prepareChartData(ArtifactAndFacet aaf, Document theme, boolean visible) {
+        if (!super.prepareChartData(aaf, theme, visible)) {
+            String name = aaf.getFacetName();
+            if (name.equals(EXTREME_WQ_CURVE)) {
+                doExtremeCurveOut(aaf, theme, visible);
+                return true;
+            }
+            else if (name.equals(EXTREME_WQ_CURVE_BASE)) {
+                doExtremeCurveBaseOut(aaf, theme, visible);
+                return true;
+            }
+            return false;
+        }
+        return true;
+    }
 
-        if (name.equals(EXTREME_WQ_CURVE)) {
-            doExtremeCurveOut(aaf, doc, visible);
-        }
-        else {
-            logger.warn("Unknown facet name " + name);
+    /** Do Extreme Curve nonextrapolated points out. */
+    protected void doExtremeCurveBaseOut(ArtifactAndFacet aaf, Document theme, boolean visible) {
+        logger.debug("doExtremeCurveBaseOut");
+        ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet();
+        Curve curve = (Curve) facet.getData(aaf.getArtifact(), context);
+        if (curve == null) {
+            logger.warn("doExtremeCurveiBaseOut: Facet does not contain Curve");
             return;
         }
+
+        XYSeries qwseries = new StyledXYSeries("meas", theme);
+        StyledSeriesBuilder.addPointsQW(qwseries, curve.getQs(), curve.getWs());
+ 
+        addAxisSeries(qwseries, YAXIS.W.idx, visible);
     }
 
 
     /** Do Extreme Curve out */
-    protected void doExtremeCurveOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
+    protected void doExtremeCurveOut(ArtifactAndFacet aaf, Document theme, boolean visible) {
         logger.debug("doExtremeCurveOut");
         ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet();
         Curve curve = (Curve) facet.getData(aaf.getArtifact(), context);
@@ -92,7 +112,7 @@
 
         StyledXYSeries series = JFreeUtil.sampleFunction2D(
                 curve,
-                doc,
+                theme,
                 aaf.getFacetDescription(),
                 500,   // number of samples
                 0.0 ,  // start
@@ -109,6 +129,7 @@
         addAxisSeries(series, 0, visible);
     }
 
+
     @Override
     protected String getChartTitle() {
         return Resources.format(

http://dive4elements.wald.intevation.org