changeset 7093:cdae0ff8960b generator-refactoring

Add DiagramGenerator doOut function
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 23 Sep 2013 10:24:47 +0200
parents 6563262052ab
children 5c059c05b100
files artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java	Mon Sep 23 10:23:21 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java	Mon Sep 23 10:24:47 2013 +0200
@@ -17,6 +17,7 @@
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle;
 import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.jfree.StyledXYSeries;
 import org.dive4elements.river.model.BedHeightSingleValue;
 import org.dive4elements.river.themes.ThemeDocument;
@@ -30,6 +31,38 @@
 
     @Override
     public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible) {
+        CallContext context = generator.getCallContext();
+        Object data = bundle.getData(context);
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+                theme);
+        if (data instanceof BedHeightSingle) {
+            BedHeightSingle bData = (BedHeightSingle)data;
+            double[] width = bData.getMorphWidths();
+            double[] stations = bData.getStations().toNativeArray();
+
+            logger.debug("doBedheightSingleOut");
+
+            for (int i = 0; i < width.length; i++) {
+                series.add(stations[i], width[i], false);
+            }
+        } else if (data instanceof List<?>) {
+            List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data;
+
+            logger.debug("doBedheightSingleValueOut");
+
+            for(BedHeightSingleValue bvalue: bData) {
+                series.add(bvalue.getStation(), bvalue.getSoundingWidth());
+            }
+        }
+        generator.addAxisSeries(series, axisName, visible);
+    }
+
+    @Override
+    public void doOut(
             XYChartGenerator generator,
             ArtifactAndFacet bundle,
             ThemeDocument theme,

http://dive4elements.wald.intevation.org