diff gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java @ 171:7fb9441dd8af

Format Code to max 80 Chars per Row and Cleanup gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 09 Oct 2009 07:54:48 +0000
parents 158e89c2263b
children 07650fc6014c
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java	Fri Oct 09 07:49:47 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java	Fri Oct 09 07:54:48 2009 +0000
@@ -27,14 +27,12 @@
 import de.intevation.gnv.geobackend.base.Result;
 import de.intevation.gnv.statistics.exception.StatisticsException;
 
-
-
 /**
  * The class <code>TimeseriesStatistics</code> fulfills the following purposes:
  * <ol>
  * <li></li>
  * </ol>
- *
+ * 
  * @author blume
  * @author Tim Englich <tim.englich@intevation.de>
  * @version 1.0
@@ -52,73 +50,71 @@
 
     private Collection<Statistic> statistics = null;
 
-    public TimeseriesStatistics(){
+    public TimeseriesStatistics() {
         super();
     }
-    
+
     /**
      * @see de.intevation.gnv.statistics.Statistics#calculateStatistics(java.util.Collection)
      */
-    public Collection<Statistic> calculateStatistics(Collection<Result> resultSet) throws StatisticsException {
+    public Collection<Statistic> calculateStatistics(
+                                                     Collection<Result> resultSet)
+                                                                                  throws StatisticsException {
         DescriptiveStatistics lStatistics = null;
         SimpleRegression lRegression = null;
         statistics = new ArrayList<Statistic>();
         String break1, break2;
         int lSeries = 1;
-        try{
-            
+        try {
+
             Iterator<Result> resultIterator = resultSet.iterator();
-            if (resultIterator.hasNext()){
+            if (resultIterator.hasNext()) {
                 Result row = resultIterator.next();
                 break1 = row.getString("GROUP1");
                 break2 = row.getString("GROUP2");
-            lRegression = new SimpleRegression();
-            lStatistics = DescriptiveStatistics.newInstance();
-            while (resultIterator.hasNext()) {
-                
-                if (!break1.equals(row.getString("GROUP1"))
+                lRegression = new SimpleRegression();
+                lStatistics = DescriptiveStatistics.newInstance();
+                while (resultIterator.hasNext()) {
+
+                    if (!break1.equals(row.getString("GROUP1"))
                         || !break2.equals(row.getString("GROUP2"))) {
-                    addStatisticsValues(lStatistics, lRegression, lSeries);
-                    
-                    lStatistics.clear();
-                    lRegression.clear();
-                    
-                    lStatistics.addValue(row.getDouble("YORDINATE"));
-                    Double x = this.calculateXOrdinateValue(row);
-                    lRegression.addData(x ,row.getDouble("YORDINATE"));
-                    
-                    break1 = row.getString("GROUP1");
-                    break2 = row.getString("GROUP2");
-                    row = resultIterator.next();
-                    lSeries ++;     
+                        addStatisticsValues(lStatistics, lRegression, lSeries);
+
+                        lStatistics.clear();
+                        lRegression.clear();
+
+                        lStatistics.addValue(row.getDouble("YORDINATE"));
+                        Double x = this.calculateXOrdinateValue(row);
+                        lRegression.addData(x, row.getDouble("YORDINATE"));
+
+                        break1 = row.getString("GROUP1");
+                        break2 = row.getString("GROUP2");
+                        row = resultIterator.next();
+                        lSeries++;
+                    } else {
+
+                        lStatistics.addValue(row.getDouble("YORDINATE"));
+                        Double x = this.calculateXOrdinateValue(row);
+                        lRegression.addData(x, row.getDouble("YORDINATE"));
+                        row = resultIterator.next();
+                    }
+
                 }
-                else{
-                    
-                    lStatistics.addValue(row.getDouble("YORDINATE"));
-                    Double x = this.calculateXOrdinateValue(row);
-                    lRegression.addData(x,row.getDouble("YORDINATE"));
-                    row = resultIterator.next();
-                }
-                
+                addStatisticsValues(lStatistics, lRegression, lSeries);
+                lStatistics.clear();
+                lRegression.clear();
             }
-            addStatisticsValues(lStatistics, lRegression,lSeries);
-            lStatistics.clear();
-            lRegression.clear();
-            }
-        }
-        catch (Exception e){
+        } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
-        
+
         return statistics;
     }
-    
-    
-    protected double calculateXOrdinateValue(Result row) throws SQLException{
-        return new Double( (row.getDate("XORDINATE")).getTime()/1000/3600) ;
+
+    protected double calculateXOrdinateValue(Result row) throws SQLException {
+        return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600);
     }
-    
-    
+
     /**
      * @param lStatistics
      * @param lRegression
@@ -126,20 +122,43 @@
      * @param lSeries
      */
     private void addStatisticsValues(DescriptiveStatistics lStatistics,
-            SimpleRegression lRegression, int lSeries) {
-        statistics.add(new Statistic("gnviewer.statistics.series",(double)lSeries));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.arithmeticMean", lStatistics.getMean()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.kurtosis", lStatistics.getKurtosis()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.max", lStatistics.getMax()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.min", lStatistics.getMin()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.n", lStatistics.getN()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.90", lStatistics.getPercentile(90)));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.75", lStatistics.getPercentile(75)));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.50", lStatistics.getPercentile(50)));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.10", lStatistics.getPercentile(10)));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.deviation", lStatistics.getStandardDeviation()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.variance", lStatistics.getVariance()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.intercept", lRegression.getIntercept()));
-        statistics.add(new Statistic("gnviewer.statistics.descriptive.slope", lRegression.getSlope()));
-    } 
+                                     SimpleRegression lRegression, int lSeries) {
+        statistics.add(new Statistic("gnviewer.statistics.series",
+                lSeries));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.arithmeticMean", lStatistics
+                        .getMean()));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.kurtosis", lStatistics
+                        .getKurtosis()));
+        statistics.add(new Statistic("gnviewer.statistics.descriptive.max",
+                lStatistics.getMax()));
+        statistics.add(new Statistic("gnviewer.statistics.descriptive.min",
+                lStatistics.getMin()));
+        statistics.add(new Statistic("gnviewer.statistics.descriptive.n",
+                lStatistics.getN()));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.percentile.90", lStatistics
+                        .getPercentile(90)));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.percentile.75", lStatistics
+                        .getPercentile(75)));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.percentile.50", lStatistics
+                        .getPercentile(50)));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.percentile.10", lStatistics
+                        .getPercentile(10)));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.deviation", lStatistics
+                        .getStandardDeviation()));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.variance", lStatistics
+                        .getVariance()));
+        statistics.add(new Statistic(
+                "gnviewer.statistics.descriptive.intercept", lRegression
+                        .getIntercept()));
+        statistics.add(new Statistic("gnviewer.statistics.descriptive.slope",
+                lRegression.getSlope()));
+    }
 }

http://dive4elements.wald.intevation.org