changeset 2049:2d5f2bc68cc6

Centralized the creation of new NumberAxis - new NumberAxis instances in FLYS will be from type IdentifiableNumberAxis which subclasses JFreeChart's NumberAxis. flys-artifacts/trunk@3539 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 23 Dec 2011 15:10:13 +0000
parents 3157a78e6494
children c4e0e433f825
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/IdentifiableNumberAxis.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 6 files changed, 61 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Dec 23 14:24:57 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Dec 23 15:10:13 2011 +0000
@@ -1,3 +1,19 @@
+2011-12-23  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/IdentifiableNumberAxis.java: New.
+	  Subclasses JFreeChart's NumberAxis and offers a getId() method which
+	  returns an identifiable key.
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Implements
+	  a createNumberAxis() method that should be used by all subclasses to
+	  create new axes. This method returns an instance of IdentifiableNumberAxis
+	  which is required for zooming.
+
+	* src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java:
+	  Create new NumberAxis instances by using XYChartGenerator.createNumberAxis().
+
 2011-12-23  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Fri Dec 23 14:24:57 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Fri Dec 23 15:10:13 2011 +0000
@@ -138,7 +138,7 @@
         if (index == YAXIS.W.idx) {
             label = getYAxisLabel();
         }
-        NumberAxis axis = new NumberAxis(label);
+        NumberAxis axis = createNumberAxis(index, label);
         axis.setLabelFont(labelFont);
         axis.setAutoRangeIncludesZero(false);
         return axis;
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Dec 23 14:24:57 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Dec 23 15:10:13 2011 +0000
@@ -86,7 +86,7 @@
         Font labelFont = new Font("Tahoma", Font.BOLD, 14);
         String label   = getYAxisLabel(index);
 
-        NumberAxis axis = new NumberAxis(label);
+        NumberAxis axis = createNumberAxis(index, label);
         if (index == YAXIS.W.idx) {
             axis.setAutoRangeIncludesZero(false);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/IdentifiableNumberAxis.java	Fri Dec 23 15:10:13 2011 +0000
@@ -0,0 +1,22 @@
+package de.intevation.flys.exports;
+
+import org.jfree.chart.axis.NumberAxis;
+
+
+public class IdentifiableNumberAxis extends NumberAxis {
+
+
+    protected String key;
+
+
+    protected IdentifiableNumberAxis(String key, String label) {
+        super(label);
+        this.key = key;
+    }
+
+
+    public String getId() {
+        return key;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Dec 23 14:24:57 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Dec 23 15:10:13 2011 +0000
@@ -221,7 +221,7 @@
         Font labelFont = new Font("Tahoma", Font.BOLD, 14);
         String label   = getYAxisLabel(index);
 
-        NumberAxis axis = new NumberAxis(label);
+        NumberAxis axis = createNumberAxis(index, label);
         // "Q" Axis shall include 0.
         if (index == YAXIS.Q.idx) {
             axis.setAutoRangeIncludesZero(true);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Dec 23 14:24:57 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Dec 23 15:10:13 2011 +0000
@@ -668,6 +668,11 @@
         for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
             ValueAxis yaxis = plot.getRangeAxis(i);
 
+            if (yaxis instanceof IdentifiableNumberAxis) {
+                logger.info("!!! IdentifiableNumberAxis found !!!");
+                // TODO Watch for fixed axes and the specified range
+            }
+
             if (yaxis == null) {
                 logger.debug("Zoom problem: no Y Axis for index: " + i);
                 continue;
@@ -1067,6 +1072,21 @@
 
 
     /**
+     * Creates a new instance of <i>IdentifiableNumberAxis</i>.
+     *
+     * @param idx The index of the new axis.
+     * @param label The label of the new axis.
+     *
+     * @return an instance of IdentifiableNumberAxis.
+     */
+    protected NumberAxis createNumberAxis(int idx, String label) {
+        YAxisWalker walker = getYAxisWalker();
+
+        return new IdentifiableNumberAxis(walker.getId(idx), label);
+    }
+
+
+    /**
      * Returns an instance of <i>ChartSettings</i> with a chart specific section
      * but with no axes settings.
      *

http://dive4elements.wald.intevation.org