[HepData-svn] r1561 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Jul 18 13:39:16 BST 2012


Author: whalley
Date: Wed Jul 18 13:39:16 2012
New Revision: 1561

Log:
handle better the plain text for cases with blank entries in first y axis

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java	Wed Jul 18 10:41:52 2012	(r1560)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java	Wed Jul 18 13:39:16 2012	(r1561)
@@ -219,7 +219,7 @@
                 String template = "";
                 Bin b = x.getBin(r);
                 Point p = y.getPoint(r);
-                if (b != null && p != null) {
+                if (b != null || p != null) {
                     Double xlow = b.getLowValue();
                     Double xhigh = b.getHighValue();
                     Double xfocus = b.getFocus();
@@ -228,7 +228,7 @@
                         template=template.concat("\t$val" + Integer.toString(ix) + "$");
                         template=template.concat("\t$val" + Integer.toString(ix) + "low$");
                         template=template.concat("\t$val" + Integer.toString(ix) + "high$");
-                   } 
+                    } 
 //                    template=template.concat("\t$yval$");
                     row.setTemplate(template);
                     row.setAttribute("xfocus", xfocus);
@@ -242,59 +242,29 @@
                       }
                     } 
                     s.append(row.toString());
-                    for (int ny=1; ny<=p.getYAxis().getDataset().getYAxes().size(); ny++ ) {
-                    try {
-                        Double yval = p.getYAxis().getDataset().getYAxis(ny).getPoint(r).getValue();
-                  //  Double yval = p.getValue();
-                        s.append("\t" + yval); 
-//                    row.setAttribute("yval", yval);
-                        for (Uncertainty e : p.getYAxis().getDataset().getYAxis(ny).getPoint(r).getErrors()) {
+                    for (int ny=1; ny<=d.getYAxes().size(); ny++ ) {
                         try {
-//                            Uncertainty ae = e.getAbsoluteError(p);
-                            Uncertainty ae = e.getAbsoluteError(p.getYAxis().getDataset().getYAxis(ny).getPoint(r));
-                            if(ae.isSymmetricReversed()){
-                                s.append("\t"  + ae.getPlus());
-                                s.append("\t+" + ae.getMinus());
-                            }
-                            else {
-                                Pattern patt9 = Pattern.compile("\\A" + "(^[\\d]+\\.[\\d]*[012345678])[9]+[012345678]*$"  + "\\Z",Pattern.CASE_INSENSITIVE);
-                                Pattern patt0 = Pattern.compile("\\A" + "(^[\\d]+\\.[\\d]*[123456789])[0]+[123456789]*$"  + "\\Z",Pattern.CASE_INSENSITIVE);
-
-//                                String tt = ae.getPlus().toString();
-// 
-//                                Matcher m9 = patt9.matcher(tt);
-//                                Matcher m0 = patt0.matcher(tt);
-// 
-//                                if(m9.matches()){
-//                                    s.append("\t+" + m9.group(1));
-//                                } else if(m0.matches()){
-//                                    s.append("\t+" + m0.group(1));
-//                                } else {
-//                                    s.append("\t+" + tt);
-//                                }
-//
-//                                tt = ae.getMinus().toString();
-//                                m9 = patt9.matcher(tt);
-//                                m0 = patt0.matcher(tt);
-//
-//                                if(m9.matches()){
-//                                    s.append("\t-" + m9.group(1));
-//                                } else if(m0.matches()){
-//                                    s.append("\t-" + m0.group(1));
-//                                } else {
-//                                    s.append("\t-" + tt);
-//                                }
-                                s.append("\t+" + ae.getPlus());
-                                s.append("\t-" + ae.getMinus());
+                            Double yval = d.getYAxis(ny).getPoint(r).getValue();
+                            s.append("\t" + yval); 
+                            for (Uncertainty e : d.getYAxis(ny).getPoint(r).getErrors()) {
+                                try {
+                                    Uncertainty ae = e.getAbsoluteError(d.getYAxis(ny).getPoint(r));
+                                    if(ae.isSymmetricReversed()){
+                                        s.append("\t"  + ae.getPlus());
+                                        s.append("\t+" + ae.getMinus());
+                                    }
+                                    else {
+                                        s.append("\t+" + ae.getPlus());
+                                        s.append("\t-" + ae.getMinus());
+                                    }
+                                } catch (HDException hde) {
+                                    s.append("\t+?\t?");
+                                }
                             }
-                        } catch (HDException hde) {
-                            s.append("\t+?\t?");
-                        }
+                        } catch (Exception  ex) { s.append("\t-"); }
                     }
-                    } catch (Exception  ex) { s.append("\t-"); }
+                    s.append("\n");
                   }
-                  s.append("\n");
-                }
             }
             out = s.toString();
         }


More information about the HepData-svn mailing list