diff flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java @ 2587:bece6f604899

Removed references to Range and replaced those with references to Bounds in ChartGenerators. flys-artifacts/trunk@4143 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 15 Mar 2012 10:30:03 +0000
parents 8cd6358eb7f8
children d75b427da50a
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Wed Mar 14 15:12:45 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Thu Mar 15 10:30:03 2012 +0000
@@ -130,9 +130,9 @@
     public static final int AXIS_SPACE = 5;
 
 
-    protected Map<Integer, Bounds> xRanges;
+    protected Map<Integer, Bounds> xBounds;
 
-    protected Map<Integer, Bounds> yRanges;
+    protected Map<Integer, Bounds> yBounds;
 
 
 
@@ -142,8 +142,8 @@
     public TimeseriesChartGenerator() {
         super();
 
-        xRanges = new HashMap<Integer, Bounds>();
-        yRanges = new HashMap<Integer, Bounds>();
+        xBounds = new HashMap<Integer, Bounds>();
+        yBounds = new HashMap<Integer, Bounds>();
     }
 
 
@@ -183,34 +183,6 @@
     }
 
 
-    // TODO DECLARE IN UPPER CLASS AND ADD OVERRIDE ANNOTATION
-    protected Bounds getXRange(int axis) {
-        return xRanges.get(Integer.valueOf(axis));
-    }
-
-
-    @Override
-    // TODO setXRange should always await a Bounds instance!
-    // TODO SHOULD BE REMOVED WHEN DEFINED IN UPPER CLASS
-    protected void setXRange(int axis, Range range) {
-        // do nothing here, we will use setXRange(int, Bounds) now
-    }
-
-
-    @Override
-    // TODO setYRange should always await a Bounds instance!
-    protected void setYRange(int axis, Range range) {
-        if (range == null) {
-            logger.warn("Range is null!");
-            return;
-        }
-
-        setYBounds(Integer.valueOf(axis), new DoubleBounds(
-            range.getLowerBound(),
-            range.getUpperBound()));
-    }
-
-
     /**
      * This method creates new instances of TimeseriesAxisDataset.
      *
@@ -223,52 +195,10 @@
     }
 
 
-    // TODO THIS SHOULD BE DONE IN AN UPPER CLASS!
     @Override
-    public void addAxisDataset(XYDataset dataset, int idx, boolean visible) {
-        if (dataset == null || idx < 0) {
-            return;
-        }
-
-        AxisDataset axisDataset = getAxisDataset(idx);
-
-        Bounds[] bounds = ChartHelper.getBounds((TimeSeriesCollection)dataset);
-
-        if (bounds == null) {
-            logger.warn("Skip XYDataset for Axis (invalid ranges): " + idx);
-            return;
-        }
-
-        if (visible) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Add new AxisDataset at index: " + idx);
-                logger.debug("X extent: " + bounds[0]);
-                logger.debug("Y extent: " + bounds[1]);
-            }
-
-            axisDataset.addDataset(dataset);
-        }
-
-        combineXRanges(bounds[0], 0);
-        combineYRanges(bounds[1], idx);
-    }
-
-
-    /**
-     * Effect: extend range of x axis to include given limits.
-     * @param range the given ("minimal") range.
-     * @param index index of axis to be merged.
-     */
-    @Override
-    protected void combineXRanges(Range range, int index) {
-        throw new RuntimeException(
-            "TimeseriesChartGenerator.combineXRanges is not implemented!");
-    }
-
-
-    protected void combineXRanges(Bounds bounds, int index) {
+    protected void combineXBounds(Bounds bounds, int index) {
         if (bounds != null) {
-            Bounds old = getXRange(index);
+            Bounds old = getXBounds(index);
 
             if (old != null) {
                 bounds = bounds.combine(old);
@@ -279,7 +209,8 @@
     }
 
 
-    protected void combineYRanges(Bounds bounds, int index) {
+    @Override
+    protected void combineYBounds(Bounds bounds, int index) {
         if (bounds != null) {
             Bounds old = getYBounds(index);
 
@@ -311,25 +242,27 @@
 
     @Override
     public Bounds getXBounds(int axis) {
-        return xRanges.get(axis);
+        return xBounds.get(axis);
     }
 
 
     @Override
     protected void setXBounds(int axis, Bounds bounds) {
-        xRanges.put(axis, bounds);
+        xBounds.put(axis, bounds);
     }
 
 
     @Override
     public Bounds getYBounds(int axis) {
-        return yRanges.get(axis);
+        return yBounds.get(axis);
     }
 
 
     @Override
     protected void setYBounds(int axis, Bounds bounds) {
-        yRanges.put(axis, bounds);
+        if (bounds != null) {
+            yBounds.put(axis, bounds);
+        }
     }
 
 
@@ -415,7 +348,7 @@
     protected void adaptZoom(XYPlot plot) {
         logger.debug("Adapt zoom of Timeseries chart.");
 
-        zoomX(plot, plot.getDomainAxis(), getXRange(0), getDomainAxisRange());
+        zoomX(plot, plot.getDomainAxis(), getXBounds(0), getDomainAxisRange());
 
         Bounds valueAxisBounds = getValueAxisRange();
 

http://dive4elements.wald.intevation.org