00001 package cedar.jetweb.model.plots; 00002 00003 import java.io.File; 00004 import java.util.Iterator; 00005 00006 00007 import cedar.jetweb.db.DBPlotManager; 00008 import cedar.jetweb.Storeable; 00009 import cedar.jetweb.*; 00010 import cedar.jetweb.model.MCProcessType; 00011 import cedar.jetweb.model.Collision; 00012 import cedar.jetweb.generator.Generator; 00013 import cedar.jetweb.job.CutCollection; 00014 00021 public class RealPlot extends DataPlot implements Storeable { 00029 public RealPlot(final int number, int paperIdIn) 00030 throws JetWebException { 00031 this.paperId = paperIdIn; 00032 this.number = number; 00033 hasdata=false; 00034 } 00035 00039 public RealPlot(){ 00040 } 00046 public void setScale(double newScale){ 00047 sysScale = newScale; 00048 } 00049 00050 public CutCollection getCutCollection(){ 00051 try{ 00052 if(cuts_==null && csnId>0) DBPlotManager.fromDB(this); 00053 }catch(JetWebException err){ 00054 System.out.println 00055 ("RealPlot: unable to retrieve cut collection for this plot"); 00056 err.printStackTrace(); 00057 System.out.println(err.getMessage()); 00058 } 00059 return cuts_; 00060 } 00061 00062 public boolean retrieve() throws JetWebException { 00063 if (csnId<=0) { 00064 csnId=DBPlotManager.getPlotId(paperId,number); 00065 } 00066 DBPlotManager.fromDB(this); 00067 return true; 00068 } 00069 00076 public boolean store() throws JetWebException { 00077 // Check whether crossection with this plot id exists 00078 // if it does, update crossection record,otherwise create 00079 // delete existing data plot (if exists) 00080 // insert new data plot records 00081 if (csnId<=0) { 00082 csnId=DBPlotManager.getPlotId(paperId,number); 00083 } 00084 if (csnId>0){ 00085 updateCrossSection(); 00086 return false; 00087 } else { 00088 insertCrossSection(); 00089 return true; 00090 } 00091 00092 } 00093 00094 00101 private void insertCrossSection() throws JetWebException { 00102 // Add the title, axis info etc. 00103 DBPlotManager.insertCrossSection(this,paperId); 00104 00105 // Now insert the data points. 00106 if (csnId>0){ 00107 if (!dataPoints.isEmpty()){ 00108 DBPlotManager.insertData(this); 00109 } 00110 } else { 00111 System.out.println("Failed to insert Data Plot"); 00112 } 00113 } 00114 00115 00122 private void updateCrossSection() throws JetWebException { 00123 00124 // Update the title, axis info etc. 00125 DBPlotManager.updateCrossSectionLabels(this); 00126 00127 // Update the data points 00128 DBPlotManager.updateCrossSectionPoints(this); 00129 00130 } 00131 00135 public MCProcessType getMCProcessType() throws JetWebException { 00136 00137 if (!(proc==null)) { 00138 //System.out.println("RealPlot: not working it out"); 00139 return proc; 00140 } else { 00141 00142 //System.out.println("RealPlot: working it out"); 00143 00144 00145 // Work out the MCProcessType from the plotSwitches. 00146 Iterator list = getSwitches(); 00147 while (list.hasNext()){ 00148 PlotSwitch pSwitch = (PlotSwitch)list.next(); 00149 if ((pSwitch.getGeneratorName()==null) && (pSwitch.getParameterName()==null)){ 00150 proc = pSwitch.getMCProcessType(); 00151 00152 if (this.getCollisionId()!=proc.getCollision().getId()){ 00153 throw new JetWebException("Inconsistent plot switch for for plotId=" 00154 +this.getId(),"collisionId:" 00155 +proc.getCollision().getId()); 00156 } 00157 return proc; 00158 } 00159 } 00160 } 00161 // If we get here, there is no default plotSwitch and no existing processType. 00162 proc = PlotSwitch.defaultProc(new Collision(getCollisionId())); 00163 return proc; 00164 } 00165 00170 public boolean equals(RealPlot rp){ 00171 return (csnId==rp.getId()); 00172 } 00173 00177 public int getProcIdWanted() throws JetWebException { 00178 throw new 00179 JetWebException("RealPlot","getProcIdWanted() not implemented."); 00180 } 00181 00187 public void delete() throws JetWebException { 00188 00189 DBPlotManager.delete(this); 00190 00191 } 00192 } 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209
Generated Wed Jan 17 09:14:27 GMT 2007