|
[HepData-svn] r1366 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formatsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Jun 23 13:49:27 BST 2010
Author: buckley Date: Wed Jun 23 13:49:33 2010 New Revision: 1366 Log: More formatter tweaks Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MatplotlibFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/RootFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java Tue Jun 22 19:35:55 2010 (r1365) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java Wed Jun 23 13:49:33 2010 (r1366) @@ -141,7 +141,7 @@ } } } catch (NullPointerException npe) { - s.append("<!-- Can't render this dataset, due to missing/incompatible information: please report this problem! -->\n"); + s.append("<!-- Can't render this plot, due to missing/incompatible information: please report this problem! -->\n"); s.append(" </dataPoint>\n"); s.append(" </dataPointSet>\n"); } Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MatplotlibFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MatplotlibFormatter.java Tue Jun 22 19:35:55 2010 (r1365) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MatplotlibFormatter.java Wed Jun 23 13:49:33 2010 (r1366) @@ -119,7 +119,7 @@ out = s.toString(); } } catch (NullPointerException npe) { - out = "# Can't render this dataset, due to missing/incompatible information: please report this problem!\n\n"; + out = "# Can't render this plot, due to missing/incompatible information: please report this problem!\n\n"; } return out; } Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java Tue Jun 22 19:35:55 2010 (r1365) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java Wed Jun 23 13:49:33 2010 (r1366) @@ -123,7 +123,7 @@ out = s.toString(); } } catch (NullPointerException npe) { - out = "# Can't render this dataset, due to missing/incompatible information: please report this problem!\n"; + out = "# Can't render this plot, due to missing/incompatible information: please report this problem!\n\n"; } return out; } Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/RootFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/RootFormatter.java Tue Jun 22 19:35:55 2010 (r1365) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/RootFormatter.java Wed Jun 23 13:49:33 2010 (r1366) @@ -45,9 +45,9 @@ public static String _header() { - String s = "#include \"TGraphAsymmErrors.h\"\n\n"; - s += "{\n\n"; + String s = "#include \"TGraphAsymmErrors.h\"\n"; s += " gROOT->SetStyle(\"Plain\");\n\n"; + s += "{\n\n"; return s; } @@ -58,20 +58,35 @@ public static String _formatDataset(Dataset d) { - String out = null; + String out = ""; try { if (d != null) { StringBuffer s = new StringBuffer(); for (XAxis x : d.getXAxes()) { for (YAxis y : d.getYAxes()) { + // Make name and path + StringTemplate name = new StringTemplate("d$did$x$xid$y$yid$"); + name.setAttribute("did", d.getId()); + name.setAttribute("xid", x.getId()); + name.setAttribute("yid", y.getId()); + StringTemplate fullname = new StringTemplate("p$paperid$_$name$"); + fullname.setAttribute("paperid", d.getPaper().getId()); + fullname.setAttribute("name", name.toString()); + StringTemplate path = new StringTemplate("/HepData/$paperid$/$name$"); + path.setAttribute("paperid", d.getPaper().getId()); + path.setAttribute("name", name.toString()); + String varname = fullname.toString(); + + out = " // Plot: " + varname + "\n"; + // Build Python point array strings - StringBuffer xv = new StringBuffer(" double xval[] = { "); - StringBuffer xem = new StringBuffer(" double xerrminus[] = { "); - StringBuffer xep = new StringBuffer(" double xerrplus[] = { "); - StringBuffer yv = new StringBuffer(" double yval[] = { "); - StringBuffer yem = new StringBuffer(" double yerrminus[] = { "); - StringBuffer yep = new StringBuffer(" double yerrplus[] = { "); + StringBuffer xv = new StringBuffer(" double "+varname+"_xval[] = { "); + StringBuffer xem = new StringBuffer(" double "+varname+"_xerrminus[] = { "); + StringBuffer xep = new StringBuffer(" double "+varname+"_xerrplus[] = { "); + StringBuffer yv = new StringBuffer(" double "+varname+"_yval[] = { "); + StringBuffer yem = new StringBuffer(" double "+varname+"_yerrminus[] = { "); + StringBuffer yep = new StringBuffer(" double "+varname+"_yerrplus[] = { "); String sep = ""; for (int r = 1; r <= d.getMaxPointId(); ++r) { Bin b = x.getBin(r); @@ -101,22 +116,9 @@ s.append(yv + " };\n"); s.append(yem + " };\n"); s.append(yep + " };\n"); - s.append("int numpoints = " + d.getNumPoints() + ";\n"); - - // Make name and path - StringTemplate name = new StringTemplate("d$did$x$xid$y$yid$"); - name.setAttribute("did", d.getId()); - name.setAttribute("xid", x.getId()); - name.setAttribute("yid", y.getId()); - StringTemplate fullname = new StringTemplate("p$paperid$_$name$"); - fullname.setAttribute("paperid", d.getPaper().getId()); - fullname.setAttribute("name", name.toString()); - StringTemplate path = new StringTemplate("/HepData/$paperid$/$name$"); - path.setAttribute("paperid", d.getPaper().getId()); - path.setAttribute("name", name.toString()); + s.append(" int numpoints = " + d.getNumPoints() + ";\n"); // Append code to make the graph object - String varname = fullname.toString(); s.append(" " + varname + " = TGraphAsymmErrors(numpoints, xval, yval, xerrminus, xerrplus, yerrminus, yerrplus);\n"); s.append(" " + varname + ".SetName(\"" + path.toString() + "\");\n"); s.append(" " + varname + ".SetTitle(\"" + path.toString() + "\");\n"); @@ -124,10 +126,10 @@ s.append("\n"); } } - out = s.toString(); + out += s.toString(); } } catch (NullPointerException npe) { - out = "// Can't render this dataset, due to missing/incompatible information: please report this problem!\n\n"; + out += " // Can't render this plot, due to missing/incompatible information: please report this problem!\n\n"; } return out; } Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java Tue Jun 22 19:35:55 2010 (r1365) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java Wed Jun 23 13:49:33 2010 (r1366) @@ -65,7 +65,7 @@ asYODA = s.toString(); } } catch (NullPointerException npe) { - asYODA = "# Can't render this dataset, due to missing/incompatible information: please report this problem!\n\n"; + asYODA = "# Can't render this plot, due to missing/incompatible information: please report this problem!\n\n"; } return asYODA;
More information about the HepData-svn mailing list |