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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Jan 18 10:14:28 GMT 2010


Author: whalley
Date: Mon Jan 18 10:14:27 2010
New Revision: 1342

Log:
correcting bug

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	Fri Jan 15 12:39:33 2010	(r1341)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java	Mon Jan 18 10:14:27 2010	(r1342)
@@ -53,7 +53,6 @@
             ncomm = _dataset.getYAxes().first().getComments().size();
             nprop = _dataset.getYAxes().first().getProperties().size();
         }
-
         // Begin the actual data table...
         writer.element("table");
         writer.attributes("class", "dataset");
@@ -109,53 +108,45 @@
 
         String[][] store = new String[ny][nprop];
         
-        for (int i=0; i<nprop; i++) {
-           int numy = -1;
-           for(YAxis y : _dataset.getYAxes()) {
-               numy++;
-               int j=-1;
-                for (Property property : y.getProperties()) {
-                    j++;
-                    if(j == i){
-                        String tempstr = property.getName().toString();
-                        tempstr = tempstr.concat(" : ");
-                        if (property.getFocus() != null){
-                            tempstr = tempstr.concat(property.getFocus().toString());
-                        }
-                        if (property.getLowValue() != null && property.getHighValue() != null &&
-                            property.getLowValue().equals(property.getHighValue())) {
-                            tempstr = tempstr.concat(property.getLowValue().toString());
-                        } else {
-                            if(property.getFocus() != null) { tempstr = tempstr.concat(" ("); }
-                            tempstr = tempstr.concat(property.getLowValue().toString());
-                            tempstr = tempstr.concat("-");
-                            tempstr = tempstr.concat(property.getHighValue().toString());
-                            if(property.getFocus() != null) { tempstr = tempstr.concat(")"); }
-                        }
-                        if (!property.getUnit().isDimensionless()) {
-                            tempstr = tempstr.concat(" ");
-                            tempstr = tempstr.concat(property.getUnit().toString());
-                        }
-                        store[numy][i] = tempstr; 
-                    }
-                        
-                }
-           }
-        } 
-
-        for(int numy=0; numy<ny; numy++){
+        int numy = -1;
+        for(YAxis y : _dataset.getYAxes()) {
+            numy++;
+            int j=-1;
             List <String> storelist = new ArrayList();
-            for (int i=0; i<nprop; i++){
-                storelist.add(store[numy][i]);
+            for (Property property : y.getProperties()) {
+                j++;
+                String tempstr = property.getName().toString();
+                if(!tempstr.startsWith("sqrts")){
+                    tempstr = tempstr.concat(" : ");
+                    if (property.getFocus() != null){
+                         tempstr = tempstr.concat(property.getFocus().toString());
+                    }
+                    if (property.getLowValue() != null && property.getHighValue() != null &&
+                         property.getLowValue().equals(property.getHighValue())) {
+                        tempstr = tempstr.concat(property.getLowValue().toString());
+                    } else {
+                        if(property.getFocus() != null) { tempstr = tempstr.concat(" ("); }
+                        tempstr = tempstr.concat(property.getLowValue().toString());
+                        tempstr = tempstr.concat("-");
+                        tempstr = tempstr.concat(property.getHighValue().toString());
+                        if(property.getFocus() != null) { tempstr = tempstr.concat(")"); }
+                    }
+                    if (!property.getUnit().isDimensionless()) {
+                        tempstr = tempstr.concat(" ");
+                        tempstr = tempstr.concat(property.getUnit().toString());
+                    }
+                    storelist.add(tempstr);
+                }        
+            
             }
             Collections.sort(storelist);
-            for (int i=0; i<nprop; i++){
+            for (int i=0; i<storelist.size(); i++){
                 store[numy][i] = storelist.get(i);
             }
         }
 
         for (int i=0; i<nprop; i++){
-            if (!store[0][i].startsWith("sqrts")) {
+            if(store[0][i] != null){
                 writer.element("tr");
                 writer.element("td");
                 writer.attributes("colspan", nx);
@@ -165,11 +156,7 @@
 // this is the actual output
 // first check is same across row
                 Boolean same = true;
-                for (int numy=0; numy<ny-1; numy++){
-                    if(!store[numy][i].equals(store[numy+1][i])){
-                        same = false;
-                    }
-                }
+                for (int nmy=0; nmy<ny-1; nmy++){ if(!store[nmy][i].equals(store[nmy+1][i])){ same = false; } }
                 if(same) {
                     writer.element("th");
                     writer.attributes("colspan",ny);
@@ -177,12 +164,11 @@
                     writer.write(store[0][i]);
                     writer.end();
                 } else {
-                    for (int numy=0; numy<ny; numy++){
+                    for (int nmy=0; nmy<ny; nmy++){
                         writer.element("th");
                         writer.attributes("class","multiple");
-                        writer.write( store[numy][i]);
+                        writer.write( store[nmy][i]);
                         writer.end();
-                        System.out.println(store[numy][i]);
                     }
                 }
                 writer.end();  //tr    


More information about the HepData-svn mailing list