[PATCH 08 of 15] issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor)
Wald Commits
scm-commit at wald.intevation.org
Fri Nov 1 18:11:58 CET 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1383319852 -3600
# Node ID e11bf92bca4ac54fbe68dda19318f0c6dc0b2fb2
# Parent f2d97537f48a8d8c970376d006fcb24f97687399
issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
diff -r f2d97537f48a -r e11bf92bca4a artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java Fri Nov 01 16:30:52 2013 +0100
@@ -0,0 +1,85 @@
+/* Copyright (C) 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.Set;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.dive4elements.river.artifacts.D4EArtifact;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+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.dive4elements.river.artifacts.model.minfo.SedimentLoad;
+import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction;
+
+public class SedimentLoadM3AProcessor extends DefaultProcessor {
+
+ private final static Logger logger =
+ Logger.getLogger(SedimentLoadM3AProcessor.class);
+
+ public static final String I18N_YAXIS_LABEL =
+ "chart.sedimentload.ls.yaxis.label.m3pera";
+ public static final String I18N_YAXIS_LABEL_DEFAULT = "[m\u00b3/a]";
+
+ @Override
+ public void doOut(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible) {
+ logger.debug("doOut " + bundle.getFacetName());
+ CallContext context = generator.getCallContext();
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+ theme);
+ Object data = bundle.getData(context);
+ String facetName = bundle.getFacetName();
+ double [][] points;
+
+ if (FacetTypes.IS.SEDIMENT_LOAD_M3A(facetName)) {
+ points = (double[][]) data;
+ } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) {
+ SedimentLoad load = (SedimentLoad) data;
+ Set<Double> kms = load.getKms();
+ points = new double[2][kms.size()];
+ int counter = 0;
+ for (Double km: kms) {
+ SedimentLoadFraction fraction = load.getFraction(km);
+ points[0][counter] = km;
+ points[1][counter] = fraction.getUnknown();
+ counter++;
+ }
+ } else {
+ logger.error("Unknown facet name: " + facetName);
+ return;
+ }
+
+ StyledSeriesBuilder.addPoints(series, points, true);
+
+ generator.addAxisSeries(series, axisName, visible);
+ }
+
+ @Override
+ public boolean canHandle(String facettype) {
+ return FacetTypes.IS.SEDIMENT_LOAD_M3A(facettype) ||
+ FacetTypes.SEDIMENT_LOAD_M3A_UNKNOWN.equals(facettype);
+ }
+
+ @Override
+ public String getAxisLabel(DiagramGenerator generator) {
+ return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
+ }
+}
diff -r f2d97537f48a -r e11bf92bca4a artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java Fri Nov 01 16:30:52 2013 +0100
@@ -0,0 +1,85 @@
+/* Copyright (C) 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.Set;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.dive4elements.river.artifacts.D4EArtifact;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+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.dive4elements.river.artifacts.model.minfo.SedimentLoad;
+import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction;
+
+public class SedimentLoadTAProcessor extends DefaultProcessor {
+
+ private final static Logger logger =
+ Logger.getLogger(SedimentLoadTAProcessor.class);
+
+ public static final String I18N_YAXIS_LABEL =
+ "chart.sedimentload.ls.yaxis.label.tpera";
+ public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]";
+
+ @Override
+ public void doOut(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible) {
+ logger.debug("doOut " + bundle.getFacetName());
+ CallContext context = generator.getCallContext();
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+ theme);
+ Object data = bundle.getData(context);
+ String facetName = bundle.getFacetName();
+ double [][] points;
+
+ if (FacetTypes.IS.SEDIMENT_LOAD_TA(facetName)) {
+ points = (double[][]) data;
+ } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) {
+ SedimentLoad load = (SedimentLoad) data;
+ Set<Double> kms = load.getKms();
+ points = new double[2][kms.size()];
+ int counter = 0;
+ for (Double km: kms) {
+ SedimentLoadFraction fraction = load.getFraction(km);
+ points[0][counter] = km;
+ points[1][counter] = fraction.getUnknown();
+ counter++;
+ }
+ } else {
+ logger.error("Unknown facet name: " + facetName);
+ return;
+ }
+
+ StyledSeriesBuilder.addPoints(series, points, true);
+
+ generator.addAxisSeries(series, axisName, visible);
+ }
+
+ @Override
+ public boolean canHandle(String facettype) {
+ return FacetTypes.IS.SEDIMENT_LOAD_TA(facettype) ||
+ FacetTypes.SEDIMENT_LOAD_TA_UNKNOWN.equals(facettype);
+ }
+
+ @Override
+ public String getAxisLabel(DiagramGenerator generator) {
+ return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
+ }
+}
More information about the Dive4elements-commits
mailing list