changeset 2397:c38063bf99da

Small improvements in model classes for Bounds. flys-artifacts/trunk@4023 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 10 Feb 2012 10:20:02 +0000
parents 2c62bbe2e415
children 5d8d24984819
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java
diffstat 3 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 10 10:12:12 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 10 10:20:02 2012 +0000
@@ -1,3 +1,12 @@
+2012-02-10  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/jfree/TimeBounds.java: Added new
+	  methods getLowerAsDate() and getUpperAsDate(). The toString() method
+	  will now return a string that contains a human readable date string.
+
+	* src/main/java/de/intevation/flys/jfree/DoubleBounds.java: Made 'lower'
+	  always be smaller than 'upper' in the default constructor.
+
 2012-02-11	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java	Fri Feb 10 10:12:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java	Fri Feb 10 10:20:02 2012 +0000
@@ -14,9 +14,13 @@
     protected double upper;
 
 
+    /**
+     * Default constructor. <b>A DoubleBounds has always set lower &lt;
+     * upper!</b>
+     */
     public DoubleBounds(double lower, double upper) {
-        this.lower = lower;
-        this.upper = upper;
+        this.lower = Math.min(lower, upper);
+        this.upper = Math.max(lower, upper);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java	Fri Feb 10 10:12:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java	Fri Feb 10 10:20:02 2012 +0000
@@ -2,7 +2,6 @@
 
 import java.util.Date;
 
-
 import org.jfree.chart.axis.DateAxis;
 import org.jfree.chart.axis.ValueAxis;
 
@@ -28,12 +27,22 @@
     }
 
 
+    public Date getLowerAsDate() {
+        return new Date(lower);
+    }
+
+
     @Override
     public Number getUpper() {
         return Long.valueOf(upper);
     }
 
 
+    public Date getUpperAsDate() {
+        return new Date(upper);
+    }
+
+
     @Override
     public void applyBounds(ValueAxis axis) {
         DateAxis dateAxis = (DateAxis) axis;
@@ -62,7 +71,7 @@
 
     @Override
     public String toString() {
-        return "TimeBounds=[" + lower + " ; " + upper + "]";
+        return "TimeBounds=["+ getLowerAsDate() + " ; " + getUpperAsDate() +"]";
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org