diff artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java @ 9104:07d51fd4864c

Added metadata subtitle to all chart export
author gernotbelger
date Tue, 29 May 2018 11:35:44 +0200
parents 3ac9cb0029b2
children 1cc7653ca84f
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java	Tue May 29 11:02:56 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java	Tue May 29 11:35:44 2018 +0200
@@ -80,7 +80,8 @@
  * It should provide some basic things that equal in all chart types.
  *
  */
-public abstract class ChartGenerator2 implements OutGenerator {
+// FIXME: copy/paste of ChartGenerator with LOTS of duplicate code... move duplicates to AbstractChartGenrator!
+public abstract class ChartGenerator2 extends AbstractChartGenerator {
 
     private static Logger log = Logger.getLogger(ChartGenerator2.class);
 
@@ -146,8 +147,24 @@
      * Default constructor that initializes internal data structures.
      */
     public ChartGenerator2() {
-        datasets = new TreeMap<Integer, AxisDataset>();
-        yAnnotations = new TreeMap<Integer, RiverAnnotation>();
+        datasets = new TreeMap<>();
+        yAnnotations = new TreeMap<>();
+    }
+    
+    @Override
+    protected final D4EArtifact getArtifact() {
+        // FIXME: should already made sure when this member is set
+        return (D4EArtifact) this.master;
+    }
+
+    @Override
+    protected final CallContext getContext() {
+        return this.context;
+    }
+    
+    @Override
+    protected final Document getRequest() {
+        return this.request;
     }
 
     /**
@@ -263,7 +280,7 @@
             chart.addSubtitle(new TextTitle(subtitle));
         }
     }
-
+    
     /**
      * Generate chart.
      */
@@ -1091,23 +1108,6 @@
         return Resources.getMsg(context.getMeta(), key, def, args);
     }
 
-
-    protected String getRiverName() {
-        D4EArtifact flys = (D4EArtifact) master;
-
-        River river = RiverUtils.getRiver(flys);
-        return (river != null) ? river.getName() : "";
-    }
-
-
-    protected double[] getRange() {
-        D4EArtifact flys = (D4EArtifact) master;
-
-        RangeAccess rangeAccess = new RangeAccess(flys);
-        return rangeAccess.getKmRange();
-    }
-
-
     /**
      * Returns the size of a chart export as array which has been specified by
      * the incoming request document.
@@ -1164,7 +1164,6 @@
             : format;
     }
 
-
     /**
      * Returns the X-Axis range as String array from request document.
      * If the (x|y)range elements are not found in request document, return

http://dive4elements.wald.intevation.org