[PATCH 1 of 3] Minor refactoring, extracted method

Wald Commits scm-commit at wald.intevation.org
Wed Jul 10 09:56:21 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1373359833 -7200
# Node ID e7eb3c4afcf33ccbe97ce0d6487eebe7d5561bb6
# Parent  9987c5a8154a3a80e0804ed61030ca972c4f3ea2
Minor refactoring, extracted method.

diff -r 9987c5a8154a -r e7eb3c4afcf3 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java
--- 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);


More information about the Dive4elements-commits mailing list