diff artifacts/src/main/java/org/dive4elements/river/exports/ReferenceCurveGenerator.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 5e38e2924c07
children 9b8e8fc1f408
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ReferenceCurveGenerator.java	Tue Jun 05 19:10:38 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ReferenceCurveGenerator.java	Tue Jun 05 19:21:16 2018 +0200
@@ -9,6 +9,7 @@
 package org.dive4elements.river.exports;
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WW;
 import org.dive4elements.river.artifacts.model.WW.ApplyFunctionIterator;
@@ -86,12 +87,12 @@
 
     /** Get default chart title. */
     @Override
-    protected String getDefaultChartTitle() {
+    protected String getDefaultChartTitle(final CallContext context) {
         return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
     }
 
     @Override
-    protected String getDefaultChartSubtitle() {
+    protected String getDefaultChartSubtitle(final CallContext context) {
         Object[] args = new Object[] {
             getRiverName(),
         };
@@ -102,14 +103,14 @@
 
     /** True if axis is in cm (because at gauge). */
     protected boolean getInCm(int index) {
-        Object obj = context.getContextValue("reference.curve.axis.scale");
+        Object obj = getContext().getContextValue("reference.curve.axis.scale");
         return obj instanceof WWAxisTypes && ((WWAxisTypes)obj).getInCm(index);
     }
 
 
     /** Get Label for X-axis (W). */
     @Override
-    protected String getDefaultXAxisLabel() {
+    protected String getDefaultXAxisLabel(final CallContext context) {
         return msg(getInCm(0) ? I18N_X_AXIS_IN_CM : I18N_X_AXIS_IN_M);
     }
 
@@ -149,6 +150,8 @@
             return;
         }
 
+        final CallContext context = getContext();
+        
         if (name.equals(facetName())) {
             doReferenceOut(artifactFacet.getData(context), theme, visible);
         }
@@ -194,7 +197,7 @@
     ) {
         WW ww = (WW)data;
 
-        Object obj = context.getContextValue("reference.curve.axis.scale");
+        Object obj = getContext().getContextValue("reference.curve.axis.scale");
 
         WWAxisTypes wwat = obj instanceof WWAxisTypes
             ? (WWAxisTypes)obj
@@ -236,7 +239,7 @@
     /** Set the tick units for given axis. */
     protected void setAxisTickUnit(double tick, ValueAxis axis) {
         TickUnits units = new TickUnits();
-        units.add(new NumberTickUnit(tick, Formatter.getWaterlevelW(context)));
+        units.add(new NumberTickUnit(tick, Formatter.getWaterlevelW(getContext())));
         axis.setStandardTickUnits(units);
         axis.setAutoTickUnitSelection(true);
     }

http://dive4elements.wald.intevation.org