[PATCH 3 of 3] Remove AxisProcessor "glue" class and extend Processor interface

Wald Commits scm-commit at wald.intevation.org
Fri Sep 20 10:30:11 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1379665803 -7200
# Branch generator-refactoring
# Node ID f9d5020af0af1dcd522e878011974d3f9ca97d66
# Parent  5c07024cdc24a60b9e8176f1c8669ce284e25fed
Remove AxisProcessor "glue" class and extend Processor interface

diff -r 5c07024cdc24 -r f9d5020af0af artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java	Fri Sep 20 10:29:14 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java	Fri Sep 20 10:30:03 2013 +0200
@@ -58,27 +58,6 @@
         }
     } // class AxisAttributes
 
-    public static class AxisProcessor {
-        private Processor processor;
-        private String axisName;
-
-        public AxisProcessor() {
-        }
-
-        public AxisProcessor(Processor processor, String axisName) {
-            this.processor = processor;
-            this.axisName  = axisName;
-        }
-
-        public Processor getProcessor() {
-            return processor;
-        }
-
-        public String getAxisName() {
-            return axisName;
-        }
-    } // class AxisProcessor
-
     public static class Argument {
         private String expression;
         private String type;
@@ -160,14 +139,14 @@
     } // class Title
 
     private List<AxisAttributes> axesAttrs;
-    private List<AxisProcessor> axesProcessors;
+    private List<Processor> processors;
 
     private Title title;
     private Title subtitle;
 
     public DiagramAttributes() {
         axesAttrs      = new ArrayList<AxisAttributes>(5);
-        axesProcessors = new ArrayList<AxisProcessor>(5);
+        processors     = new ArrayList<Processor>(5);
     }
 
     public DiagramAttributes(Element config) {
@@ -200,8 +179,8 @@
         }
     }
 
-    public List<AxisProcessor> getAxesProcessors() {
-        return axesProcessors;
+    public List<Processor> getProcessors() {
+        return processors;
     }
 
     public Title getTitle() {
@@ -226,7 +205,8 @@
             try {
                 Processor processor =
                     (Processor)Class.forName(className).newInstance();
-                axesProcessors.add(new AxisProcessor(processor, axisName));
+                processor.setAxisName(axisName);
+                processors.add(processor);
             }
             catch (ClassNotFoundException cnfe) {
                 log.error(cnfe, cnfe);
diff -r 5c07024cdc24 -r f9d5020af0af artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Fri Sep 20 10:29:14 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Fri Sep 20 10:30:03 2013 +0200
@@ -41,6 +41,7 @@
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.river.exports.process.Processor;
 import org.dive4elements.river.jfree.AxisDataset;
 import org.dive4elements.river.jfree.AnnotationHelper;
 import org.dive4elements.river.jfree.Bounds;
@@ -53,15 +54,6 @@
 
 import org.w3c.dom.Element;
 
-/* TODO remove after hackish testing */
-import org.dive4elements.river.exports.process.Processor;
-import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor;
-import org.dive4elements.river.exports.process.BedDiffYearProcessor;
-import org.dive4elements.river.exports.process.BedheightProcessor;
-import org.dive4elements.river.exports.process.QOutProcessor;
-import org.dive4elements.river.exports.process.WOutProcessor;
-/* end TODO*/
-
 /**
  * The main diagram creation class.
  *
@@ -1010,16 +1002,10 @@
 
         logger.debug("DoOut for facet: " + facetName);
 
-        for (DiagramAttributes.AxisProcessor ap:
-            diagramAttributes.getAxesProcessors()) {
-
-            Processor pr = ap.getProcessor();
-
+        for (Processor pr: diagramAttributes.getProcessors()) {
             if (pr.canHandle(facetName)) {
-            //    pr.doOut(this, bundle, theme, visible, 0);
+//                pr.doOut(this, bundle, theme, visible, 0);
             }
         }
     }
-
-
 }
diff -r 5c07024cdc24 -r f9d5020af0af artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java	Fri Sep 20 10:29:14 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java	Fri Sep 20 10:30:03 2013 +0200
@@ -10,12 +10,23 @@
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.themes.ThemeDocument;
 
 /** Dummy implementation for the Processor interface.
  */
 public class DefaultProcessor implements Processor {
 
+    protected String axisName;
+
+    public void setAxisName(String axisName) {
+        this.axisName = axisName;
+    }
+
+    public String getAxisName() {
+        return axisName;
+    }
+
     /**
      * Processes data to generate e.g. a chart.
      *
@@ -25,13 +36,22 @@
      * @param visible       The visibility of the curve.
      * @param index        The index of the curve
      */
+    @Override
     public void doOut(
             XYChartGenerator generator,
             ArtifactAndFacet aandf,
             ThemeDocument    theme,
             boolean          visible,
-            int              indexu)
-    {
+            int              index) {
+        return;
+    }
+
+    @Override
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet aandf,
+            ThemeDocument    theme,
+            boolean          visible) {
         return;
     }
 
@@ -41,6 +61,7 @@
      * @param facettype Name of the facet type
      * @return true if the facettype can be processed
      */
+    @Override
     public boolean canHandle(String facettype)
     {
         return false;
diff -r 5c07024cdc24 -r f9d5020af0af artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java	Fri Sep 20 10:29:14 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java	Fri Sep 20 10:30:03 2013 +0200
@@ -31,7 +31,7 @@
 
 /** Helper for data handling in discharge diagrams. */
 public class DischargeProcessor
-implements   Processor, FacetTypes {
+extends DefaultProcessor implements FacetTypes {
 
     private final static Logger logger =
             Logger.getLogger(DischargeProcessor.class);
diff -r 5c07024cdc24 -r f9d5020af0af artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java	Fri Sep 20 10:29:14 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java	Fri Sep 20 10:30:03 2013 +0200
@@ -11,6 +11,7 @@
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.river.exports.XYChartGenerator;
 import org.dive4elements.river.themes.ThemeDocument;
+import org.dive4elements.river.exports.DiagramGenerator;
 
 /**
  * A processor is intended to generate an output e.g. curve in a chart diagramm from
@@ -19,17 +20,46 @@
  * @author <a href="mailto:bjoern.ricks at intevation.de">Björn Ricks</a>
  */
 public interface Processor {
+    /**
+     * Set the axis for this processor.
+     * This should be done before doOut is called for the first time.
+     *
+     * @param axisName The name of the Axis this processor should use.
+     */
+    public void setAxisName(String axisName);
+
+    /**
+     * Get the axis for this processor.
+     *
+     * @return The name of the axis that is used.
+     */
+    public String getAxisName();
 
     /**
      * Processes data to generate e.g. a chart.
      *
      * @param generator XYChartGenerator to add output on.
-     * @param aandf       The artifact and facet
-     * @param theme      The theme that contains styling information.
-     * @param visible       The visibility of the curve.
-     * @param index        The index of the curve
+     * @param aandf     The artifact and facet
+     * @param theme     The theme that contains styling information.
+     * @param visible   The visibility of the curve.
      */
     public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet aandf,
+            ThemeDocument    theme,
+            boolean          visible);
+
+    /**
+     * Processes data to generate e.g. a chart.
+     *
+     * @param generator DiagramGenerator to add output on.
+     * @param aandf     The artifact and facet
+     * @param theme     The theme that contains styling information.
+     * @param visible   The visibility of the curve.
+     * @param index     The index of the curve
+     */
+    @Deprecated
+    public void doOut(
             XYChartGenerator generator,
             ArtifactAndFacet aandf,
             ThemeDocument    theme,


More information about the Dive4elements-commits mailing list