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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Sep 28 21:13:24 BST 2015


Author: watt
Date: Mon Sep 28 21:13:24 2015
New Revision: 1894

Log:
More attempted fixes to formatters

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

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java	Mon Sep 28 20:00:29 2015	(r1893)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java	Mon Sep 28 21:13:24 2015	(r1894)
@@ -252,15 +252,18 @@
 				s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getLowValue() + " TO " + ds.getXAxis(nx+1).getBin(i+1).getHighValue());
 			    }
                         } else {
-                            if(ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue()==null){
+                            if (ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue() == null) {
                                 s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getLowValue());                   
                             }
-                            else if(ds.getXAxis(nx+1).getBin(i+1).getLowValue() == null && ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null){
+                            else if (ds.getXAxis(nx+1).getBin(i+1).getLowValue() == null && ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null) {
                                 s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getHighValue());                   
                             }
-                            else{
+                            else if (ds.getXAxis(nx+1).getBin(i+1).getDescription() != null) {
                                 s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getDescription());
                             }
+			    else {
+				s.append(" -");
+			    }
 			}
                     } catch(Exception e){
 			if (ds.getXAxis(nx+1).getBin(i+1).getDescription() != null) {

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java	Mon Sep 28 20:00:29 2015	(r1893)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java	Mon Sep 28 21:13:24 2015	(r1894)
@@ -359,7 +359,18 @@
                     if((Math.abs(diff/mean) > 1E-6) || (mean == 0.0 && Math.abs(diff) > 1E-6)){ haswidth = true;}
                 }
 
-                if(bin.getFocus() != null) {
+                if(bin.getRelation() != null && bin.getRelation() != Relation.EQUALS ) { 
+                    if(!first) { s.append(", "); } 
+                    s.append("value: '"+bin.getRelation()+" ");
+		    if (bin.getLowValue() != null) {
+			s.append(bin.getLowValue());
+		    } else if (bin.getHighValue() != null) {
+			s.append(bin.getHighValue());
+		    }
+		    s.append("'");
+                    first=false; 
+                }
+                else if(bin.getFocus() != null) {
                     if(asymmfocus || !haswidth) { 
                         if(!first) {s.append(", "); } 
                         if(bin.getFocusLength()!=null) { 
@@ -370,7 +381,7 @@
 			first=false; 
                     }
 		}
-		if(bin.getLowValue() != null) {
+		if(bin.getLowValue() != null && haswidth) {
                     if(!first) { s.append(", "); } 
 		    if(bin.getLowValueLength()!=null) { 
                         s.append("low: "+forms(bin.getLowValue(),bin.getLowValueLength())); 
@@ -379,7 +390,7 @@
                     }
                     first=false; 
                 }
-		if(bin.getHighValue() != null) {
+		if(bin.getHighValue() != null && haswidth) {
                     if(!first) {s.append(", "); } 
                     if(bin.getHighValueLength()!=null) { 
                         s.append("high: "+forms(bin.getHighValue(),bin.getHighValueLength())); 
@@ -388,17 +399,12 @@
                     }
                     first=false; 
                 }
-                if(bin.getRelation() != null && bin.getRelation() != Relation.EQUALS ) { 
-                    if(!first) { s.append(", "); } 
-                    s.append("relation: '"+bin.getRelation()+"'");
-                    first=false; 
-                }
                 if(bin.getDescription() != null ) {  
                     if(!first) { s.append(", "); } 
                     s.append("value: '"+bin.getDescription()+"'");  
                     first=false;
                 }
-		if (bin.getDescription() == null && bin.getFocus() == null) {
+		if (bin.getDescription() == null && bin.getFocus() == null && bin.getLowValue() == null && bin.getHighValue() == null) {
 		    s.append("value: '-'");
 		}
                 if(bin.getId() < xax.getBins().size()) {

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 Sep 28 20:00:29 2015	(r1893)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DatasetAsHtml.java	Mon Sep 28 21:13:24 2015	(r1894)
@@ -438,7 +438,12 @@
                     Double f = null;
                     Double high = null;
                     Double low = null;
-                    Bin b = x.getBin(ip);
+		    Bin b;
+		    try{
+			b = x.getBin(ip);
+		    } catch (Exception e) {
+			b = null;
+		    }
                     writer.element("td");
                     if(ip == npoints) {  writer.attributes("class", "xval_last"); }
                     else {  writer.attributes("class", "xval"); }
@@ -538,7 +543,9 @@
                         } else {
                             writer.write(b.getDescription());
                         }
-                    }
+                    } else {
+			writer.writeRaw("–");
+		    }
                     writer.end(); //td
                 }
 


More information about the HepData-svn mailing list