[HepData-svn] r1341 - in trunk/hepdata-webapp/src/main: java/cedar/hepdata/formats java/cedar/hepdata/webapp/components resources/cedar/hepdata/webapp/pages

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Jan 15 12:39:33 GMT 2010


Author: whalley
Date: Fri Jan 15 12:39:33 2010
New Revision: 1341

Log:
tidying up property output in tables - amongst other things

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/ViewTest.tml

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java	Wed Jan 13 15:16:43 2010	(r1340)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java	Fri Jan 15 12:39:33 2010	(r1341)
@@ -63,8 +63,11 @@
 	            if(ds.getDsPlabString(n) != null){ s.append(ds.getDsPlabString(n) + "\n"); }
 	            else{ break; }	
             }
+            s.append("\n" + ds.getXAxes().size() + "\n");
+            s.append("\n" + ds.getYAxes().size() + "\n");
     	} 
 
+        
         return s.toString();
     }
 

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 Jan 13 15:16:43 2010	(r1340)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java	Fri Jan 15 12:39:33 2010	(r1341)
@@ -13,6 +13,7 @@
 import com.Ostermiller.util.SignificantFigures;
 
 import java.text.*;
+import java.util.*;
 
 
 
@@ -104,50 +105,89 @@
             writer.end(); //tr
         }
 
+        // Next the numerical properties new version
 
-        // Next the numerical properties
-        for (int i = 1; i < nprop + 1; ++i) {
-            writer.element("tr");
-            writer.attributes("class", "axisproperties");
-
-            writer.element("td");
-            writer.attributes("colspan", nx);
-            writer.writeRaw("&nbsp;");
-            writer.end();
-
-            for (YAxis y : _dataset.getYAxes()) {
-                int j = 0;
+        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()) {
-                    if ( ! property.getName().equals("sqrts")) {
-                        j++;
-                        if (j == i) {
-                            writer.element("th");
-                            writer.write(property.getName() + " : ");
-                            if (property.getFocus() != null){
-                                writer.write(property.getFocus().toString());
-                            }
-                            if (property.getLowValue() != null && property.getHighValue() != null &&
-                                property.getLowValue().equals(property.getHighValue())) {
-                                writer.write(property.getLowValue().toString());
-                            } else {
-                                if(property.getFocus() != null) { writer.write(" ("); }
-                                writer.write(property.getLowValue().toString());
-                                writer.writeRaw("&ndash;");
-                                writer.write(property.getHighValue().toString());
-                                if(property.getFocus() != null) { writer.write(")"); }
-                            }
-                            if (!property.getUnit().isDimensionless()) {
-                                writer.writeRaw("&nbsp;");
-                                writer.write(property.getUnit().toString());
-                            }
-                            writer.end();
+                    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++){
+            List <String> storelist = new ArrayList();
+            for (int i=0; i<nprop; i++){
+                storelist.add(store[numy][i]);
+            }
+            Collections.sort(storelist);
+            for (int i=0; i<nprop; i++){
+                store[numy][i] = storelist.get(i);
             }
-            writer.end(); //tr
         }
 
+        for (int i=0; i<nprop; i++){
+            if (!store[0][i].startsWith("sqrts")) {
+                writer.element("tr");
+                writer.element("td");
+                writer.attributes("colspan", nx);
+                writer.writeRaw("&nbsp;");
+                writer.end();
+
+// 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;
+                    }
+                }
+                if(same) {
+                    writer.element("th");
+                    writer.attributes("colspan",ny);
+                    writer.attributes("class","multiple");
+                    writer.write(store[0][i]);
+                    writer.end();
+                } else {
+                    for (int numy=0; numy<ny; numy++){
+                        writer.element("th");
+                        writer.attributes("class","multiple");
+                        writer.write( store[numy][i]);
+                        writer.end();
+                        System.out.println(store[numy][i]);
+                    }
+                }
+                writer.end();  //tr    
+            }
+        }
 
         // Headers
         writer.element("tr");

Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/ViewTest.tml
==============================================================================
--- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/ViewTest.tml	Wed Jan 13 15:16:43 2010	(r1340)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/ViewTest.tml	Fri Jan 15 12:39:33 2010	(r1341)
@@ -87,10 +87,8 @@
           ${dataset.getDsReactions()} 
           <br/>
           ${dataset.getDsObservables()} 
- <!--
           <br/>
           ${dataset.getDsPlabs()} 
--->
           <br/>
           ${dataset.getYAxis(1).getReactions()} 
           <t:datasetAsHtml dataset="dataset" format="${format}" />


More information about the HepData-svn mailing list