[Dive4elements-commits] [PATCH 4 of 8] Implement a BedheightProcessor to generate charts from bed height data

Wald Commits scm-commit at wald.intevation.org
Thu Nov 15 16:31:33 CET 2012


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1352992881 -3600
# Node ID ce4ff444f215a396389cae8c75eff28744751875
# Parent  b838d16c629ea3c6a263c1c1c671ab0896329d42
Implement a BedheightProcessor to generate charts from bed height data

diff -r b838d16c629e -r ce4ff444f215 flys-artifacts/src/main/java/de/intevation/flys/exports/process/BedheightProcessor.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/process/BedheightProcessor.java	Thu Nov 15 16:21:21 2012 +0100
@@ -0,0 +1,77 @@
+package de.intevation.flys.exports.process;
+
+import java.util.List;
+
+import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;
+
+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.artifacts.CallContext;
+import de.intevation.flys.artifacts.model.minfo.BedHeightSingle;
+import de.intevation.flys.exports.XYChartGenerator;
+import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.model.BedHeightSingleValue;
+
+public class BedheightProcessor implements Processor {
+
+    private final static Logger logger =
+            Logger.getLogger(BedheightProcessor.class);
+
+    private final static String BEDHEIGHT = "bedheight";
+
+    @Override
+    public void doOut(XYChartGenerator generator, ArtifactAndFacet aandf,
+            Document theme, boolean visible, int index) {
+        CallContext context = generator.getCallContext();
+        Object data = aandf.getData(context);
+        if (data instanceof BedHeightSingle) {
+            doBedheightSingleOut(generator, aandf, theme, index, visible,
+                    (BedHeightSingle)data);
+        }
+        else if (data instanceof List<?>) {
+            doBedheightSingeValuesOut(generator, aandf, theme, index, visible,
+                    (List<BedHeightSingleValue>)data);
+        }
+        logger.error("Can't process " + data.getClass().getName() + " objects");
+    }
+
+    private void doBedheightSingeValuesOut(XYChartGenerator generator,
+            ArtifactAndFacet aandf, Document theme, int index, boolean visible,
+            List<BedHeightSingleValue> data) {
+        logger.debug("doBedheightSingleOut");
+
+        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(),
+                theme);
+        for(BedHeightSingleValue bvalue: data) {
+            series.add(bvalue.getStation(), bvalue.getSoundingWidth());
+        }
+        generator.addAxisSeries(series, index, visible);
+    }
+
+    @Override
+    public boolean canHandle(String facettype) {
+        return BEDHEIGHT.equals(facettype);
+    }
+
+    public void doBedheightSingleOut(XYChartGenerator generator,
+            ArtifactAndFacet aandf, Document theme, int index, boolean visible,
+            BedHeightSingle data) {
+        double[] width = data.getMorphWidths();
+        double[] stations = data.getStations().toNativeArray();
+
+        logger.debug("doBedheightSingleOut");
+
+        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(),
+                theme);
+
+        for (int i = 0; i < width.length; i++) {
+            series.add(stations[i], width[i], false);
+        }
+
+        generator.addAxisSeries(series, index, visible);
+    }
+
+}


More information about the Dive4elements-commits mailing list