Index: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/AboutHepdata.tml =================================================================== --- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/AboutHepdata.tml (revision 1899) +++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/AboutHepdata.tml (revision 1900) @@ -1,80 +1,81 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html t:type="layout" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> <title>Durham REACTION DATABASE Search</title> <body class="reaction"> <table> <tr> <td> <h2>About HepData</h2> <p/> -The Durham High Energy Physics Database (HepData) has been built up over the past four decades as a unique open-access repository for scattering data from experimental particle physics. It currently comprises the data points from plots and tables related to several thousand publications including those from the Large Hadron Collider (LHC). +The Durham High Energy Physics Database (HepData) has been built up over the past four decades as a unique open-access repository for scattering data from experimental particle physics. It currently comprises the data points from plots and tables related to several thousand publications including those from the Large Hadron Collider (LHC). An overview of the HepData project was presented in a <a href="http://hepdata.cedar.ac.uk/resource/hepdata-aahep7.pdf">talk</a> (2.9 MB) at <a href="http://indico.cern.ch/event/aahep7/">AAHEP7</a> on 2nd April 2014 and in a <a href="http://hepdata.cedar.ac.uk/resource/hepdata-aahep8.pdf">talk</a> (1.4 MB) at <a href="http://indico.cern.ch/event/aahep8/">AAHEP8</a> on 2nd September 2015. <p/> HepData is funded by a grant from the UK <a href="http://www.stfc.ac.uk">STFC</a> and is based at the <a href="http://www.ippp.dur.ac.uk">IPPP</a> at Durham University. The HepData team is very small comprising: -<table cellspacing='20'> -<tr><td> +<p/> <table align='center' border='1' cellpadding='5'> <tr align='center' valign='top'> <td> -<b>Graeme Watt</b><br/> +<a href="http://www.ippp.dur.ac.uk/profile/watt"><b>Graeme Watt</b></a><br/> <img src="http://hepdata.cedar.ac.uk/resource/graemewatt.jpeg" vspace='5'></img><br/> Current Database Manager<br/> (since October 2013) </td> <td> -<b>Mike Whalley</b><br/> +<a href="http://www.ippp.dur.ac.uk/profile/whalley"><b>Mike Whalley</b></a><br/> <img src="http://hepdata.cedar.ac.uk/resource/mikewhalley.jpeg" vspace='5'></img><br/> Previous Database Manager<br/> (part-time, retiring) </td> <td> -<b>Joanne Bentham</b><br/> +<a href="http://www.ippp.dur.ac.uk/profile/joanne"><b>Joanne Bentham</b></a><br/> <img src="http://hepdata.cedar.ac.uk/resource/joannebentham.jpeg" vspace='5'></img><br/> Coding Assistant<br/> </td> -</tr> -</table> -</td> <td> -<i>Principal Investigator</i>:<br/> -Frank Krauss<br/><br/> -<i>Co-Investigators</i>:<br/> -Jeppe Andersen<br/>Nigel Glover<br/>Valya Khoze<br/>Peter Richardson +<a href="http://www.ippp.dur.ac.uk/profile/krauss"><b>Frank Krauss</b></a><br/> +<img src="http://hepdata.cedar.ac.uk/resource/frankkrauss.jpeg" vspace='5'></img><br/> +Principal Investigator<br/> </td> </tr> </table> <p/> -An overview of the HepData project was presented in a <a href="http://hepdata.cedar.ac.uk/resource/hepdata-aahep7.pdf">talk</a> (2.9 MB) at <a href="http://indico.cern.ch/event/aahep7/">AAHEP7</a> on 2nd April 2014 and in a <a href="http://hepdata.cedar.ac.uk/resource/hepdata-aahep8.pdf">talk</a> (1.4 MB) at <a href="http://indico.cern.ch/event/aahep8/">AAHEP8</a> on 2nd September 2015. -<p/> -The HepData advisory board <a href="http://conference.ippp.dur.ac.uk/e/HepData2014">kickoff meeting</a> was held on 12th November 2014. The next advisory board meeting will be held on 16th October 2015. The current external advisory board members are: +The HepData advisory board kickoff <a href="http://conference.ippp.dur.ac.uk/e/HepData2014">meeting</a> was held on 12th November 2014, with a follow-up <a href="http://conference.ippp.dur.ac.uk/e/HepData2015">meeting</a> held on 16th October 2015. The current advisory board members are: <table border='0' cellspacing='5'> <tr> -<td> Constantin Loizides (LBNL, ALICE)</td> +<td> Enrico Scomparin (Torino, ALICE)</td> <td> </td> -<td> Matthew Wing (UCL, smaller experiments)</td> +<td> Kyle Cranmer (NYU, wider user base)</td> </tr> <tr> <td> Bill Murray (RAL/Warwick, ATLAS)</td> <td> </td> -<td> Kyle Cranmer (NYU, wider user base)</td> +<td> Sünje Dallmeier-Tiessen (CERN, INSPIRE)</td> </tr> <tr> <td> Henning Flaecher (Bristol, CMS)</td> <td> </td> -<td> Sünje Dallmeier-Tiessen (CERN, INSPIRE)</td> +<td> Salvatore Mele (CERN, INSPIRE)</td> </tr> <tr> <td> Ulrik Egede (Imperial, LHCb)</td> +<td> </td> +<td> Keith Ellis (IPPP)</td> +</tr> +<tr> +<td> Matthew Wing (UCL, smaller experiments)</td> +<td> </td> +<td> Jeppe Andersen (IPPP)</td> </tr> </table> <p/> +A transition will soon be made to a new HEPData site, <a href="http://www.hepdata.net">hepdata.net</a>, based on <a href="http://invenio-software.org/">Invenio</a>, developed in collaboration with <a href="http://inspirehep.net">INSPIRE</a>, and hosted at <a href="http://home.cern">CERN</a>. +<p/> </td> </tr> </table> - </body> </html> Index: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java =================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java (revision 1899) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java (revision 1900) @@ -1,621 +1,630 @@ package cedar.hepdata.formats; import cedar.hepdata.model.*; import cedar.hepdata.util.*; import cedar.hepdata.xml.*; import cedar.hepdata.db.*; import cedar.hepdata.webapp.components.*; import java.util.*; import java.text.*; import java.io.File; import java.io.*; import org.antlr.stringtemplate.*; import com.Ostermiller.util.SignificantFigures; public class YamlFormatter { public static String format(Collection<Dataset> ds, Paper p) { String s4=" "; String sp=" - "; StringBuffer s = new StringBuffer(); if (p != null) { s.append("---\n"); // _headerYAML contains all the bibliographic type stuff at the beginning s.append(_headerYAML(p)); } // and now the datasets for (Dataset d : ds){ s.append("\n---\n"); s.append(_metadataYAML(d)); // dataset information in _metadata //s.append("data_file: data"+d.getId()+".yaml\n"); //s.append("additional_resources:\n"); s.append(_dataYAML(d)); // dataset information in _data } // for (Dataset d : ds){ // s.append("\n---\n"); // s.append(_dataYAML(d)); // dataset information in _data // } // finally finish off (at present does nothing!) s.append(_footerYAML()); // then write it all out. return s.toString(); } public static String _getTimestamp(){ DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = new Date(); return dateFormat.format(date); } public static String _headerYAML(Paper p) { String s4=" "; String sp=" - "; StringBuffer s = new StringBuffer(); s.append("record_ids: # optional\n"); if(p.getInspireId()!=null) { s.append(sp+"{type: inspire, id: "+p.getInspireId()+"}\n"); } if(p.getRedId()!=null) { s.append(sp+"{type: red, id: "+p.getRedId()+"}\n"); } s.append("dateupdated: '"+p.getDateUpdated()+"'\n"); if(p.getModifications().size()>0){ s.append("modifications: # what, by whom and when encoded or changed\n"); int mcount=0; for (Modification m : p.getModifications()){ mcount++; if (m.getAction()!=null) { s.append(sp+"{action: '"+m.getAction()+"'"); } else { if (mcount==1) { s.append(sp+"{action: 'Encoded'"); } else { s.append(sp+"{action: 'Modified'"); } } s.append(", date: '"+m.getComment()+"', who: '"+m.getModifier()+"'}\n"); } } if(p.getComments().size()>0){ s.append("comment: | # preserve newlines\n"); boolean first=true; for (String comment : p.getComments()){ if(first){ s.append(s4+comment.replaceAll("\n","\n ")+"."); first=false; } else { s.append(s4+comment.replaceAll("\n","\n ")+"."); } s.append("\n"); } } s.append("\nadditional_resources:\n"); if(p.getReferences().size()>0){ for (Reference r : p.getReferences()){ if(r.getDescription().startsWith("http")){ s.append(sp+"{location: '"+r.getDescription()+"', description: 'web page with auxiliary material'}\n"); } } if (p.getHaveRivet()) { s.append(sp+"{location: 'http://rivet.hepforge.org/analyses#"+p.getRivetName()+"', description: 'Rivet analysis'}\n"); } } // here we deal with the extra resource area description/line files String[] descs = { "description1" , "description2" , "description3" , "description4" }; String[] links = { "link1" , "link2" , "link3" , "link4" }; String[] ids = new String[3]; if(p.getSpiresId() != null ) { ids[0]=p.getSpiresId().toString(); } else { ids[0]=""; } if(p.getInspireId() != null ) { ids[1]=p.getInspireId().toString(); } else { ids[1]=""; } if(p.getRedId() != null ) { ids[2]=p.getRedId().toString(); } else { ids[2]=""; } for (int i=0; i<descs.length; i++){ for(int j=0; j<ids.length; j++){ String descfile = "/home/hepdata/resource/" +ids[j] + "/" + descs[i]; String linkfile = "/home/hepdata/resource/" +ids[j] + "/" + links[i]; File testdesc = new File(descfile); File testlink = new File(linkfile); String desc=""; String link=""; if( testdesc.exists() && testlink.exists() ){ try { BufferedReader in = new BufferedReader(new FileReader(descfile)); desc=in.readLine(); } catch (IOException e){} try { BufferedReader in = new BufferedReader(new FileReader(linkfile)); link=in.readLine(); } catch (IOException e){} s.append(sp+"{location: '"+link+"', description: '"+desc.replaceAll("'","''")+"'}\n"); } } } // next the possible index.shtml file in the resource area for (int j=0; j<ids.length; j++){ String descfile = "/home/hepdata/resource/" +ids[j] + "/description"; String linkfile = "/home/hepdata/resource/" +ids[j] + "/index.shtml"; File testdesc = new File(descfile); File testlink = new File(linkfile); String desc=""; if( testdesc.exists() && testlink.exists() ) { try { BufferedReader in = new BufferedReader(new FileReader(descfile)); desc=in.readLine(); } catch (IOException e){} s.append(sp+"{location: '/resource/"+ids[j]+"/index.shtml', description: '"+desc.replaceAll("'","''")+"'}\n"); } } // next the possible insert.html file in the resource area for (int j=0; j<ids.length; j++){ String insertfile = "/home/hepdata/resource/" +ids[j] + "/insert.html"; File testinsert = new File(insertfile); String insert=""; if(testinsert.exists()){ s.append(sp+"{location: '/resource/"+ids[j]+"/insert.html', description: 'insert.html'}\n"); } } return s.toString(); } public static String _footerYAML() { StringBuffer s = new StringBuffer(); return s.toString(); } public static String _metadataYAML(Dataset ds){ String s4=" "; String sp=" - "; StringBuffer s = new StringBuffer(); int idbase=9000000; int id=idbase+ds.getId(); String location = ""; Paper p = ds.getPaper(); s.append("name: 'Table "+ds.getId()+"'\n"); for (String ct : ds.getComments()){ if(ct.startsWith("Location:")) { location = ct.replaceFirst("Location:","").replaceAll(" ",""); // s.append("label: "+ct.replaceFirst("Location:","Data from")+" from: "+p.getTitle()+"\n"); s.append("label: '"+ct.replaceFirst("Location:","Data from")+"'\n"); } } boolean first=true; for (String ct : ds.getComments()){ if(!ct.startsWith("Location:")) { s.append("description: |\n"); if(first){ s.append(s4+ct.replaceFirst("VERBATIM","").replaceAll("\n","\n ")+"."); first=false; } else { s.append(s4+ct.replaceFirst("VERBATIM","").replaceAll("\n","\n ")+"."); } s.append("\n"); } } s.append("keywords:\n"); if(ds.getDsReactions().size() > 0) { s.append(sp+"{name: reactions, values: ["); int nr=0; for (String dsreac : ds.getDsReactions()){ s.append("'"+dsreac+"'"); if(++nr==ds.getDsReactions().size()){s.append("]}\n"); } else {s.append(", ");} } } if(ds.getDsObservables().size() > 0) { s.append(sp+"{name: observables, values: ["); int no=0; for (String dsobs : ds.getDsObservables()){ s.append("'"+dsobs+"'"); if(++no==ds.getDsObservables().size()){s.append("]}\n"); } else {s.append(", ");} } } if(ds.getDsPlabs().size() > 0) { s.append(sp+"{name: plabs, values: ["); int np=0; for (String dsplab : ds.getDsPlabs()){ s.append("'"+dsplab+"'"); if(++np==ds.getDsPlabs().size()){s.append("]}\n"); } else {s.append(", ");} } } // if(p.getKeywords().size() > 0) { // s.append(sp+"{name: keywords, values: ["); // int np=0; // for (String pkey : p.getKeywords()){ // s.append("'"+pkey+"'"); // if(++np==p.getKeywords().size()){s.append("]}\n"); } // else {s.append(", ");} // } // } Double ecmlow=99999.0; Double ecmhigh=-99999.0; boolean haveecm=false; for (YAxis yax : ds.getYAxes()){ for (Property prop : yax.getProperties()){ if(prop.getName().startsWith("SQRT(S)")){ if(prop.getFocus() != null) { if(prop.getFocus()>ecmhigh) ecmhigh=prop.getFocus(); if(prop.getFocus()<ecmlow) ecmlow=prop.getFocus(); haveecm=true; } if(prop.getLowValue() != null) { if(prop.getLowValue()<ecmlow) ecmlow=prop.getLowValue(); haveecm=true; } if(prop.getHighValue() != null) { if(prop.getHighValue()>ecmhigh) ecmhigh=prop.getHighValue(); haveecm=true; } } } } if(!haveecm){ for (XAxis xax : ds.getXAxes()){ if(xax.getHeader().startsWith("SQRT(S)")){ for (Bin bin : xax.getBins()){ if(bin.getFocus() != null) { if(bin.getFocus()>ecmhigh) ecmhigh=bin.getFocus(); if(bin.getFocus()<ecmlow) ecmlow=bin.getFocus(); haveecm=true; } if(bin.getLowValue() != null) { if(bin.getLowValue()<ecmlow) ecmlow=bin.getLowValue(); haveecm=true; } if(bin.getHighValue() != null) { if(bin.getHighValue()>ecmhigh) ecmhigh=bin.getHighValue(); haveecm=true; } } } } } if(haveecm){ s.append(sp+"{name: cmenergies, values: [" + ecmlow); if(!ecmlow.equals(ecmhigh)) s.append("-"+ecmhigh); s.append("]}\n"); } // Write location of image files if present. s.append("additional_resources:\n"); String[] ids = new String[3]; if(p.getSpiresId() != null ) { ids[0]=p.getSpiresId().toString(); } else { ids[0]=""; } if(p.getInspireId() != null ) { ids[1]=p.getInspireId().toString(); } else { ids[1]=""; } if(p.getRedId() != null ) { ids[2]=p.getRedId().toString(); } else { ids[2]=""; } for(int j=0; j<ids.length; j++) { String imagefile = "/home/hepdata/resource/" +ids[j] + "/fig" + location + ".png"; File testimage = new File(imagefile); if(testimage.exists()){ s.append(sp+"{location: '/resource/"+ids[j]+"/fig" + location + ".png', description: 'Image file'}\n"); } String thumbfile = "/home/hepdata/resource/" +ids[j] + "/thumb_fig" + location + ".png"; File testthumb = new File(thumbfile); if(testthumb.exists()){ s.append(sp+"{location: '/resource/"+ids[j]+"/thumb_fig" + location + ".png', description: 'Thumbnail image file'}\n"); } } return s.toString(); } public static String _dataYAML(Dataset ds){ String s4=" "; String sp=" - "; StringBuffer s = new StringBuffer(); int idbase=9000000; int id=idbase+ds.getId(); String location = ""; Paper p = ds.getPaper(); int npoints=ds.getNumPoints(); //s.append("name: 'Table "+ds.getId()+"'\n"); s.append("independent_variables:\n"); if (npoints > 0) { for (XAxis xax : ds.getXAxes()){ String name=xax.getHeader(); String unit=""; if(xax.getHeader().contains(" IN ")){ name=xax.getHeader().substring(0,xax.getHeader().indexOf(" IN ")).trim(); unit=xax.getHeader().substring(xax.getHeader().indexOf(" IN ")+4).trim(); + } else if (xax.getHeader().contains(" in ")) { + name=xax.getHeader().substring(0,xax.getHeader().indexOf(" in ")).trim(); + unit=xax.getHeader().substring(xax.getHeader().indexOf(" in ")+4).trim(); } s.append(sp+"header: {name: '"+name.replaceAll("'","''")+"'"); if(!unit.equals("")){ s.append(", units: '"+unit+"'"); } s.append("}\n"); s.append(s4+"values:\n"); for (Bin bin : xax.getBins()){ boolean first=true; s.append(s4+sp+"{"); // if(bin.getId() != null ) { // s.append("id: "+bin.getId()); // first=false; // } boolean asymmfocus = false; if (bin.getLowValue() != null && bin.getHighValue() != null && bin.getFocus() != null) { double diff = bin.getFocus() - (bin.getLowValue() + bin.getHighValue()) / 2.0; if (Math.abs(diff/bin.getFocus()) > 1E-6) { asymmfocus = true; } } boolean haswidth = false; if (bin.getLowValue() != null && bin.getHighValue() != null) { double diff = bin.getHighValue() - bin.getLowValue(); double mean = (bin.getLowValue() + bin.getHighValue()) / 2.0; if((Math.abs(diff/mean) > 1E-6) || (mean == 0.0 && Math.abs(diff) > 1E-6)){ haswidth = true;} } 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) { s.append("value: "+forms(bin.getFocus(),bin.getFocusLength())); } else { s.append("value: "+bin.getFocus()); } first=false; } } if(bin.getLowValue() != null && haswidth) { if(!first) { s.append(", "); } if(bin.getLowValueLength()!=null) { s.append("low: "+forms(bin.getLowValue(),bin.getLowValueLength())); } else { s.append("low: "+bin.getLowValue()); } first=false; } if(bin.getHighValue() != null && haswidth) { if(!first) {s.append(", "); } if(bin.getHighValueLength()!=null) { s.append("high: "+forms(bin.getHighValue(),bin.getHighValueLength())); } else { s.append("high: "+bin.getHighValue()); } first=false; } if(bin.getDescription() != null ) { if(!first) { s.append(", "); } s.append("value: '"+bin.getDescription()+"'"); first=false; } if (bin.getDescription() == null && bin.getFocus() == null && bin.getLowValue() == null && bin.getHighValue() == null) { s.append("value: '-'"); } if(bin.getId() < xax.getBins().size()) { s.append("}"); } else{s.append("}");} s.append("\n"); } } } s.append("dependent_variables:\n"); if (npoints > 0) { for (YAxis yax : ds.getYAxes()){ String name=yax.getHeader(); String unit=""; if(yax.getHeader().contains(" IN ")){ name=yax.getHeader().substring(0,yax.getHeader().indexOf(" IN ")).trim(); unit=yax.getHeader().substring(yax.getHeader().indexOf(" IN ")+4).trim(); + } else if (yax.getHeader().contains(" in ")) { + name=yax.getHeader().substring(0,yax.getHeader().indexOf(" in ")).trim(); + unit=yax.getHeader().substring(yax.getHeader().indexOf(" in ")+4).trim(); } s.append(sp+"header: {name: '"+name.replaceAll("'","''")+"'"); if(!unit.equals("")){ s.append(", units: '"+unit+"'"); } s.append("}\n"); boolean first=true; for (Property prop : yax.getProperties()){ if(first) { s.append(s4+"qualifiers:\n"); } first=false; s.append(s4+sp+"{name: '"+prop.getName().replaceAll("'","''")+"'"); if(prop.getFocus()!=null || prop.getLowValue()!=null || prop.getHighValue()!=null){ s.append(", value: '"); } if (prop.getFocus() != null){ s.append(prop.getFocus()); } if (prop.getLowValue() != null && prop.getHighValue() != null && prop.getLowValue().equals(prop.getHighValue())) { s.append(prop.getLowValue()); } else { if(prop.getFocus() != null) { s.append(" ("); } s.append(prop.getLowValue()); s.append("-"); s.append(prop.getHighValue()); if(prop.getFocus() != null) { s.append(")"); } } if(prop.getFocus()!=null || prop.getLowValue()!=null || prop.getHighValue()!=null){ s.append("'"); } if (prop.getUnit().toString().equals("") || !prop.getUnit().isDimensionless()) { s.append(", units: '"); s.append(prop.getUnit().toString()+"'"); } s.append("}\n"); } for (String comment : yax.getComments()){ if(first) { s.append(s4+"qualifiers:\n"); } first=false; unit=""; String type=comment.substring(0,comment.indexOf(":")-1).trim(); String value=comment.substring(comment.indexOf(":")+1).trim(); // String type="SYS"; // String value=comment; // if(comment.indexOf(":")>-1) { // type=comment.substring(0,comment.indexOf(":")-1).trim(); // value=comment.substring(comment.indexOf(":")+1).trim(); // } if(type.contains(" IN ")){ unit=type.substring(type.indexOf(" IN ")+4).trim(); type=type.substring(0,type.indexOf(" IN ")).trim(); + } else if (type.contains(" in ")) { + unit=type.substring(type.indexOf(" in ")+4).trim(); + type=type.substring(0,type.indexOf(" in ")).trim(); } s.append(s4+sp+"{name: '"+type.replaceAll("'","''")+"'"); s.append(", value: '"+ value.replaceAll("'","''")+"'"); // if(type.equals("SYS") && value.indexOf("//")>-1){ // String comments[] = value.replaceAll("////","//").split("//"); // for( int i=0; i<comments.length; i++) { // s.append(s4+sp+"{name: '"+type.replaceAll("'","''")+"'"); // s.append(", value: '"+ comments[i].replaceAll("'","''")+"'"); // if(i!=comments.length-1) { s.append("}\n"); } // } // } // else { // s.append(s4+sp+"{name: '"+type.replaceAll("'","''")+"'"); // s.append(", value: '"+ value.replaceAll("'","''")+"'"); // } if(!unit.equals("")){ s.append(", units: '"+ unit+"'"); } s.append("}\n"); } for(Uncertainty error : ds.getErrors()){ if(error.getPlus()==0.0){ s.append(s4+sp+"{name: 'SYS', value: '"+error.getComment()+"'}\n"); } } for(Uncertainty error : yax.getErrors()){ if(error.getPlus()==0.0){ s.append(s4+sp+"{name: 'SYS', value: '"+error.getComment()+"'}\n"); } } s.append(s4+"values:\n"); for (int ip=1; ip<npoints+1; ip++){ Point point = yax.getPoint(ip); if(point==null){ // s.append(s4+sp+"id: "+ip+"\n"); // s.append(s4+s4+"value: '-'\n"); s.append(s4+sp+"value: '-'\n"); } else{ // s.append(s4+sp+"id: "+point.getId()+"\n"); // s.append(s4+s4+"value: "); s.append(s4+sp+"value: "); if(point.getRelation() != Relation.EQUALS){ s.append("'"+point.getRelation()); } // s.append(point.getValue()+" "+point.getValueLength()+"\n"); if (point.getDescription() != null) { if(point.getRelation() == Relation.EQUALS){ s.append("'"); } s.append(point.getDescription()+"'"); } else { s.append(point.getValue()); } if (point.getRelation() != Relation.EQUALS) { s.append("'"); } s.append("\n"); if (point.getErrors().size() > 0 || yax.getErrors().size() > 0 || ds.getErrors().size() > 0) { s.append(s4+s4+"errors:\n"); } if(point.getErrors().size()>0){ for(Uncertainty error : point.getErrors()){ s.append(_formatError(error,"point")); } } if(yax.getErrors().size()>0){ for(Uncertainty error : yax.getErrors()){ if(error.getPlus()!=0.0) s.append(_formatError(error,"axis")); } } if(ds.getErrors().size()>0){ for(Uncertainty error : ds.getErrors()){ if(error.getPlus()!=0.0) s.append(_formatError(error,"dataset")); } } } } } } return s.toString(); } public static String _formatError(Uncertainty error, String which) { String s4=" "; String sp=" - "; StringBuffer s = new StringBuffer(); Double test = error.getMinus(); if(which.equals("point")) test=-test; if((error.getPlus()>=0.0 && (error.getPlus().equals(test))) || error.hasZeroSize()){ s.append(s4+s4+sp+"{symerror: "); s.append(error.getPlus()); if(error.getNormType()==ErrorNorm.PCT){ s.append("%"); } } else{ s.append(s4+s4+sp+"{asymerror: "); s.append("{plus: "+error.getPlus()); if(error.getNormType()==ErrorNorm.PCT){ s.append("%"); } s.append(", minus: "+error.getMinus()); if(error.getNormType()==ErrorNorm.PCT){ s.append("%"); } s.append("}"); } if(error.getSourceType()==ErrorSource.STAT) s.append(", label: 'stat"); else if(error.getSourceType()==ErrorSource.SYS) s.append(", label: 'sys"); else if(error.getSourceType()==ErrorSource.TOTAL) s.append(", label: 'total"); if (error.getSourceType()==ErrorSource.STAT || error.getSourceType()==ErrorSource.SYS || error.getSourceType()==ErrorSource.TOTAL) { if(!error.getComment().equals("")) s.append(","+error.getComment()); s.append("'"); } s.append("}\n"); return s.toString(); } public static String forms(Double value, int after) { String form = "0."; for(int i=0; i<after; ++i){ form=form.concat("0"); } DecimalFormat myFormatter = new DecimalFormat(form); String sval = "Cannot format this"; if(value instanceof Double) { sval = myFormatter.format(value); } if(sval.endsWith(".")) { sval=sval.substring(0,sval.length()-1); } return sval; } }