diff flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java @ 1933:9e9cfc036a3f

Better use multiple axis feature in chart generators. flys-artifacts/trunk@3314 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 24 Nov 2011 11:03:33 +0000
parents 7c52e9cb2a72
children 06d8d371d244
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Thu Nov 24 10:59:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Thu Nov 24 11:03:33 2011 +0000
@@ -2,9 +2,12 @@
 
 import org.apache.log4j.Logger;
 
+import java.awt.Font;
+
 import org.w3c.dom.Document;
 
 import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.plot.XYPlot;
 import org.jfree.data.Range;
@@ -35,6 +38,14 @@
 extends      XYChartGenerator
 implements   FacetTypes {
 
+    public static enum YAXIS {
+        W(0);
+        protected int idx;
+        private YAXIS(int c) {
+            idx = c;
+        }
+    }
+
     /** The logger used in this generator. */
     private static Logger logger =
         Logger.getLogger(DischargeCurveGenerator.class);
@@ -56,7 +67,6 @@
     public static final String I18N_YAXIS_LABEL_DEFAULT  = "W [cm]";
 
 
-
     public DischargeCurveGenerator() {
         super();
     }
@@ -75,11 +85,16 @@
     }
 
 
+    /**
+     * i18n-Label for X-Axis.
+     */
     protected String getXAxisLabel() {
         return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
     }
 
-
+    /**
+     * i18n-Label for X-Axis (W).
+     */
     protected String getYAxisLabel() {
         return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
     }
@@ -96,6 +111,23 @@
         return zoomin;
     }
 
+    /**
+     * Create Y-Axis.
+     * First Axis: W.
+     * @return Y-Axis with label.
+     */
+    @Override
+    protected NumberAxis createYAxis(int index) {
+        Font labelFont = new Font("Tahoma", Font.BOLD, 14);
+        String label = "default";
+        if (index == YAXIS.W.idx) {
+            label = getYAxisLabel();
+        }
+        NumberAxis axis = new NumberAxis(label);
+        axis.setLabelFont(labelFont);
+        return axis;
+    }
+
 
     public void doOut(
         Artifact artifact,
@@ -171,7 +203,7 @@
 
         StyledSeriesBuilder.addPointsQW(series, wqkms);
 
-        addAxisSeries(series, 0, visible);
+        addAxisSeries(series, YAXIS.W.idx, visible);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org