Changeset 4439


Ignore:
Timestamp:
Mar 11, 2013, 12:23:25 PM (10 years ago)
Author:
olle
Message:

Refs #799. Proteios SE spectrum viewer updated to indicate the zoom region with a gray rectangle in the original spectrum, in case both a zoomed and original spectrum are shown:

  1. Class/file action/peakList/PeakAnnotationUtil.java in client/servlet/ is updated with a new public method void markZoomMassRange(BufferedImage image, Double massCutoffMin, Double massCutoffMax), that marks a mass region by drawing a rectangle in an existing mass spectrum image. It obtains values of the lowest and highest masses in the spectrum, as well as the spectrum area left and right offsets in pixels from values of instance variables, so these must have been set before the method is called. Existing public method void annotateMassValues(BufferedImage image, SpectrumInterface spectrum) is updated to set these values, since it is normally called before the new method.
  2. Classes/files action/peakList/PlotFileSpectrum.java and action/peakList/PlotSpectrum.java, both in client/servlet/, are updated in protected method void runMe() to obtain value of new valid parameter VBoolean VMASSCUTOFFMARKUPONLY and if its value is true, ignore the cutoff values when obtaining the spectra (i.e. this spectra is not zoomed), and call method void markZoomMassRange(BufferedImage image, Double massCutoffMin, Double massCutoffMax) in the PeakAnnotationUtil object used to annotate the spectrum.
  3. Classes/files action/file/InspectActiveSpectrumFile.java, action/hit/ViewActiveHitSpectrum.java, action/peakList/ViewActivePeakList.java, and action/spectrumSearch/ViewActivePeptideSearchResult.java, all in client/servlet/, are updated to add mass cutoff values to valid parameters VMASSCUTOFFLOWSTR and VMASSCUTOFFHIGHSTR, and set value of valid parameter VMASSCUTOFFMARKUPONLY to true for the view action used for the original spectrum plot.
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  
    412412            viewOriginalAction.addParameter(PlotFileSpectrum.VSPECTRUMID,
    413413            spectrumId);
     414            viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFLOWSTR,
     415                massCutoffLowStr);
     416            viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFHIGHSTR,
     417                massCutoffHighStr);
     418            viewOriginalAction.addParameter(PlotFileSpectrum.VMASSCUTOFFMARKUPONLY,
     419                true);
    414420            plotOriginal.setViewAction(viewOriginalAction);
    415421            plotOriginal.setHeight(PlotFileSpectrum.HEIGHT);
  • trunk/client/servlet/src/org/proteios/action/hit/ViewActiveHitSpectrum.java

    r4436 r4439  
    246246        viewOriginalAction.addParameter(FormFactory.VID, hitPeakListFileId);
    247247        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);
    248254        plotOriginal.setViewAction(viewOriginalAction);
    249255        plotOriginal.setHeight(PlotFileSpectrum.HEIGHT);
  • trunk/client/servlet/src/org/proteios/action/peakList/PeakAnnotationUtil.java

    r4435 r4439  
    3333
    3434import static java.awt.Color.BLUE;
     35import static java.awt.Color.GRAY;
    3536import java.awt.Graphics2D;
    3637import java.awt.image.BufferedImage;
     
    316317      graphics.drawString(massStr, xCoord, (height - yCoord));
    317318    }
     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);
    318417  }
    319418
  • trunk/client/servlet/src/org/proteios/action/peakList/PlotFileSpectrum.java

    r4435 r4439  
    5050import se.lu.thep.waf.ActionException;
    5151import se.lu.thep.waf.constraints.InvalidParameterValue;
     52import se.lu.thep.waf.constraints.VBoolean;
    5253import se.lu.thep.waf.constraints.VFloat;
    5354import se.lu.thep.waf.constraints.VString;
     
    6768  public static final VString VMASSCUTOFFLOWSTR = MassRangeForm.VMASSCUTOFFLOWSTR;
    6869  public static final VString VMASSCUTOFFHIGHSTR = MassRangeForm.VMASSCUTOFFHIGHSTR;
     70  public static final VBoolean VMASSCUTOFFMARKUPONLY = new VBoolean("massCutoffMarkupOnly", false);
    6971  private int spectrumOffsetLeft = -1;
    7072  private int spectrumOffsetRight = -1;
     
    199201          massCutoffHigh = massCutoffLowTmp;
    200202        }
     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        }
    201209        log.debug("fileId = " + peakListFileId);
    202210        log.debug("spectrumId = \"" + spectrumId + "\"");
     
    205213        log.debug("massCutoffLow = " + massCutoffLow);
    206214        log.debug("massCutoffHigh = " + massCutoffHigh);
     215        log.debug("massCutoffMarkupOnly = " + massCutoffMarkupOnly);
    207216        /***********************************************************************
    208217            * Get peakListFile data
     
    271280            log.debug("useTitle = " + useTitle + " spectrumId = \"" + spectrumId + "\"");
    272281            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            }
    275287            if (spectrum != null)
    276288            {
     
    333345        PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil();
    334346        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        }
    335362        /***********************************************************************
    336363            * Send plot
  • trunk/client/servlet/src/org/proteios/action/peakList/PlotSpectrum.java

    r4435 r4439  
    4545import se.lu.thep.waf.ActionException;
    4646import se.lu.thep.waf.constraints.InvalidParameterValue;
     47import se.lu.thep.waf.constraints.VBoolean;
    4748import se.lu.thep.waf.constraints.VString;
    4849import java.awt.image.BufferedImage;
     
    6566  public static final VString VMASSCUTOFFLOWSTR = new VString("massCutoffLowStr", 0, 255, false);
    6667  public static final VString VMASSCUTOFFHIGHSTR = new VString("massCutoffHighStr", 0, 255, false);
     68  public static final VBoolean VMASSCUTOFFMARKUPONLY = new VBoolean("massCutoffMarkupOnly", false);
    6769  private int spectrumOffsetLeft = -1;
    6870  private int spectrumOffsetRight = -1;
     
    183185      massCutoffHigh = massCutoffLowTmp;
    184186    }
     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        }
    185193    log.debug("peakListId = " + peakListId);
    186194    log.debug("massCutoffLowStr = \"" + massCutoffLowStr + "\"");
     
    188196    log.debug("massCutoffLow = " + massCutoffLow);
    189197    log.debug("massCutoffHigh = " + massCutoffHigh);
     198        log.debug("massCutoffMarkupOnly = " + massCutoffMarkupOnly);
    190199    DbControl dc = newDbControl();
    191200    PeakList pl = PeakList.getById(dc, peakListId);
     
    228237    }
    229238    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        }
    232244    if (spectrum != null)
    233245    {
     
    295307    PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil();
    296308    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        }
    297324    /***********************************************************************
    298325     * Send plot
  • trunk/client/servlet/src/org/proteios/action/peakList/ViewActivePeakList.java

    r4436 r4439  
    131131            PlotSpectrum.class, "ViewOriginal");
    132132            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);
    133139            plotOriginal.setViewAction(viewOriginalAction);
    134140            plotOriginal.setHeight(PlotSpectrum.HEIGHT);
  • trunk/client/servlet/src/org/proteios/action/spectrumSearch/ViewActivePeptideSearchResult.java

    r4436 r4439  
    198198                viewOriginalAction.addParameter(FormFactory.VID, peakListFile.getId());
    199199                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);
    200206                plotOriginal.setViewAction(viewOriginalAction);
    201207                plotOriginal.setHeight(PlotFileSpectrum.HEIGHT);
Note: See TracChangeset for help on using the changeset viewer.