changeset 2399:73b15736cb80

Improved the interface and implementations of Bounds. flys-artifacts/trunk@4025 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 10 Feb 2012 10:43:29 +0000
parents 5d8d24984819
children f55984858952
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/jfree/Bounds.java flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java
diffstat 4 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 10 10:24:33 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 10 10:43:29 2012 +0000
@@ -1,3 +1,11 @@
+2012-02-10  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/jfree/Bounds.java,
+	  src/main/java/de/intevation/flys/jfree/TimeBounds.java,
+	  src/main/java/de/intevation/flys/jfree/DoubleBounds.java: Added a method
+	  applyBounds(ValueAxis, int) that might be used to adapt the range of the
+	  axis to the bounds adding a space to the left and right.
+
 2012-02-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/ChartGenerator.java: Defined
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/Bounds.java	Fri Feb 10 10:24:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/Bounds.java	Fri Feb 10 10:43:29 2012 +0000
@@ -16,6 +16,8 @@
 
     void applyBounds(ValueAxis axis);
 
+    void applyBounds(ValueAxis axis, int percent);
+
     Bounds combine(Bounds bounds);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java	Fri Feb 10 10:24:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java	Fri Feb 10 10:43:29 2012 +0000
@@ -43,6 +43,13 @@
 
 
     @Override
+    public void applyBounds(ValueAxis axis, int percent) {
+        double space = (upper - lower) / 100 * percent;
+        axis.setRange(new Range(lower-space, upper+space));
+    }
+
+
+    @Override
     public Bounds combine(Bounds bounds) {
         if (bounds == null) {
             return this;
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java	Fri Feb 10 10:24:33 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java	Fri Feb 10 10:43:29 2012 +0000
@@ -53,6 +53,17 @@
 
 
     @Override
+    public void applyBounds(ValueAxis axis, int percent) {
+        DateAxis dateAxis = (DateAxis) axis;
+
+        long space = (upper - lower) / 100 * percent;
+
+        dateAxis.setMinimumDate(new Date(lower-space));
+        dateAxis.setMaximumDate(new Date(upper+space));
+    }
+
+
+    @Override
     public Bounds combine(Bounds bounds) {
         if (bounds == null) {
             return this;

http://dive4elements.wald.intevation.org