changeset 1689:e9475d2ef343

Bugfix: #189 Changed the order of a duration curve CSV export. flys-artifacts/trunk@2911 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 10 Oct 2011 07:07:17 +0000
parents 7eb9015489b0
children 0053a4529f2f
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQDay.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java
diffstat 3 files changed, 38 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Oct 07 15:55:38 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Oct 10 07:07:17 2011 +0000
@@ -1,3 +1,15 @@
+2011-10-10  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue189 (WINFO/Dauerlinie: Sortierung der Berechnungsausgabe nach Dauerzahlen aufsteigend)
+
+	* src/main/java/de/intevation/flys/artifacts/model/WQDay.java: Added a
+	  method that determines if the items (days) in this object are increasing
+	  or not.
+
+	* src/main/java/de/intevation/flys/exports/DurationCurveExporter.java:
+	  Changed the order of the CSV export - the highest day is at the top of
+	  the export; the lowest day is at the bottom.
+
 2011-10-07	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	Worked on flys/issue150 (Diagramm: Anzeige von W bergauf).
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQDay.java	Fri Oct 07 15:55:38 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQDay.java	Mon Oct 10 07:07:17 2011 +0000
@@ -33,6 +33,15 @@
         days.add(day);
     }
 
+
+    public boolean isIncreasing() {
+        int lo = getDay(0);
+        int hi = getDay(size()-1);
+
+        return lo < hi;
+    }
+
+
     public int getDay(int idx) {
         return days.getQuick(idx);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java	Fri Oct 07 15:55:38 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java	Mon Oct 10 07:07:17 2011 +0000
@@ -97,12 +97,23 @@
         NumberFormat qf  = getQFormatter();
         NumberFormat df  = getDFormatter();
 
-        for (int i = 0; i < size; i ++) {
-            writer.writeNext(new String[] {
-                wf.format(wqday.getW(i)),
-                qf.format(wqday.getQ(i)),
-                df.format(wqday.getDay(i))
-            });
+        if (wqday.isIncreasing()) {
+            for (int i = size-1; i >= 0; i --) {
+                writer.writeNext(new String[] {
+                    wf.format(wqday.getW(i)),
+                    qf.format(wqday.getQ(i)),
+                    df.format(wqday.getDay(i))
+                });
+            }
+        }
+        else {
+            for (int i = 0; i < size; i ++) {
+                writer.writeNext(new String[] {
+                    wf.format(wqday.getW(i)),
+                    qf.format(wqday.getQ(i)),
+                    df.format(wqday.getDay(i))
+                });
+            }
         }
     }
 

http://dive4elements.wald.intevation.org