changeset 6549:e7eb3c4afcf3

Minor refactoring, extracted method.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 09 Jul 2013 10:50:33 +0200
parents 9987c5a8154a
children 7cf3b3bcd439
files artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java
diffstat 1 files changed, 33 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java	Tue Jul 09 10:28:52 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java	Tue Jul 09 10:50:33 2013 +0200
@@ -91,35 +91,9 @@
         }
 
         if (bundle.getData(context) instanceof BedDifferencesResult) {
-            if (getXBounds(0) != null && getDomainAxisRange() != null) {
-                Bounds bounds =
-                    calculateZoom(getXBounds(0), getDomainAxisRange());
-                context.putContextValue("startkm", bounds.getLower());
-                context.putContextValue("endkm", bounds.getUpper());
-            }
-            else if (getXBounds(0) != null && getDomainAxisRange() == null) {
-                context.putContextValue("startkm", getXBounds(0).getLower());
-                context.putContextValue("endkm", getXBounds(0).getUpper());
-            }
-            else if (getXBounds(0) == null && getDomainAxisRange() == null) {
-                BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-                if (data.getKms().size() >= 0) {
-                    context.putContextValue("startkm", data.getKms().min());
-                    context.putContextValue("endkm", data.getKms().max());
-                }
-                else {
-                    logger.warn("No data to define start and end km");
-                }
-            }
-            else if (getXBounds(0) == null && getDomainAxisRange() != null){
-                BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-                Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
-                Bounds bounds =
-                    calculateZoom(b, getDomainAxisRange());
-                context.putContextValue("startkm", bounds.getLower());
-                context.putContextValue("endkm", bounds.getUpper());
-            }
+            setContextBounds(bundle);
         }
+
         Processor processor = new KMIndexProcessor();
         if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR)) {
             doBedDifferenceYearOut(
@@ -146,6 +120,37 @@
         }
     }
 
+    public void setContextBounds(ArtifactAndFacet bundle) {
+        if (getXBounds(0) != null && getDomainAxisRange() != null) {
+            Bounds bounds =
+                calculateZoom(getXBounds(0), getDomainAxisRange());
+            context.putContextValue("startkm", bounds.getLower());
+            context.putContextValue("endkm", bounds.getUpper());
+        }
+        else if (getXBounds(0) != null && getDomainAxisRange() == null) {
+            context.putContextValue("startkm", getXBounds(0).getLower());
+            context.putContextValue("endkm", getXBounds(0).getUpper());
+        }
+        else if (getXBounds(0) == null && getDomainAxisRange() == null) {
+            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
+            if (data.getKms().size() >= 0) {
+                context.putContextValue("startkm", data.getKms().min());
+                context.putContextValue("endkm", data.getKms().max());
+            }
+            else {
+                logger.warn("No data to define start and end km");
+            }
+        }
+        else if (getXBounds(0) == null && getDomainAxisRange() != null){
+            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
+            Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
+            Bounds bounds =
+                calculateZoom(b, getDomainAxisRange());
+            context.putContextValue("startkm", bounds.getLower());
+            context.putContextValue("endkm", bounds.getUpper());
+        }
+    }
+
     @Override
     protected String getDefaultChartTitle() {
         return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);

http://dive4elements.wald.intevation.org