diff artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java@bd047b71ab37
children 4897a58c8746
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java	Thu Apr 25 15:23:37 2013 +0200
@@ -0,0 +1,163 @@
+package org.dive4elements.river.exports;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.w3c.dom.Document;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.river.artifacts.FLYSArtifact;
+import org.dive4elements.river.artifacts.access.HistoricalDischargeAccess;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.Timerange;
+import org.dive4elements.river.artifacts.model.WQKms;
+
+import org.dive4elements.river.jfree.FLYSAnnotation;
+import org.dive4elements.river.jfree.StyledValueMarker;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.utils.FLYSUtils;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class HistoricalDischargeWQCurveGenerator
+extends      XYChartGenerator
+implements   FacetTypes {
+
+    /** Private logger. */
+    private static Logger logger = Logger
+        .getLogger(HistoricalDischargeWQCurveGenerator.class);
+
+    public static final String I18N_CHART_TITLE = "chart.historical.discharge.wq.title";
+
+    public static final String I18N_CHART_SUBTITLE = "chart.historical.discharge.wq.subtitle";
+
+    public static final String I18N_XAXIS_LABEL = "chart.historical.discharge.wq.xaxis.label";
+
+    public static final String I18N_YAXIS_LABEL = "chart.historical.discharge.wq.yaxis.label";
+
+    /** One Y-Axis only, in this chart. */
+    public static enum YAXIS {
+        W(0);
+
+        protected int idx;
+
+        private YAXIS(int c) {
+            idx = c;
+        }
+    }
+
+    @Override
+    protected 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();
+            }
+        };
+    }
+
+    @Override
+    protected String getDefaultChartTitle() {
+        return msg(I18N_CHART_TITLE, I18N_CHART_TITLE);
+    }
+
+    @Override
+    protected String getDefaultChartSubtitle() {
+        FLYSArtifact flys = (FLYSArtifact) master;
+        Timerange evalTime = new HistoricalDischargeAccess(flys)
+            .getEvaluationTimerange();
+
+        Object[] args = new Object[] { FLYSUtils.getReferenceGaugeName(flys),
+            evalTime.getStart(), evalTime.getEnd() };
+
+        return msg(I18N_CHART_SUBTITLE, "", args);
+    }
+
+    @Override
+    protected String getDefaultXAxisLabel() {
+        return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL);
+    }
+
+    @Override
+    protected String getDefaultYAxisLabel(int pos) {
+        if (pos == 0) {
+            return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL);
+        }
+        else {
+            return "NO TITLE FOR Y AXIS: " + pos;
+        }
+    }
+
+    @Override
+    public void doOut(ArtifactAndFacet artifactFacet, Document theme,
+        boolean visible) {
+        String name = artifactFacet.getFacetName();
+        logger.debug("HistoricalDischargeWQCurveGenerator.doOut: " + name);
+        logger.debug("Theme description is: "
+            + artifactFacet.getFacetDescription());
+
+        if (name.equals(HISTORICAL_DISCHARGE_WQ_Q)) {
+            doHistoricalDischargeOutQ(
+                (FLYSArtifact) artifactFacet.getArtifact(),
+                artifactFacet.getData(context),
+                artifactFacet.getFacetDescription(), theme, visible);
+        }
+        else if (name.equals(HISTORICAL_DISCHARGE_WQ_W)) {
+            doHistoricalDischargeOutW(
+                (FLYSArtifact) artifactFacet.getArtifact(),
+                artifactFacet.getData(context),
+                artifactFacet.getFacetDescription(), theme, visible);
+        }
+        else if (name.equals(HISTORICAL_DISCHARGE_WQ_CURVE)) {
+            doHistoricalDischargeCurveOut(
+                (FLYSArtifact) artifactFacet.getArtifact(),
+                artifactFacet.getData(context),
+                artifactFacet.getFacetDescription(), theme, visible);
+        }
+        else if (FacetTypes.IS.MANUALPOINTS(name)) {
+            doPoints(artifactFacet.getData(context), artifactFacet, theme,
+                visible, YAXIS.W.idx);
+        }
+        else if (HISTORICAL_DISCHARGE_MAINVALUES_Q.equals(name)) {
+            doAnnotations((FLYSAnnotation)
+                artifactFacet.getData(context), artifactFacet, theme, visible);
+        }
+        else if (HISTORICAL_DISCHARGE_MAINVALUES_W.equals(name)) {
+            doAnnotations((FLYSAnnotation)
+                artifactFacet.getData(context), artifactFacet, theme, visible);
+        }
+        else {
+            logger.warn("doOut(): unknown facet name: " + name);
+            return;
+        }
+    }
+
+    protected void doHistoricalDischargeOutQ(FLYSArtifact artifact,
+        Object data, String desc, Document theme, boolean visible) {
+        double value = Double.valueOf(data.toString());
+        addDomainMarker(new StyledValueMarker(value, theme), visible);
+    }
+
+    protected void doHistoricalDischargeOutW(FLYSArtifact artifact,
+        Object data, String desc, Document theme, boolean visible) {
+        double value = Double.valueOf(data.toString());
+        addValueMarker(new StyledValueMarker(value, theme), visible);
+    }
+
+    protected void doHistoricalDischargeCurveOut(FLYSArtifact artifact,
+        Object data, String desc, Document theme, boolean visible) {
+        XYSeries series = new StyledXYSeries(desc, theme);
+        StyledSeriesBuilder.addPointsQW(series, (WQKms) data);
+
+        addAxisSeries(series, YAXIS.W.idx, visible);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org