diff artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java @ 9123:1cc7653ca84f

Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
author gernotbelger
date Tue, 05 Jun 2018 19:21:16 +0200
parents 07d51fd4864c
children 7c7f73e5e01e
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java	Tue Jun 05 19:10:38 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java	Tue Jun 05 19:21:16 2018 +0200
@@ -9,12 +9,12 @@
 package org.dive4elements.river.exports;
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.jfree.Bounds;
 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
 import org.dive4elements.river.jfree.DoubleBounds;
 import org.dive4elements.river.jfree.RiverAnnotation;
-import org.dive4elements.river.jfree.AnnotationHelper;
 import org.dive4elements.river.jfree.StyledTimeSeries;
 import org.dive4elements.river.jfree.TimeBounds;
 import org.dive4elements.river.jfree.AxisDataset;
@@ -93,14 +93,12 @@
         attributes = new HashMap<String, String>();
     }
 
-
-
     @Override
-    public JFreeChart generateChart() {
+    protected JFreeChart generateChart(CallContext context) {
         log.info("Generate Timeseries Chart.");
 
         JFreeChart chart = ChartFactory.createTimeSeriesChart(
-            getChartTitle(),
+            getChartTitle(context),
             getXAxisLabel(),
             getYAxisLabel(0),
             null,
@@ -113,8 +111,8 @@
         chart.setBackgroundPaint(Color.WHITE);
         plot.setBackgroundPaint(Color.WHITE);
 
-        addSubtitles(chart);
-        addMetadataSubtitle( chart );
+        addSubtitles(context, chart);
+        addMetadataSubtitle( context, chart );
         adjustPlot(plot);
         addDatasets(plot);
         adjustAxes(plot);
@@ -126,11 +124,8 @@
 
         consumeAxisSettings(plot);
 
-        AnnotationHelper.addAnnotationsToRenderer(
-            annotations,
-            plot,
-            getChartSettings(),
-            datasets);
+        addAnnotationsToRenderer(plot);
+        
         addLogo(plot);
         aggregateLegendEntries(plot);
         return chart;
@@ -629,7 +624,7 @@
         catch(JSONException ex) {
             String str = array.getString(0);
             DateFormat df = DateFormat.getDateInstance(
-                    DateFormat.MEDIUM, Resources.getLocale(context.getMeta()));
+                    DateFormat.MEDIUM, Resources.getLocale(getContext().getMeta()));
             return df.parse(str);
         }
     }
@@ -856,7 +851,7 @@
      * setLowerTimeRange */
     @Override
     protected List<AxisSection> buildXAxisSections() {
-        List<AxisSection> axisSections = new ArrayList<AxisSection>();
+        List<AxisSection> axisSections = new ArrayList<>();
 
         String identifier = "X";
 

http://dive4elements.wald.intevation.org