Changeset 4439
- Timestamp:
- Mar 11, 2013, 12:23:25 PM (10 years ago)
- Location:
- trunk/client/servlet/src/org/proteios/action
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/servlet/src/org/proteios/action/file/InspectActiveSpectrumFile.java
r4436 r4439 412 412 viewOriginalAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 413 413 spectrumId); 414 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFLOWSTR, 415 massCutoffLowStr); 416 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFHIGHSTR, 417 massCutoffHighStr); 418 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFMARKUPONLY, 419 true); 414 420 plotOriginal.setViewAction(viewOriginalAction); 415 421 plotOriginal.setHeight(PlotFileSpectrum.HEIGHT); -
trunk/client/servlet/src/org/proteios/action/hit/ViewActiveHitSpectrum.java
r4436 r4439 246 246 viewOriginalAction.addParameter(FormFactory.VID, hitPeakListFileId); 247 247 viewOriginalAction.addParameter(PlotFileSpectrum.VSPECTRUMID, spectrumId); 248 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFLOWSTR, 249 massCutoffLowStr); 250 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFHIGHSTR, 251 massCutoffHighStr); 252 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFMARKUPONLY, 253 true); 248 254 plotOriginal.setViewAction(viewOriginalAction); 249 255 plotOriginal.setHeight(PlotFileSpectrum.HEIGHT); -
trunk/client/servlet/src/org/proteios/action/peakList/PeakAnnotationUtil.java
r4435 r4439 33 33 34 34 import static java.awt.Color.BLUE; 35 import static java.awt.Color.GRAY; 35 36 import java.awt.Graphics2D; 36 37 import java.awt.image.BufferedImage; … … 316 317 graphics.drawString(massStr, xCoord, (height - yCoord)); 317 318 } 319 // Set spectrum offset left and right pixel values 320 setSpectrumOffsetLeft(xSpectrumOffsetLeft); 321 setSpectrumOffsetRight(xSpectrumOffsetRight); 322 // Set spectrum limit mass min and max values 323 setSpectrumLimitMassMin(massMin); 324 setSpectrumLimitMassMax(massMax); 325 } 326 327 328 /** 329 * Marks a mass region by drawing a rectangle 330 * in an existing mass spectrum image. 331 * 332 * @param image BufferedImage Input mass spectrum image to mark mass region in. 333 * @param massCutoffMin Double The low mass cutoff value for the markup region. 334 * @param massCutoffMax Double The high mass cutoff value for the markup region. 335 */ 336 public void markZoomMassRange(BufferedImage image, Double massCutoffMin, Double massCutoffMax) 337 { 338 // If no mass spectrum image, return directly 339 if (image == null) 340 { 341 return; 342 } 343 // Get spectrum offset left and right pixel values 344 int xSpectrumOffsetLeft = getSpectrumOffsetLeft(); 345 int xSpectrumOffsetRight = getSpectrumOffsetRight(); 346 // Get spectrum limit mass min and max values 347 Double massMin = getSpectrumLimitMassMin(); 348 Double massMax = getSpectrumLimitMassMax(); 349 // If any other input value is missing, return directly 350 if (massCutoffMin == null || massCutoffMax == null || massMin == null || massMax == null || xSpectrumOffsetLeft < 0 || xSpectrumOffsetRight < 0) 351 { 352 return; 353 } 354 // 355 double massRange = 1.0; 356 if (massMin < massMax) 357 { 358 massRange = massMax - massMin; 359 } 360 log.debug("massMin = " + massMin + " massMax = " + massMax + " massRange = " + massRange); 361 /* 362 * The positioning of mass value markers above (or near) 363 * the top of a mass spectrum peak is determined by 364 * a type of dead reckoning, as use of the JFreeChart 365 * package to draw the mass spectra itself does not 366 * give any feedback for the position of the top of 367 * a mass peak, which depends on the offsets of the 368 * spectrum drawing area in the image, when space for 369 * scales and labels have been allocated. The available 370 * input are the width and height of the image, plus 371 * the mass and intensity values of the spectra. 372 * Based on the graphical output for typical standard 373 * choices of spectra, the needed offsets have been 374 * determined by trial and error to a degree that 375 * hopefully is sufficient for an adequate placement 376 * of the markers. 377 */ 378 /* 379 * The following offsets are based on the following input: 380 * width = 400 381 * height = 300 382 * min mass = 110 383 * max mass = 1022 384 * max intensity = 3361 385 */ 386 // Use coordinate system with origin at lower left corner 387 int width = image.getWidth(); 388 int height = image.getHeight(); 389 // Offsets in pixels for inner drawing area without scales and labels 390 //int xInnerAreaOffsetLeft = 58; 391 //int xInnerAreaOffsetRight = 12; 392 int yInnerAreaOffsetBottom = 36; 393 int yInnerAreaOffsetTop = 30; 394 // Offsets in pixels for mass spectrum area relative to inner drawing area 395 //int xInnerAreaFirstPeakOffset = 18; 396 //int xInnerAreaLastPeakOffset = 13; 397 int yInnerAreaPeakBottomOffset = 0; 398 int yInnerAreaPeakTopOffset = 10; 399 // Offsets in pixels for mass spectrum area relative to full drawing area 400 int ySpectrumOffsetBottom = yInnerAreaOffsetBottom + yInnerAreaPeakBottomOffset; 401 int ySpectrumOffsetTop = yInnerAreaOffsetTop + yInnerAreaPeakTopOffset; 402 int spectrumAreaWidth = width - xSpectrumOffsetLeft - xSpectrumOffsetRight; 403 int spectrumAreaHeight = height - ySpectrumOffsetBottom - ySpectrumOffsetTop; 404 log.debug("width = " + width + " height = " + height); 405 log.debug("spectrumAreaWidth = " + spectrumAreaWidth + " spectrumAreaHeight = " + spectrumAreaHeight); 406 int xCutoffMinCoord = xSpectrumOffsetLeft + (int) (spectrumAreaWidth*((massCutoffMin - massMin)/massRange)); 407 int xCutoffMaxCoord = xSpectrumOffsetLeft + (int) (spectrumAreaWidth*((massCutoffMax - massMin)/massRange)); 408 // Prepare to add mass value annotations to mass spectrum image 409 Graphics2D graphics = image.createGraphics(); 410 // Copy original buffer 411 graphics.drawImage(image, 0, 0, null, null); 412 graphics.setColor(GRAY); 413 // Draw rectangle containing zoom region 414 int zoomRectWidth = xCutoffMaxCoord - xCutoffMinCoord; 415 int zoomRectHeight = height - yInnerAreaOffsetBottom - yInnerAreaOffsetTop - 2; 416 graphics.drawRect(xCutoffMinCoord, yInnerAreaOffsetTop - 3, zoomRectWidth, zoomRectHeight); 318 417 } 319 418 -
trunk/client/servlet/src/org/proteios/action/peakList/PlotFileSpectrum.java
r4435 r4439 50 50 import se.lu.thep.waf.ActionException; 51 51 import se.lu.thep.waf.constraints.InvalidParameterValue; 52 import se.lu.thep.waf.constraints.VBoolean; 52 53 import se.lu.thep.waf.constraints.VFloat; 53 54 import se.lu.thep.waf.constraints.VString; … … 67 68 public static final VString VMASSCUTOFFLOWSTR = MassRangeForm.VMASSCUTOFFLOWSTR; 68 69 public static final VString VMASSCUTOFFHIGHSTR = MassRangeForm.VMASSCUTOFFHIGHSTR; 70 public static final VBoolean VMASSCUTOFFMARKUPONLY = new VBoolean("massCutoffMarkupOnly", false); 69 71 private int spectrumOffsetLeft = -1; 70 72 private int spectrumOffsetRight = -1; … … 199 201 massCutoffHigh = massCutoffLowTmp; 200 202 } 203 // Get flag to only use mass cutoff values for markup 204 Boolean massCutoffMarkupOnly = getValidBoolean(VMASSCUTOFFMARKUPONLY); 205 if (massCutoffMarkupOnly == null) 206 { 207 massCutoffMarkupOnly = false; 208 } 201 209 log.debug("fileId = " + peakListFileId); 202 210 log.debug("spectrumId = \"" + spectrumId + "\""); … … 205 213 log.debug("massCutoffLow = " + massCutoffLow); 206 214 log.debug("massCutoffHigh = " + massCutoffHigh); 215 log.debug("massCutoffMarkupOnly = " + massCutoffMarkupOnly); 207 216 /*********************************************************************** 208 217 * Get peakListFile data … … 271 280 log.debug("useTitle = " + useTitle + " spectrumId = \"" + spectrumId + "\""); 272 281 spectrum = peakListFileReader.getSpectrum(spectrumId); 273 // Restrict spectrum to specified mass range, if defined 274 spectrum = zoomSpectrum(spectrum, massCutoffLow, massCutoffHigh); 282 if (!massCutoffMarkupOnly) 283 { 284 // Restrict spectrum to specified mass range, if defined 285 spectrum = zoomSpectrum(spectrum, massCutoffLow, massCutoffHigh); 286 } 275 287 if (spectrum != null) 276 288 { … … 333 345 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 334 346 peakAnnotationUtil.annotateMassValues(image, spectrum); 347 // Mark zoom region if requested 348 if (massCutoffMarkupOnly) 349 { 350 Double massCutoffLowDbl = null; 351 Double massCutoffHighDbl = null; 352 if (massCutoffLow != null) 353 { 354 massCutoffLowDbl = Double.valueOf((double)massCutoffLow); 355 } 356 if (massCutoffHigh != null) 357 { 358 massCutoffHighDbl = Double.valueOf((double)massCutoffHigh); 359 } 360 peakAnnotationUtil.markZoomMassRange(image, massCutoffLowDbl, massCutoffHighDbl); 361 } 335 362 /*********************************************************************** 336 363 * Send plot -
trunk/client/servlet/src/org/proteios/action/peakList/PlotSpectrum.java
r4435 r4439 45 45 import se.lu.thep.waf.ActionException; 46 46 import se.lu.thep.waf.constraints.InvalidParameterValue; 47 import se.lu.thep.waf.constraints.VBoolean; 47 48 import se.lu.thep.waf.constraints.VString; 48 49 import java.awt.image.BufferedImage; … … 65 66 public static final VString VMASSCUTOFFLOWSTR = new VString("massCutoffLowStr", 0, 255, false); 66 67 public static final VString VMASSCUTOFFHIGHSTR = new VString("massCutoffHighStr", 0, 255, false); 68 public static final VBoolean VMASSCUTOFFMARKUPONLY = new VBoolean("massCutoffMarkupOnly", false); 67 69 private int spectrumOffsetLeft = -1; 68 70 private int spectrumOffsetRight = -1; … … 183 185 massCutoffHigh = massCutoffLowTmp; 184 186 } 187 // Get flag to only use mass cutoff values for markup 188 Boolean massCutoffMarkupOnly = getValidBoolean(VMASSCUTOFFMARKUPONLY); 189 if (massCutoffMarkupOnly == null) 190 { 191 massCutoffMarkupOnly = false; 192 } 185 193 log.debug("peakListId = " + peakListId); 186 194 log.debug("massCutoffLowStr = \"" + massCutoffLowStr + "\""); … … 188 196 log.debug("massCutoffLow = " + massCutoffLow); 189 197 log.debug("massCutoffHigh = " + massCutoffHigh); 198 log.debug("massCutoffMarkupOnly = " + massCutoffMarkupOnly); 190 199 DbControl dc = newDbControl(); 191 200 PeakList pl = PeakList.getById(dc, peakListId); … … 228 237 } 229 238 SpectrumInterface spectrum = null; 230 // Restrict spectrum to specified mass range, if defined 231 spectrum = zoomSpectrum(spectrumOrig, massCutoffLow, massCutoffHigh); 239 if (!massCutoffMarkupOnly) 240 { 241 // Restrict spectrum to specified mass range, if defined 242 spectrum = zoomSpectrum(spectrum, massCutoffLow, massCutoffHigh); 243 } 232 244 if (spectrum != null) 233 245 { … … 295 307 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 296 308 peakAnnotationUtil.annotateMassValues(image, spectrum); 309 // Mark zoom region if requested 310 if (massCutoffMarkupOnly) 311 { 312 Double massCutoffLowDbl = null; 313 Double massCutoffHighDbl = null; 314 if (massCutoffLow != null) 315 { 316 massCutoffLowDbl = Double.valueOf((double)massCutoffLow); 317 } 318 if (massCutoffHigh != null) 319 { 320 massCutoffHighDbl = Double.valueOf((double)massCutoffHigh); 321 } 322 peakAnnotationUtil.markZoomMassRange(image, massCutoffLowDbl, massCutoffHighDbl); 323 } 297 324 /*********************************************************************** 298 325 * Send plot -
trunk/client/servlet/src/org/proteios/action/peakList/ViewActivePeakList.java
r4436 r4439 131 131 PlotSpectrum.class, "ViewOriginal"); 132 132 viewOriginalAction.addParameter(FormFactory.VID, peakListId); 133 viewOriginalAction.addParameter(PlotSpectrum.VMASSCUTOFFLOWSTR, 134 massCutoffLowStr); 135 viewOriginalAction.addParameter(PlotSpectrum.VMASSCUTOFFHIGHSTR, 136 massCutoffHighStr); 137 viewOriginalAction.addParameter(PlotSpectrum.VMASSCUTOFFMARKUPONLY, 138 true); 133 139 plotOriginal.setViewAction(viewOriginalAction); 134 140 plotOriginal.setHeight(PlotSpectrum.HEIGHT); -
trunk/client/servlet/src/org/proteios/action/spectrumSearch/ViewActivePeptideSearchResult.java
r4436 r4439 198 198 viewOriginalAction.addParameter(FormFactory.VID, peakListFile.getId()); 199 199 viewOriginalAction.addParameter(MassRangeForm.VSPECTRUMID, spectrumId); 200 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFLOWSTR, 201 massCutoffLowStr); 202 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFHIGHSTR, 203 massCutoffHighStr); 204 viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFMARKUPONLY, 205 true); 200 206 plotOriginal.setViewAction(viewOriginalAction); 201 207 plotOriginal.setHeight(PlotFileSpectrum.HEIGHT);
Note: See TracChangeset
for help on using the changeset viewer.