changeset 3141:3582e87e9171

FixA: Made GaugeRange a top level class. flys-artifacts/trunk@4749 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 21 Jun 2012 15:39:34 +0000
parents 3d456d8bca6e
children 9aed2e4de3ca
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java
diffstat 3 files changed, 99 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jun 21 15:27:57 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jun 21 15:39:34 2012 +0000
@@ -1,3 +1,11 @@
+2012-06-21	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java:
+	  New. Moved out of FixingsOverview.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java:
+	  Moved GaugeRange into top level class.
+	  
 2012-06-21	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java	Thu Jun 21 15:27:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java	Thu Jun 21 15:39:34 2012 +0000
@@ -8,9 +8,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.log4j.Logger;
 
@@ -27,8 +25,7 @@
 {
     private static Logger log = Logger.getLogger(FixingsOverview.class);
 
-    public static final double EPSILON  = 1e-5;
-    public static final double EPSILON2 = 1e-1;
+    public static final double EPSILON = 1e-1;
 
     public static final String DATE_FORMAT = "dd.MM.yyyy";
 
@@ -114,81 +111,6 @@
         "WHERE" +
         "    wst_column_id = :column_id";
 
-    public static class GaugeRange extends Range {
-
-        private static final class Sector implements Serializable {
-
-            int    sector;
-            double value;
-
-            Sector(int sector, double value) {
-                this.sector = sector;
-                this.value  = value;
-            }
-
-        } // class Sector
-
-        protected int gaugeId;
-
-        protected Map<String, Double> mainValues;
-        protected List<Sector> sectors;
-
-        public GaugeRange() {
-        }
-
-        public GaugeRange(double start, double end, int gaugeId) {
-            super(start, end);
-            this.gaugeId = gaugeId;
-            mainValues = new HashMap<String, Double>();
-            sectors = new ArrayList<Sector>(3);
-        }
-
-        public void addMainValue(String label, Double value) {
-            int idx = label.indexOf('(');
-            if (idx >= 0) {
-                label = label.substring(0, idx);
-            }
-            mainValues.put(label, value);
-        }
-
-        protected Double getMainValue(String label) {
-            Double v = mainValues.get(label);
-            if (v == null) {
-                log.warn("Missing main value '"
-                    + label + "' for gauge " + gaugeId);
-            }
-            return v;
-        }
-
-        public void buildClasses() {
-            Double mnq = getMainValue("MNQ");
-            Double mq  = getMainValue("MQ");
-            Double mhq = getMainValue("MHQ");
-            Double hq5 = getMainValue("HQ5");
-
-            Double [][] pairs = {
-                { mnq,  mq },
-                {  mq, mhq },
-                { hq5, hq5 } };
-
-            for (int c = 0; c < pairs.length; ++c) {
-                Double [] pair = pairs[c];
-                if (pair[0] != null && pair[1] != null) {
-                    double value = 0.5*(pair[0] + pair[1]);
-                    sectors.add(new Sector(c, value));
-                }
-            }
-        }
-
-        public int classify(double value) {
-            for (Sector sector: sectors) {
-                if (value < sector.value) {
-                    return sector.sector;
-                }
-            }
-            return sectors.size();
-        }
-    } // class GaugeRange
 
     public static class GaugeFinder {
 
@@ -312,7 +234,7 @@
 
         public boolean enlarge(SectorRange other) {
             if (sector == other.sector
-            && Math.abs(end-other.start) < EPSILON2) {
+            && Math.abs(end-other.start) < EPSILON) {
                 end = other.end;
                 return true;
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java	Thu Jun 21 15:39:34 2012 +0000
@@ -0,0 +1,89 @@
+package de.intevation.flys.artifacts.model;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+public class GaugeRange
+extends      Range
+{
+    private static Logger log = Logger.getLogger(GaugeRange.class);
+
+    private static final class Sector implements Serializable {
+
+        int    sector;
+        double value;
+
+        Sector(int sector, double value) {
+            this.sector = sector;
+            this.value  = value;
+        }
+    } // class Sector
+
+    protected int gaugeId;
+
+    protected Map<String, Double> mainValues;
+    protected List<Sector> sectors;
+
+    public GaugeRange() {
+    }
+
+    public GaugeRange(double start, double end, int gaugeId) {
+        super(start, end);
+        this.gaugeId = gaugeId;
+        mainValues = new HashMap<String, Double>();
+        sectors = new ArrayList<Sector>(3);
+    }
+
+    public void addMainValue(String label, Double value) {
+        int idx = label.indexOf('(');
+        if (idx >= 0) {
+            label = label.substring(0, idx);
+        }
+        mainValues.put(label, value);
+    }
+
+    protected Double getMainValue(String label) {
+        Double v = mainValues.get(label);
+        if (v == null) {
+            log.warn("Missing main value '"
+                + label + "' for gauge " + gaugeId);
+        }
+        return v;
+    }
+
+    public void buildClasses() {
+        Double mnq = getMainValue("MNQ");
+        Double mq  = getMainValue("MQ");
+        Double mhq = getMainValue("MHQ");
+        Double hq5 = getMainValue("HQ5");
+
+        Double [][] pairs = {
+            { mnq,  mq },
+            {  mq, mhq },
+            { hq5, hq5 } };
+
+        for (int c = 0; c < pairs.length; ++c) {
+            Double [] pair = pairs[c];
+            if (pair[0] != null && pair[1] != null) {
+                double value = 0.5*(pair[0] + pair[1]);
+                sectors.add(new Sector(c, value));
+            }
+        }
+    }
+
+    public int classify(double value) {
+        for (Sector sector: sectors) {
+            if (value < sector.value) {
+                return sector.sector;
+            }
+        }
+        return sectors.size();
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org