Changeset 3535
- Timestamp:
- Oct 8, 2015, 2:09:21 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/pdf/PilotReportWorker.java
r3533 r3535 1 1 package net.sf.basedb.reggie.pdf; 2 2 3 import java.io.BufferedReader; 3 4 import java.io.File; 4 5 import java.io.FileInputStream; 6 import java.io.FileReader; 5 7 import java.io.IOException; 6 8 import java.io.InputStream; … … 23 25 import net.sf.basedb.core.Extract; 24 26 import net.sf.basedb.core.Sample; 27 import net.sf.basedb.core.Type; 25 28 import net.sf.basedb.reggie.Reggie; 26 29 import net.sf.basedb.reggie.Site; … … 211 214 212 215 // Plots 213 float y = PLOT_START_Y;216 float yPlot = PLOT_START_Y; 214 217 float yText = PLOT_TEXT_START_Y; 215 218 String[] plots = { "GGI", "ESR1", "PGR", "ERBB2", "MKI67" }; 216 219 String[] lowHigh = { "Låg", "Hög" }; 217 String[] positiveNegative = { "Negativ", "Positiv" };220 String[] negativePositive = { "Negativ", "Positiv" }; 218 221 for (int plotNo = 0; plotNo < plots.length; plotNo++) 219 222 { 220 // TODO - the text is from a random number! 221 String[] options = plotNo == 0 || plotNo == 4 ? lowHigh : positiveNegative; 222 pdfUtil.addText(options[Math.random() > 0.5 ? 0 : 1], 14, Element.ALIGN_LEFT, PLOT_TEXT_X, yText); 223 String plot = plots[plotNo]; 224 File plotTxt = new File(workDir, plot+".txt"); 225 float plotScore = parsePlotScore(plotTxt); 226 String[] options = plotNo == 0 || plotNo == 4 ? lowHigh : negativePositive; 227 pdfUtil.addText(Float.isNaN(plotScore) ? "N/A" : options[plotScore < 0 ? 0 : 1], 14, Element.ALIGN_LEFT, PLOT_TEXT_X, yText); 223 228 yText -= PLOT_DELTA_Y; 224 229 225 String plot = plots[plotNo]; 226 File f2 = new File(workDir, plot+".pdf"); 227 if (f2.exists()) 230 File plotPdf = new File(workDir, plot+".pdf"); 231 if (plotPdf.exists()) 228 232 { 229 pdfUtil.importPdf(new FileInputStream(f2), PLOT_X, y, 1.0f, 1.0f); 230 y -= PLOT_DELTA_Y; 233 pdfUtil.importPdf(new FileInputStream(plotPdf), PLOT_X, yPlot, 1.0f, 1.0f); 231 234 } 235 yPlot -= PLOT_DELTA_Y; 232 236 } 233 237 … … 291 295 } 292 296 297 private float parsePlotScore(File plotScore) 298 throws IOException 299 { 300 BufferedReader reader = null; 301 float score = Float.NaN; 302 if (plotScore.exists()) 303 { 304 try 305 { 306 reader = new BufferedReader(new FileReader(plotScore)); 307 score = (float)Type.FLOAT.parseString(reader.readLine()); 308 } 309 finally 310 { 311 FileUtil.close(reader); 312 } 313 } 314 return score; 315 } 316 293 317 /** 294 318 Add personal information to the pilot report.
Note: See TracChangeset
for help on using the changeset viewer.