diff flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java @ 3610:66f539df4e8b

Issue 716. FixA: Spilt reference and analysis period themes into one theme for each event. flys-artifacts/trunk@5239 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 23 Aug 2012 08:49:37 +0000
parents 988ec06c400a
children a74bdd032cf7
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Wed Aug 22 14:51:19 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Thu Aug 23 08:49:37 2012 +0000
@@ -243,7 +243,7 @@
         addAttribute(desc, "outline");
         Map<Integer, int[]> annoIdxMap = new HashMap<Integer, int[]>();
         annoIdxMap.put (0, new int[]{0,0});
-        doQWDTextAnnotations(annoIdxMap, tsc, new QWD[]{qwd.qwd}, theme, visible);
+        doQWDTextAnnotations(annoIdxMap, tsc, qwd.qwd, theme, visible);
     }
 
 
@@ -256,25 +256,20 @@
     ) {
         logger.debug("doAnalysisEventsOut: desc = " + desc);
 
-        QWD[] qwds = (QWD[]) data;
-        doQWDEventsOut(qwds, desc, theme, visible);
+        QWD qwd = (QWD) data;
+        doQWDEventsOut(qwd, desc, theme, visible);
     }
 
 
-    protected void doQWDEventsOut(QWD[] qwds, String desc, Document theme, boolean visible)
+    protected void doQWDEventsOut(QWD qwd, String desc, Document theme, boolean visible)
     {
         TimeSeriesCollection tsc = new TimeSeriesCollection();
 
         TimeSeries   series = new StyledTimeSeries(desc, theme);
         TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme);
 
-        if (qwds == null) {
-            logger.debug("doQWDEventsOut: qwds == null");
-            return;
-        }
-
-        if (qwds.length == 0) {
-            logger.debug("doQWDEventsOut: qwds.length == 0");
+        if (qwd == null) {
+            logger.debug("doQWDEventsOut: qwd == null");
             return;
         }
 
@@ -282,38 +277,33 @@
 
         int idxInterpol = 0;
         int idxRegular = 0;
-        for (int i = 0; i < qwds.length; i++) {
-            if (qwds[i] == null) {
-                logger.debug("doQWDEventsOut: qwds[" + i + "] == null");
-                continue;
-            }
-            RegularTimePeriod rtp = new Day(qwds[i].getDate());
-            double value =  qwds[i].getDeltaW();
-            boolean interpolate = qwds[i].getInterpolated();
-            if (interpolate) {
-                if(interpol.addOrUpdate(rtp, value) == null) {
-                    annoIdxMap.put(
-                            i,
-                            new int[]{1, idxInterpol});
-                    idxInterpol++;
-                }
-            }
-            else {
-                if(series.addOrUpdate(rtp, value) == null) {
-                    annoIdxMap.put(
-                            i,
-                            new int[]{0, idxRegular});
-                    idxRegular++;
-                }
+        RegularTimePeriod rtp = new Day(qwd.getDate());
+        double value =  qwd.getDeltaW();
+        boolean interpolate = qwd.getInterpolated();
+        if (interpolate) {
+            if(interpol.addOrUpdate(rtp, value) == null) {
+                annoIdxMap.put(
+                        0,
+                        new int[]{1, idxInterpol});
+                idxInterpol++;
             }
         }
+        else {
+            if(series.addOrUpdate(rtp, value) == null) {
+                annoIdxMap.put(
+                        0,
+                        new int[]{0, idxRegular});
+                idxRegular++;
+            }
+        }
+
         tsc.addSeries(series);
         tsc.addSeries(interpol);
         addAxisDataset(tsc, 0, visible);
         addAttribute(desc + "interpol", "interpolate");
         addAttribute(desc, "outline");
 
-        doQWDTextAnnotations(annoIdxMap, tsc, qwds, theme, visible);
+        doQWDTextAnnotations(annoIdxMap, tsc, qwd, theme, visible);
     }
 
 
@@ -321,7 +311,7 @@
      * @param annoIdxMap map of index in qwds to series/data item indices in tsc.
      */
     protected void doQWDTextAnnotations(Map<Integer, int[]> annoIdxMap,
-            TimeSeriesCollection tsc, QWD[] qwds, Document theme,
+            TimeSeriesCollection tsc, QWD qwd, Document theme,
             boolean visible) {
         logger.debug("doQWDTextAnnotation()");
 
@@ -334,7 +324,6 @@
         Set<Map.Entry<Integer, int[]>> entries = annoIdxMap.entrySet();
 
         for(Map.Entry<Integer, int[]> entry : entries) {
-            QWD qwd = qwds[entry.getKey()];
             int[] idxs = entry.getValue();
             double x = tsc.getXValue(idxs[0], idxs[1]);
             XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
@@ -359,8 +348,8 @@
     ) {
         logger.debug("doReferenceEventsOut: desc = " + desc);
 
-        QWD[] qwds = (QWD[]) data;
-        doQWDEventsOut(qwds, desc, theme, visible);
+        QWD qwd = (QWD) data;
+        doQWDEventsOut(qwd, desc, theme, visible);
     }
 
 

http://dive4elements.wald.intevation.org