[HepData-svn] r1424 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Dec 9 16:54:22 GMT 2010


Author: whalley
Date: Thu Dec  9 16:54:22 2010
New Revision: 1424

Log:
better handling of x bin widths - especially when thee is no width

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java	Mon Nov 22 14:40:12 2010	(r1423)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java	Thu Dec  9 16:54:22 2010	(r1424)
@@ -209,6 +209,7 @@
                     // at least one bin has a focus which significantly differs from the mean
                     // ..force it to be true so that we always output the mean
                     boolean asymmfocus = true;
+                    boolean haswidth = false;
                     for (Bin b : x.getBins()) {
                         if (b.getLowValue() != null && b.getHighValue() != null && b.getFocus() != null) {
                             double diff = b.getFocus() - (b.getLowValue() + b.getHighValue()) / 2.0;
@@ -216,6 +217,13 @@
                                 asymmfocus = true;
                             }
                         }
+                        if (b.getLowValue() != null && b.getHighValue() != null){
+                            double diff = b.getHighValue() - b.getLowValue();
+                            double mean = (b.getHighValue() + b.getLowValue())/2.0;
+                            if(diff/mean > 1E-6){
+                                haswidth = true;
+                            }
+                        }
                         if (b.getLowValue() != null && b.getLowValue().toString().length() > lwidth) {
                             lwidth = b.getLowValue().toString().length();
                         }
@@ -226,7 +234,6 @@
                             fwidth = b.getFocus().toString().length();
                         }
                     }
-
                     Double f = null;
                     Double high = null;
                     Double low = null;
@@ -294,7 +301,7 @@
 
 
                                     Double width = high - low;
-                                    if (f != null && asymmfocus) {
+                                    if (f != null && asymmfocus && haswidth) {
                                         writer.writeRaw(f_val);
                                         writer.writeRaw(" (bin: ");
                                         writer.writeRaw(f_low + "–" + f_high);


More information about the HepData-svn mailing list