changeset 4242:448cbd8708d5

Added new classes for the last commit.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 24 Oct 2012 14:44:12 +0200
parents 49cb65d5932d
children e68a710d9652
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HistoricalWQKms.java flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeWQCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeWQCurveInfoGenerator.java
diffstat 3 files changed, 195 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HistoricalWQKms.java	Wed Oct 24 14:44:12 2012 +0200
@@ -0,0 +1,22 @@
+package de.intevation.flys.artifacts.model;
+
+import de.intevation.flys.model.TimeInterval;
+
+
+public class HistoricalWQKms extends WQKms {
+
+    private TimeInterval timeInterval;
+
+    public HistoricalWQKms() {
+    }
+
+    public HistoricalWQKms(double[] kms, double[] qs, double[] ws, String name,
+        TimeInterval timeInterval) {
+        super(kms, qs, ws, name);
+        this.timeInterval = timeInterval;
+    }
+
+    public TimeInterval getTimeInterval() {
+        return timeInterval;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeWQCurveGenerator.java	Wed Oct 24 14:44:12 2012 +0200
@@ -0,0 +1,156 @@
+package de.intevation.flys.exports;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.w3c.dom.Document;
+
+import de.intevation.artifactdatabase.state.ArtifactAndFacet;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.access.HistoricalDischargeAccess;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.Timerange;
+import de.intevation.flys.artifacts.model.WQKms;
+import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.utils.FLYSUtils;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class HistoricalDischargeWQCurveGenerator extends XYChartGenerator
+    implements FacetTypes {
+
+    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";
+
+    public static final String I18N_YAXIS_SECOND_LABEL = "chart.historical.discharge.wq.yaxis.second.label";
+
+    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 if (pos == 1) {
+            return msg(I18N_YAXIS_SECOND_LABEL, I18N_YAXIS_SECOND_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 {
+            logger.warn("doOut(): unknown facet name: " + name);
+            return;
+        }
+    }
+
+    protected void doHistoricalDischargeOutQ(FLYSArtifact artifact,
+        Object data, String desc, Document theme, boolean visible) {
+        logger.debug("doHistoricalDischargeOutQ(): description = " + desc);
+
+        // addAxisDataset(series, YAXIS.Q.idx, visible);
+    }
+
+    protected void doHistoricalDischargeOutW(FLYSArtifact artifact,
+        Object data, String desc, Document theme, boolean visible) {
+        logger.debug("doHistoricalDischargeOutW(): description = " + desc);
+
+        // addAxisDataset(series, YAXIS.W.idx, 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 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeWQCurveInfoGenerator.java	Wed Oct 24 14:44:12 2012 +0200
@@ -0,0 +1,17 @@
+package de.intevation.flys.exports;
+
+
+/**
+ * A ChartInfoGenerator that generates meta information for specific
+ * historical discharge curves.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class HistoricalDischargeWQCurveInfoGenerator
+extends      ChartInfoGenerator
+{
+    public HistoricalDischargeWQCurveInfoGenerator() {
+        super(new HistoricalDischargeWQCurveGenerator());
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org