Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

HTMLPaperWriter.java

Go to the documentation of this file.
00001 package cedar.jetweb.html;
00002 
00003 import java.io.PrintWriter;
00004 import java.io.BufferedWriter;
00005 import java.io.File;
00006 import java.io.FileWriter;
00007 import java.io.IOException;
00008 
00009 import java.text.DateFormat;
00010 import java.text.SimpleDateFormat;
00011 import java.text.NumberFormat;
00012 import java.text.ParseException;
00013 
00014 import java.util.Locale;
00015 import java.util.Date;
00016 import java.util.Enumeration;
00017 import java.util.Vector;
00018 import java.util.List;
00019 import java.util.Iterator;
00020 import java.util.Map;
00021 import java.util.HashMap;
00022 import java.util.Map.Entry;
00023 import java.util.TreeMap;
00024 
00025 //import org.apache.commons.io.FileUtils;
00026 
00027 import cedar.jetweb.*;
00028 import cedar.jetweb.model.*;
00029 import cedar.jetweb.model.paper.*;
00030 import cedar.jetweb.model.plots.*;
00031 import cedar.jetweb.model.fit.*;
00032 import cedar.jetweb.job.*;
00033 import cedar.jetweb.batch.SubmitScriptHandler;
00034 import cedar.jetweb.JetWebException;
00035 import cedar.jetweb.JetWebConfig;
00036 import cedar.jetweb.hist.JetWebHist;
00037 import cedar.jetweb.generator.Generator;
00038 
00046 public class HTMLPaperWriter extends HTMLWriter {
00047 
00048     public HTMLPaperWriter(PrintWriter out, String newservletpath){
00049     super(out,newservletpath);
00050     }
00051     public HTMLPaperWriter(String fname, String newservletpath){
00052     super(fname,newservletpath);
00053     }
00054 
00055 
00059     public static void writePaperScreen(String paperIdString, 
00060                     PrintWriter out, String servletPath){
00061 
00062     int paperId=0;
00063     String title;
00064     BufferedWriter ofile = new BufferedWriter(out);
00065 
00066     try {
00067         paperId= Integer.parseInt(paperIdString);
00068         Paper paper = new Paper(paperId);
00069         HTMLPaperWriter pm = new HTMLPaperWriter(out,servletPath);
00070         pm.writePaperForm(paper," ");
00071         pm.writePlotsForm(paper," ");
00072         pm.close();
00073     } catch (JetWebException jwe){
00074         HTMLErrorWriter.write(out,jwe);
00075     } catch (NumberFormatException e){
00076         out.close();
00077     }
00078     }
00079 
00080 
00084     public static String getLink(Paper paper){
00085 
00086     return "<A href='http://"+JetWebConfig.spiresURL
00087         +"/cgi-bin/spiface/hep/www?rawcmd=find+irn+"
00088         +paper.getIRN()+"'>SPIRES Reference</A>";
00089 
00090     }
00097     public void writePaperForm(Paper paper, String message){
00098 
00099     try {
00100         ofile.newLine();
00101 
00102         ofile.write("<p>");
00103         openForm("POST",servletPath);
00104 
00105         ofile.write("<input type='hidden' name='PAPERID' value='"+paper.getId()+"'>");
00106 
00107         ofile.write("<table border='3' width='100'><tr>");
00108 
00109         ofile.write("<td><p>Title:</p></td>");
00110         ofile.write("<td colspan='1'><input type='text' size='70' name='TITLE' value='"
00111             +paper.getTitle()+"'></p></td></tr>");
00112 
00113         ofile.newLine();
00114         
00115         ofile.write("<tr><td><p>"+HTMLPaperWriter.getLink(paper)+"</td>");
00116         ofile.write("<td colspan='1'><input type='text' size='70' name='IRN' value='"
00117             +paper.getIRN()+"'></p></td></tr>");
00118         ofile.newLine();
00119 
00120         ofile.write("<tr><td><p>Journal Reference</p></td>");
00121         ofile.write("<td colspan='1'><input type='text' size='70' name='REFERENCE' value='"
00122             +paper.getReference()+"'></p></td></tr>");
00123         ofile.newLine();
00124 
00125         ofile.write("<tr><td><p>Collaboration:</p></td>");
00126         ofile.write("<td><input type='text' size='70' name='COLLABORATION' value='"
00127             +paper.getCollaboration()+"'></p></td></tr>");
00128 
00129         ofile.newLine();
00130 
00131         ofile.write("<tr><td><p>Accelerator:</p></td>");
00132         ofile.write("<td colspan='1'><input type='text' size='70' name='ACCELERATOR' value='"
00133             +paper.getAccelerator()+"'></p></td></tr>");
00134 
00135         ofile.newLine();
00136 
00137         ofile.write("<tr><td><p>Code Author(s):</p></td>");
00138         ofile.write("<td colspan='1'><input type='text' size='70' name='CODEAUTHOR' value='"
00139             +paper.getCodeAuthor()+"'></p></td></tr>");
00140 
00141         ofile.newLine();
00142 
00143         ofile.write("<tr><td><p>Contact:</p></td>");
00144         ofile.write("<td colspan='1'><input type='text' size='70' name='CONTACT' value='"
00145             +paper.getContact()+"'></p></td></tr>");
00146 
00147         ofile.newLine();
00148 
00149         ofile.write("<tr><td><p>Directory:</p></td>");
00150         ofile.write("<td colspan='1'><input type='text' size='70' name='DIRECTORY' value='"
00151             +paper.getDirName()+"'></p></td></tr>");
00152 
00153 
00154         ofile.write("<td align='left'><input type='submit' name='DELETEPAPER' value='Delete paper' title='Delete this paper and all plots associated with it from the database'></TD>");
00155 
00156         ofile.write("<td align='right'><input type='submit' name='CHANGEPAPER' value='Submit Changes'></TD></TR>");
00157 
00158         ofile.write("</table>");
00159         closeForm();
00160 
00161         ofile.write("</p>");
00162 
00163         ofile.newLine();
00164         
00165     } catch (IOException e) {
00166         System.out.println("Could not open output stream for this paper."+e);
00167     }
00168     }
00169 
00176     public void writePlotsForm(Paper paper, String message) throws JetWebException {
00177 
00178     try {
00179         ofile.write("<p><form enctype='multipart/form-data' method='post' action='"
00180             +JetWebConfig.uploadServletPath+"'>");
00181         ofile.write("<table border='3' width='100%'>");
00182         ofile.newLine();
00183 
00184         ofile.write("<input type='hidden' name='PLOTUPLOAD'>");
00185         ofile.write("<input type='hidden' name='PAPERID' value='"
00186             +paper.getId()+"'>");
00187         ofile.write("<input type='hidden' name='DIRECTORY' value='"
00188             +"/"+paper.getDirName()+"'>");
00189 
00190         ofile.write("<tr><td colspan='3'><p><font color='red'"
00191             +message+"</em></p></td><tr>");
00192         
00193         if (paper.getPlots()!=null){
00194         for (DataPlot plot : paper.getPlots()){    
00195             writePlotEntry(paper,plot);
00196         }
00197         }
00198 
00199         ofile.write("</table>");
00200         ofile.newLine();
00201 
00202         ofile.write("<table border='3' width='100%'>");
00203         ofile.newLine();
00204         
00205         // Finished existing plots. Allow a new one to be added
00206         writeNewPlotEntry(paper,"NEW");
00207 
00208         ofile.write("</table>");
00209 
00210         // End of all the plots!
00211 
00212         ofile.newLine();
00213         
00214         ofile.write("<input type='submit' value='Upload all plot information'>");
00215         ofile.newLine();
00216         //ofile.write("</table>");
00217 
00218         ofile.write("<hr noshade='noshade' size='3'>");
00219 
00220         ofile.write("</form>");
00221 
00222         ofile.write("<p><a href='/"+JetWebConfig.serverName+"'>Back to top</a></p>");
00223         
00224         DateFormat defaultDate = DateFormat.getDateInstance();
00225         DateFormat theTime = DateFormat.getTimeInstance();
00226         ofile.write("<hr noshade='noshade' size='3'><p>This page last updated "
00227             + defaultDate.format(new Date()) + " at "
00228             + theTime.format(new Date())+"</p>");       
00229         ofile.newLine();
00230     }
00231     catch (IOException e) {
00232         System.out.println("Could not open output stream for this paper."+e);
00233     }
00234     }
00235 
00236     private void writePlotEntry(Paper paper, DataPlot plot)
00237     throws IOException, JetWebException {
00238 
00239     // Start table row & entry
00240     ofile.write("<tr><td colspan='3'><hr noshade='noshade' size='3'></td></tr>"); 
00241     ofile.write("<tr><td colspan='3'><p><b>Paper ID="+paper.getId()+", Plot number "
00242             +plot.getNumber()+", plot ID="+plot.getId()+"</b></p></td>");
00243 
00244     ofile.write("<input type='hidden' name='CURRENTPLOTNUM' value='" 
00245             +plot.getNumber()+"'>");
00246     
00247     ofile.newLine();
00248     
00249     ofile.write("<tr><td><p>Title (mandatory!):</p></td>");
00250     ofile.write("<td colspan='2';><input type='text' size='70' name='TITLE"
00251             +plot.getNumber()+"' value='"
00252             +plot.getTitle()+"'></p></td></tr>");
00253     
00254     ofile.newLine();
00255     
00256     ofile.write("<tr><td><p>Scale factor:</p></td>");
00257     ofile.write("<td colspan='1'><input type='text' size='10' name='SCALE"
00258             +plot.getNumber()+"' value='"
00259             +dform.format(plot.getSysScale())+"'></p></td>");
00260     ofile.newLine();
00261     
00262     ofile.write("<td rowspan='6' align='right'>");
00263     // Link to the Graphics file.
00264     ofile.write("<a href='"+JetWebConfig.getHTMLRoot()+"/"
00265             +JetWebConfig.plotCacheDirName+"/"
00266             +paper.getDirName()+
00267             "/plot"+Integer.toString(plot.getNumber())+"."+
00268             JetWebConfig.graphicsType+"'> <img src='"+
00269             JetWebConfig.getHTMLRoot()+"/"
00270             +JetWebConfig.plotCacheDirName+"/"+paper.getDirName()+
00271             "/plot"+Integer.toString(plot.getNumber())+"."
00272             +JetWebConfig.graphicsType+"' alt='plot"
00273             +Integer.toString(plot.getNumber())+"'></a></td></tr>");
00274     
00275     ofile.newLine();
00276     
00277     ofile.write("<tr><td><p>In the default chi2?</p></td>");
00278     ofile.write("<td colspan='1'><select name='DEFSUM"
00279             +plot.getNumber()+"'>");
00280     ofile.write("<option value='"+plot.isDefaultSum()+"'>"
00281             +plot.isDefaultSum()+"</option>");
00282     ofile.write("<option value='"+!plot.isDefaultSum()+"'>"
00283             +!plot.isDefaultSum()+"</option></select></p></td></tr>");
00284     ofile.newLine();
00285     
00286     ofile.write("<tr><td><p>Is a normalised (shape) plot?</p></td>");
00287     ofile.write("<td colspan='1'><select name='ISSHAPE"
00288             +plot.getNumber()+"'>");
00289     ofile.write("<option value='"+plot.isShape()+"'>"
00290             +plot.isShape()+"</option>");
00291     ofile.write("<option value='"+!plot.isShape()+"'>"
00292             +!plot.isShape()+"</option></select></p></td></tr>");
00293     ofile.newLine();
00294     
00295     ofile.write("<tr><td><p>Use a logarithmic abscissa</p></td>");
00296     ofile.write("<td colspan='1'><select name='ISLOG"
00297             +plot.getNumber()
00298             +"'> <option value='"+plot.isLogarithmic()+"'>"
00299             +plot.isLogarithmic()+"</option>");
00300     ofile.newLine();
00301     ofile.write("<option value='"+!plot.isLogarithmic()+"'>"
00302             +!plot.isLogarithmic()+"</option></select></p></td></tr>");
00303     ofile.newLine();
00304 
00305     ofile.write("<tr><td><p>X label:</p></td>");
00306     ofile.write("<td colspan='1'><input type='text' size='30' name='XLABEL"
00307             +plot.getNumber()+"' value='"
00308             +plot.getXLabel()+"'></p></td>");
00309     ofile.newLine();
00310     
00311     ofile.write("<tr><td><p>Y label:</p></td>");
00312     ofile.write("<td colspan='1'><input type='text' size='30' name='YLABEL"
00313             +plot.getNumber()+"' value='"
00314             +plot.getYLabel()+"'></p></td></tr>");
00315     ofile.newLine();
00316     
00317     
00318     HTMLProcessWriter procWriter = new HTMLProcessWriter(ofile,servletPath);
00319 
00320     try {
00321 
00322         ofile.write("<tr><td colspan='1'><p>Default process type:</p></td><td colspan='2'><p>");
00323         //System.out.println(plot+" "+plot.getMCProcessType().getId());
00324 
00325         procWriter.write(plot.getMCProcessType().toString());
00326         //System.out.println("here");
00327         ofile.write("</p></td></tr>");
00328         ofile.newLine();
00329         
00330         Collision collision = null;
00331         ofile.write("<tr><td colspan='1'><p>Colliding beams are:</p></td><td colspan='2'><p>");
00332         ofile.write("<select name='COLL"+plot.getNumber()+"'>");
00333         try {
00334         collision = new Collision(plot.getCollisionId());
00335         ofile.write("<option value="+collision.getId()+">");
00336         procWriter.write(collision.toString());
00337         ofile.write("</option>");
00338         } catch (JetWebException jwe) {
00339         ofile.write("<option value='undefined'>Undefined</option>");
00340         }
00341         Vector<Collision> cList = Collision.getAll();
00342         for (Collision c : cList){
00343         ofile.write("<option value='"+c.getId()+"'>");
00344         procWriter.write(c.toString());
00345         ofile.write("</option>"); 
00346         }
00347         ofile.write("</select>");
00348 
00349 
00350         ofile.write("</p></td></tr>");
00351         ofile.newLine();
00352         ofile.write("<tr>");
00353         ofile.write("<td><p>Limits of allowed kinematic cuts</p></td>");
00354         ofile.write("<td colspan='2'>");
00355         for(Cut cut: plot.getCutCollection().getCuts()){
00356         ofile.newLine();
00357         ofile.write("<p>");
00358         ofile.write
00359             (cut.getName() + " = " + cut.getValue());
00360         ofile.write("</p>");
00361         }
00362 
00363         ofile.newLine();
00364         ofile.write("<p>");
00365         
00366         ofile.write("Add a new cut:");
00367         ofile.write("</p><p>");
00368         ofile.write("Cut name ");
00369         ofile.write("<input type='text' name='CUTNAME" + 
00370             plot.getNumber() +
00371             "' size='7' value=''>");
00372         ofile.write(" value ");
00373         ofile.write("<input type='text' name='CUTVALUE" + 
00374             plot.getNumber() +
00375             "' size='7' value=''>");
00376         ofile.write("</p>");
00377 
00378         ofile.write("</p></td>");
00379         ofile.write("</tr>");
00380         ofile.write("<tr><td><p>Process switches:</p></td>");
00381         ofile.write("<td colspan='2'><table>");
00382         Iterator<PlotSwitch> switches = plot.getSwitches();
00383         
00384         while (switches.hasNext()){     
00385         PlotSwitch plotSwitch = switches.next();
00386         writeSwitchForm(plotSwitch,String.valueOf(plotSwitch.getId()),collision);
00387         ofile.newLine();
00388         }
00389         
00390         writeSwitchForm(null,plot.getNumber()+"-new",collision);        
00391         ofile.newLine();
00392         
00393         ofile.write("</table></td></tr>");
00394         ofile.newLine();
00395         
00396     } catch (JetWebException jwe){
00397         ofile.write(jwe.getMessage());
00398     }
00399         
00400     ofile.write("<tr><td><p>Upload new XML data file for this plot:</p></td> ");
00401     ofile.write("<td align='right'><p><input type='FILE' name='XMLPLOT-"
00402             +plot.getNumber()+"'></td>");
00403     ofile.newLine();
00404     ofile.write("<td><p>Delete this plot:");
00405     ofile.write("<input type='checkbox' name='DELETEPLOT"+plot.getNumber()
00406             +"'></p></td></tr>");
00407     }
00408 
00409     private void writeNewPlotEntry(Paper paper, String label) throws IOException, JetWebException {
00410 
00411     HTMLProcessWriter procWriter = new HTMLProcessWriter(ofile,servletPath);
00412     ofile.write("<tr><td colspan='3'><p>New plot </p></td></tr>");
00413     ofile.newLine();
00414     
00415     ofile.write("<tr><td><p>Title (Mandatory!):</p></td>");
00416     ofile.write("<td colspan='2'><input type='TEXT' size='70' name='TITLE-"
00417             +label+"'></p></td></tr>");
00418     ofile.newLine();
00419     
00420     ofile.write("<tr><td><p>Scale factor:</p></td>");
00421     ofile.write("<td colspan='1'><input type='TEXT' size='10' name='SCALE-"
00422             +label+"' value='1.0'></p></td></tr>");
00423     ofile.newLine();
00424     
00425     ofile.write("<tr><td><p>X label:</p></td>");
00426     ofile.write("<td colspan='1'><input type='TEXT' size='30' name='XLABEL-"
00427             +label+"'></p></td></tr>");
00428     ofile.newLine();
00429     
00430     ofile.write("<tr><td><p>Y label:</p></td>");
00431     ofile.write("<td colspan='1'><input type='TEXT' size='30' name='YLABEL-"
00432             +label+"'></p></td></tr>");
00433     ofile.newLine();
00434     
00435     ofile.write("<tr><td><p>In the default chi2?</p></td>");
00436     ofile.write("<td colspan='1'><select name='DEFSUM-"
00437             +label+"'>");
00438     ofile.write("<option value='false'>False</option>");
00439     ofile.write("<option value='true'>True</option></select></p></td></tr>");
00440     ofile.newLine();
00441     
00442     ofile.write("<tr><td><p>Is a normalised (shape) plot?</p></td>");
00443     ofile.write("<td colspan='1'><select name='ISSHAPE-"+label+"'>");
00444     ofile.write("<option value='false'>False</option>");
00445     ofile.write("<option value='true'>True</option></select></p></td></tr>");
00446     ofile.newLine();
00447     
00448     ofile.write("<tr><td><p>Use a logarithmic abscissa</p></td>");
00449     ofile.write("<td colspan='1'><select name='ISLOG-"
00450             +label+"'> <option value='false'>False</option><option value='true'>True</option></select></p></td></tr>");
00451     ofile.newLine();
00452     
00453     ofile.write("<tr><td><p>Colliding beams are:</p></td><td><p>");
00454     ofile.write("<select name='COLL-"+label+"'>");
00455     ofile.write("<option value='undefined'>Undefined</option>");
00456     Vector<Collision> cList = Collision.getAll();
00457     for (Collision c : cList){
00458         ofile.write("<option value='"+c.getId()+"'>");
00459         procWriter.write(c.toString());
00460         ofile.write("</option>"); 
00461         ofile.newLine();
00462     }
00463     ofile.write("</select></td></tr>");
00464 
00465     ofile.newLine();
00466     ofile.write("<tr><td><p>Process switches:</p></td>");
00467     ofile.write("<td colspan='2'><table>");
00468             
00469     writeSwitchForm(null,label+"-NEW",null);        
00470     ofile.newLine();
00471 
00472     ofile.write("</table></td></tr>");
00473     
00474     ofile.newLine();
00475     
00476     if(label.equals("NEW")){
00477         ofile.write("<tr><td><p>" + 
00478             "Upload new XML data file for this plot:</p></td> ");
00479 
00480         ofile.write("<td align='LEFT'>" + 
00481             "<p>Data plot number from HZTool routine: "+
00482             "<input type='TEXT' name='HZSTEERPLOTID' size='5'>" + 
00483             "</p><p>" + 
00484             "MC plot number from HZTool routine: "+
00485             "<input type='TEXT' name='HZMCPLOTID' size='5'>"+
00486             "</p></td>"+
00487             "<td align='LEFT'><p>"+
00488             "<input type='FILE' name='XMLPLOT-'" + label + ">"+ 
00489             "</p></td></tr>");
00490 
00491         //ofile.write("<td align='LEFT'><p><input type='FILE' name='XMLPLOT-"
00492         //  +label+
00493         //  "'></p></td><td align='LEFT'>" + 
00494         //  "<p>Plot number from HZTool routine: "+
00495         //  "<input type='TEXT' name='HZSTEERPLOTID' size='5'>"+
00496         //  "</p></td></tr>");
00497     }else{
00498         ofile.write
00499         ("<tr><td colspan='2'>" + 
00500          "<p>Upload new XML data file for this plot:</p></td> ");
00501         ofile.write("<td align='RIGHT'><p><input type='FILE' name='XMLPLOT-"
00502             +label+"'></p></td></tr>");
00503     }
00504     
00505     }
00506 
00507     private void writeSwitchForm(PlotSwitch ps, String label, Collision collision) 
00508     throws IOException, JetWebException {
00509 
00510     HTMLProcessWriter procWriter = new HTMLProcessWriter(ofile,servletPath);
00511     ofile.write("<TR><TD COLSPAN=8><P>Use process ");
00512 
00513     ofile.write("<SELECT name='PROC"+label+"'>");
00514     try {
00515         ofile.write("<option value='"+ps.getMCProcessTypeId()+"'>");
00516         procWriter.write(ps.getMCProcessType().toString());
00517         ofile.write("</option>"); 
00518     } catch (NullPointerException n){
00519     }
00520     ofile.write("<option value='undefined'>Undefined</option>");
00521     ofile.write("<option value='-1'> Remove this switch </option>");
00522     Vector<MCProcessType> ptList = MCProcessType.getAll(collision,true);
00523     for (MCProcessType pt : ptList){
00524         ofile.write("<option value='"+pt.getId()+"'>");
00525         procWriter.write(pt.toString());
00526         ofile.write("</option>"); 
00527     }
00528     ofile.write("</select>");
00529         
00530     ofile.write(" if ");
00531 
00532     ofile.write("<select name='PARMNAME"+label+"'>");
00533     if (ps!=null && ps.getParameterName()!=null && !ps.getParameterName().equalsIgnoreCase("NULL")) {
00534         ofile.write("<option value='"+ps.getParameterName()+"'>"+ps.getParameterName()+"</option>"); 
00535     }
00536     ofile.write("<option value='undefined'>Undefined</option>");
00537     Iterator<String> parmList = PlotSwitch.getAllowedParameters();
00538     while (parmList.hasNext()){ 
00539         String parm = parmList.next();
00540         ofile.write("<option value='"+parm+"'>"+parm+"</option>");
00541     }
00542     ofile.write("</select>");
00543 
00544     ofile.write(" is between ");
00545     ofile.write("<input type='TEXT' size='10' name='PARMVALL"
00546             +label);
00547     if (ps!=null && ps.getParameterName()!=null && !ps.getParameterName().equalsIgnoreCase("NULL") ) { 
00548         ofile.write("' value='"+ps.getParameterValueLow()); }
00549     ofile.write("'>");
00550 
00551     ofile.write(" and ");
00552     ofile.write("<input type='text' size='10' name='PARMVALH"
00553             +label);
00554     if (ps!=null && ps.getParameterName()!=null && !ps.getParameterName().equalsIgnoreCase("NULL")) { 
00555         ofile.write("' value='"+ps.getParameterValueHigh()); }
00556 
00557     ofile.write("'> </p></td></tr>");
00558         
00559 
00560 
00561     ofile.write("<tr><td colspan='2'><p>for generator");
00562     ofile.write("<select name='GEN"+label+"'>");
00563     if (ps!=null && ps.getGeneratorName()!=null && !ps.getGeneratorName().equalsIgnoreCase("NULL") ) {
00564         ofile.write("<option value='"+ps.getGeneratorName()+"'>"
00565             +ps.getGeneratorName()+"</option>"); 
00566     }
00567     ofile.write("<option value='undefined'>Undefined/Any</option>");
00568     for (String name : Generator.allNames()){
00569         ofile.write("<option value='"+name+"'>"+name+"</option>");
00570     }
00571     ofile.write("</select></p></td>");
00572 
00573     ofile.write("<TR><TD COLSPAN=8><hr></TD></TR>");
00574 
00575     }
00576 
00577 
00581     public void display(Paper paper) throws JetWebException {
00582     display(paper,null);
00583     }
00584 
00590     public void display(Paper paper, Fit fit) 
00591     throws JetWebException {
00592 
00593     //System.out.println("Writing paper: "+paper.getReference());
00594 
00595     try {
00596 
00597         if (!verbose) {
00598 
00599         openForm("post",servletPath);
00600         ofile.write("JetWeb ID : "+paper.getId());
00601         ofile.write(" <b>"+paper.getTitle()+"</b> : "
00602                 +HTMLPaperWriter.getLink(paper)+" : ");
00603         ofile.write("<input type='hidden' name='PAPERID' value='"+paper.getId()+"'>");  
00604         if (fit!=null){
00605             ofile.write("<input type='hidden' name='FITID' value='"+fit.getId()+"'>");  
00606         }
00607         ofile.write(HTMLUtils.writeSubmitButton("PAPER",
00608                             "More details on this paper.",
00609                             "More"));       
00610         closeForm();
00611         return;
00612         }
00613 
00614         ofile.write("<div class='jetweb-paper'>");
00615         ofile.write("<table width='100%'><tr>");
00616         ofile.write("<td colspan='2'><p>ID:"+paper.getId()
00617             +" <b>"+paper.getTitle()+"</b></p></td>");
00618         ofile.write("<td><p>"+HTMLPaperWriter.getLink(paper)+"</p></td>");
00619         ofile.write("</tr>");
00620 
00621         ofile.newLine();
00622         ofile.write("<tr>");
00623 
00624         ofile.write("<td><p>Code author(s): "+paper.getCodeAuthor()+"</p></td>");
00625         ofile.write("<td><p>Contact: "+paper.getContact()+"</p>");
00626         ofile.write("</tr>");
00627     
00628         ofile.newLine();
00629         ofile.write("<tr>");
00630 
00631         /*      
00632         StringBuffer imagePath = new StringBuffer(JetWebConfig.plotCacheDirName);
00633         if (fit!=null) {
00634         imagePath.append("/"+fit.getId());
00635         }
00636         imagePath.append("/"+paper.getDirName());
00637         */
00638 
00639         HTMLPlotWriter plotWriter = new HTMLPlotWriter(ofile,servletPath);
00640         plotWriter.setVerbose(true);
00641         //plotWriter.setImagePath(imagePath.toString());
00642 
00643         Vector<Integer> fitPlots = null;
00644         
00645         if(fit!=null){
00646         fitPlots = fit.getPlotSelection().getPlotIds();
00647         }
00648         
00649         System.out.println("fitPlots = " + fitPlots);
00650 
00651         for (DataPlot plot : paper.getPlots()){
00652 
00653         // only write the plot if it is in the fit and the paper
00654         // (unless the fit is null)
00655         if(fit==null || fitPlots.contains(plot.getId())){
00656 
00657             System.out.println("displaying plot " + plot.getId());
00658 
00659             ofile.write("<tr><td colspan='3'>");
00660             plotWriter.display(plot,fit);
00661             ofile.write("</td></tr>");
00662             ofile.newLine();
00663             ofile.write
00664             ("<tr><td colspan='3'>"+
00665              "<hr noshade size='3'/></td></tr>");
00666         }
00667         }
00668 
00669         ofile.write("</table>");
00670 
00671     }
00672     catch (IOException e) {
00673         System.out.println("Could not open output stream for this paper."+e);
00674     }
00675     }
00676 
00677 
00681     public static void writeGraphics(final Map<Integer,Paper> papers, Fit fit){
00682 
00683 
00684     if (JetWebConfig.writePlots){
00685 
00686         StringBuffer pathBuff = new StringBuffer(JetWebConfig.rootDirectory);
00687         pathBuff.append("/"+JetWebConfig.plotCacheDirName);
00688         if (fit!=null){
00689         pathBuff.append("/"+fit.getId());
00690         }   
00691         final String path = pathBuff.toString();
00692         Thread t = new Thread(new Runnable(){
00693             public void run(){ 
00694             System.out.println("Spawned writeGraphics thread");
00695             for (Paper mcPaper : papers.values()){
00696                 JetWebHist.writeGraphics(mcPaper,path);
00697             }
00698             System.out.println("Finished writeGraphics thread");
00699             } 
00700         });
00701         t.setPriority(Thread.MIN_PRIORITY);
00702         t.start();
00703         // Add to ThreadPool to avoid too many threads running at once.
00704         JetWebConfig.graphicsThreadPool.add(t); 
00705     }
00706     }
00707 
00711     public void display(Object object) throws JetWebException {
00712     try {
00713         display((Paper)object,null);
00714     } catch (ClassCastException e) {
00715         throw new JetWebException(e);
00716     }
00717     }
00718 
00719 
00720 }
00721 
00722 

Generated Wed Jan 17 09:14:27 GMT 2007