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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Sep 15 15:09:31 BST 2010


Author: whalley
Date: Wed Sep 15 15:09:30 2010
New Revision: 1391

Log:
output as integer if all dataset values are integer

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	Wed Sep 15 11:47:32 2010	(r1390)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java	Wed Sep 15 15:09:30 2010	(r1391)
@@ -64,7 +64,6 @@
         // Next the numerical properties new version
 
         String[][] store = new String[ny][nprop+ncomm];
-        
         int numy = -1;
         for(YAxis y : _dataset.getYAxes()) {
             numy++;
@@ -105,7 +104,6 @@
                 } 
             }
         }
-
         for (int i=0; i<nprop+ncomm; i++){
             if(store[0][i] != null){
                 writer.element("tr");
@@ -184,6 +182,8 @@
         if (getFormat().equals("full") && _dataset.getNumPoints() != 0) {
 
             // Finally the numbers themselves
+            int sumzero = 0;
+            int allzero = 0;
             for (int ip = 1 ; ip <= npoints; ip++) {
                 writer.element("tr");
 
@@ -271,12 +271,13 @@
                     writer.attributes("class", "yval");
                     try {
                         /// DON'T MODIFY ANY OF THIS AT THE MOMENT: I'M MOVING THE FORMATTING TO AN EXTERNAL CLASS!
-
                         if (pt2.getRelation() != Relation.EQUALS) {
                             writer.write(pt2.getRelation().toString());
                         }
                         SignificantFigures val = new SignificantFigures(pt2.getValue());
                         int lsd = val.getLSD();
+                        allzero += 1;
+                        if (pt2.getValue().toString().endsWith(".0")) sumzero += 1; 
                         if (pt2.getValue().toString().endsWith("0") || pt2.getValue().toString().indexOf("0E") > 0) {
                             lsd += 1;
                         }
@@ -299,6 +300,7 @@
                         }
                         int msd = val.getMSD();
                         if (msd <= 0) msd = 1;
+                        if(allzero == sumzero) lsd = 0;
                         writer.write(Formats.forms(pt2.getValue(), msd, -lsd));
                         if (pt2.getRelation() == Relation.EQUALS) {
                             for (PointError e : pt2.getErrors()) {


More information about the HepData-svn mailing list