diff artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 7084:f0731aa7b735 generator-refactoring

Implement Label handling
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 20 Sep 2013 19:18:04 +0200
parents 3c4efd4b2c19
children 42e243c640a0
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Fri Sep 20 19:17:49 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Fri Sep 20 19:18:04 2013 +0200
@@ -118,8 +118,8 @@
 
         JFreeChart chart = ChartFactory.createXYLineChart(
             getChartTitle(),
-            getXAxisLabel(),
-            getYAxisLabel(0),
+            "",
+            "",
             null,
             PlotOrientation.VERTICAL,
             isLegendVisible(),
@@ -173,6 +173,9 @@
         return chart;
     }
 
+    public String getOutName() {
+        return outName;
+    }
 
     /**
      * Return left most data points x value (on first axis).
@@ -1021,31 +1024,18 @@
      */
     @Override
     protected String getDefaultXAxisLabel() {
-        return "TODO X axis label";
-/*        D4EArtifact flys = (D4EArtifact) master;
+        DiagramAttributes.Title dTitle = diagramAttributes.getDomainAxisTitle();
+        if (dTitle == null) {
+            return "Domain Axis Title not configured in conf.xml";
+        }
 
-        return msg(
-            I18N_XAXIS_LABEL,
-            I18N_XAXIS_LABEL_DEFAULT,
-            new Object[] { RiverUtils.getRiver(flys).getName() }); */
+        return dTitle.evaluate((D4EArtifact)getMaster(), context);
     }
 
     @Override
-    protected String getDefaultYAxisLabel(int index) {
-        return "TODO Y Axis label";
-/*        String label = "default";
-
-        if (index == YAXIS.W.idx) {
-            label = getWAxisLabel();
-        }
-        else if (index == YAXIS.Q.idx) {
-            label = msg(getQAxisLabelKey(), getQAxisDefaultLabel());
-        }
-        else if (index == YAXIS.D.idx) {
-            label = msg(I18N_WDIFF_YAXIS_LABEL, I18N_WDIFF_YAXIS_LABEL_DEFAULT);
-        }
-
-        return label;*/
+    protected String getDefaultYAxisLabel(String axisName) {
+        Processor pr = diagramAttributes.getProcessorForAxisName(axisName);
+        return pr == null ? "" : pr.getAxisLabel(this);
     }
 
 
@@ -1061,8 +1051,9 @@
 
         for (int i = 0, n = axesAttrs.size(); i < n; i++) {
             AxisSection ySection = new AxisSection();
-            ySection.setIdentifier(diagramAttributes.getAxisName(i));
-            ySection.setLabel(getYAxisLabel(i));
+            String axisName = diagramAttributes.getAxisName(i);
+            ySection.setIdentifier(axisName);
+            ySection.setLabel(getYAxisLabel(axisName));
             ySection.setFontSize(14);
             ySection.setFixed(false);
 
@@ -1079,6 +1070,27 @@
         return axisSections;
     }
 
+    /**
+     * Returns the Y-Axis label of a chart at position <i>pos</i>.
+     *
+     * @return the Y-Axis label of a chart at position <i>0</i>.
+     */
+    protected String getYAxisLabel(String axisName) {
+        ChartSettings chartSettings = getChartSettings();
+        if (chartSettings == null) {
+            return getDefaultYAxisLabel(axisName);
+        }
+        AxisSection as = chartSettings.getAxisSection(axisName);
+        if (as != null) {
+            String label = as.getLabel();
+            if (label != null) {
+                return label;
+            }
+        }
+
+        return getDefaultYAxisLabel(axisName);
+    }
+
     protected String axisIndexToName(int index) {
         return diagramAttributes.getAxisName(index);
     }

http://dive4elements.wald.intevation.org