changeset 348:635af5381a4d

Added an abstract OutGenerator that should be the base class for all generators which create charts. flys-artifacts/trunk@1750 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 27 Apr 2011 14:40:44 +0000
parents a63d8bdb2d79
children 6167ae622ce0
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java
diffstat 3 files changed, 60 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Apr 27 14:35:44 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Apr 27 14:40:44 2011 +0000
@@ -1,3 +1,13 @@
+2011-04-27  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/ChartGenerator.java: New. An
+	  abstract OutGenerator that might be used to create chart output. Some
+	  basic things that are equal in all charts should be done here!
+
+	* src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java:
+	  This OutGenerator no longer implements the OutGenerator directly, but it
+	  extends the ChartGenerator now.
+
 2011-04-27  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Wed Apr 27 14:40:44 2011 +0000
@@ -0,0 +1,48 @@
+package de.intevation.flys.exports;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Document;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+
+/**
+ * The base class for chart creation. It should provide some basic things that
+ * equal in all chart types.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public abstract class ChartGenerator implements OutGenerator {
+
+    private static Logger logger = Logger.getLogger(ChartGenerator.class);
+
+
+    /** The document of the incoming out() request.*/
+    protected Document request;
+
+    /** The output stream where the data should be written to.*/
+    protected OutputStream out;
+
+    /** The CallContext object.*/
+    protected CallContext context;
+
+
+    public void init(Document request, OutputStream out, CallContext context) {
+        logger.debug("ChartGenerator.init");
+
+        this.request = request;
+        this.out     = out;
+        this.context = context;
+    }
+
+
+    public abstract void doOut(Artifact artifact, Document attr);
+
+    public abstract void generate() throws IOException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Wed Apr 27 14:35:44 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Wed Apr 27 14:40:44 2011 +0000
@@ -2,7 +2,6 @@
 
 import java.awt.Color;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -18,7 +17,6 @@
 import org.jfree.chart.plot.PlotOrientation;
 
 import de.intevation.artifacts.Artifact;
-import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.model.Gauge;
 
@@ -33,35 +31,19 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class DischargeCurveGenerator implements OutGenerator {
+public class DischargeCurveGenerator extends ChartGenerator {
 
     /** The logger used in this generator.*/
     private static Logger logger =
         Logger.getLogger(DischargeCurveGenerator.class);
 
-    /** The document of the incoming out() request.*/
-    protected Document request;
-
-    /** The output stream where the data should be written to.*/
-    protected OutputStream out;
-
-    /** The CallContext object.*/
-    protected CallContext context;
 
     /** The Dataset that contains the data for the chart.*/
     protected DefaultXYDataset dataset;
 
 
     public DischargeCurveGenerator() {
-    }
-
-
-    public void init(Document request, OutputStream out, CallContext context) {
-        logger.debug("DischargeCurveGenerator.init");
-
-        this.request = request;
-        this.out     = out;
-        this.context = context;
+        super();
 
         this.dataset = new DefaultXYDataset();
     }

http://dive4elements.wald.intevation.org