changeset 7091:c7d8adb91576 generator-refactoring

Simplify code to prepare DiagramGenerator signature
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 23 Sep 2013 10:22:52 +0200 (2013-09-23)
parents 9a37d6dce2c7
children 6563262052ab
files artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java
diffstat 1 files changed, 18 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java	Mon Sep 23 10:21:59 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java	Mon Sep 23 10:22:52 2013 +0200
@@ -38,26 +38,26 @@
     ) {
         CallContext context = generator.getCallContext();
         Object data = bundle.getData(context);
-        if (data instanceof BedHeightSingle) {
-            doBedheightSingleOut(generator, bundle, theme, index, visible,
-                    (BedHeightSingle)data);
-        }
-        else if (data instanceof List<?>) {
-            doBedheightSingeValuesOut(generator, bundle, theme, index, visible,
-                    (List<BedHeightSingleValue>)data);
-        }
-        logger.error("Can't process " + data.getClass().getName() + " objects");
-    }
-
-    private void doBedheightSingeValuesOut(XYChartGenerator generator,
-            ArtifactAndFacet bundle, ThemeDocument theme, int index, boolean visible,
-            List<BedHeightSingleValue> data) {
-        logger.debug("doBedheightSingeValuesOut");
-
         XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
-        for(BedHeightSingleValue bvalue: data) {
-            series.add(bvalue.getStation(), bvalue.getSoundingWidth());
+        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, index, visible);
     }
@@ -66,22 +66,4 @@
     public boolean canHandle(String facettype) {
         return BEDHEIGHT.equals(facettype);
     }
-
-    public void doBedheightSingleOut(XYChartGenerator generator,
-            ArtifactAndFacet bundle, ThemeDocument theme, int index, boolean visible,
-            BedHeightSingle data) {
-        double[] width = data.getMorphWidths();
-        double[] stations = data.getStations().toNativeArray();
-
-        logger.debug("doBedheightSingleOut");
-
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
-                theme);
-
-        for (int i = 0; i < width.length; i++) {
-            series.add(stations[i], width[i], false);
-        }
-
-        generator.addAxisSeries(series, index, visible);
-    }
 }

http://dive4elements.wald.intevation.org