Changeset 4436


Ignore:
Timestamp:
Mar 8, 2013, 10:08:54 AM (10 years ago)
Author:
olle
Message:

Refs #799. Proteios SE mass spectrum viewer updated to allow a zoom mass range to be set using the mouse:

  1. JavaScript www/static/js/script.js in client/servlet/ updated with two new functions setMouseDownMassCutoffValue(e, inputElName, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax) and setMouseUpMassCutoffValue(e, inputElName, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax) to set the value of the low and high cutoff mass input fields. A number of global variables and help functions are also added, in order to convert a click position to a mass value, and get the functionality of selecting a mass range by either dragging the mouse or clicking on the low and high end masses in the spectrum. Some updates of existing functions were also made, in order to increase the stability of the script.


  1. Classes/files action/file/InspectActiveSpectrumFile.java, action/hit/ViewActiveHitSpectrum.java, action/peakList/ViewActivePeakList.java, and action/spectrumSearch/ViewActivePeptideSearchResult.java, all in client/servlet/, were updated to set the id, ondragstart, onMousedown, and onMouseup attribute values for the spectrum images. Attribute ondragstart is set to "return false;", in order to disable default drag functionality for the browser. Attributes onMousedown and onMouseup are set to call new JavaScript functions setMouseDownMassCutoffValue(...) and setMouseUpMassCutoffValue(...), respectively. The spectrum low and high end masses and pixel offsets are obtained from the spectrum plot object, and transferred to the script functions as arguments. Also, the zoomed spectrum is now shown above the original spectrum.
Location:
trunk/client/servlet
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/file/InspectActiveSpectrumFile.java

    r4031 r4436  
    406406        {
    407407            plotOriginal = new Image();
     408            plotOriginal.setId("msPlotOriginal");
    408409            ActionLink viewOriginalAction = getActionFactory().getActionLink(
    409410            PlotFileSpectrum.class, "ViewOriginal");
     
    418419            fileId, spectrumId, (String) null, (String) null);
    419420            plotOriginal.setImageMap(imageMap);
     421            // Set onMousedown and onMouseup strings
     422            int spectrumOffsetLeft = plotFileSpectrum.getSpectrumOffsetLeft();
     423            int spectrumOffsetRight = plotFileSpectrum.getSpectrumOffsetRight();
     424            Double massMin = plotFileSpectrum.getSpectrumLimitMassMin();
     425            Double massMax = plotFileSpectrum.getSpectrumLimitMassMax();
     426            plotOriginal.setOnDragstartStr("return false;");
     427            plotOriginal.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     428            plotOriginal.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    420429        }
    421430        Image plot = new Image();
     431        plot.setId("msPlot");
    422432        ActionLink viewAction = getActionFactory().getActionLink(
    423433        PlotFileSpectrum.class, "View");
     
    435445        spectrumId, massCutoffLowStr, massCutoffHighStr);
    436446        plot.setImageMap(imageMap);
     447        // Set onMousedown and onMouseup strings
     448        int spectrumOffsetLeft = plotFileSpectrum.getSpectrumOffsetLeft();
     449        int spectrumOffsetRight = plotFileSpectrum.getSpectrumOffsetRight();
     450        Double massMin = plotFileSpectrum.getSpectrumLimitMassMin();
     451        Double massMax = plotFileSpectrum.getSpectrumLimitMassMax();
     452        plot.setOnDragstartStr("return false;");
     453        plot.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     454        plot.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    437455        /***********************************************************************
    438456            * Spectrum iteration buttons
     
    562580        // Row container for plot and properties form
    563581        RowContainer rc = new RowContainer();
     582        rc.add(plot);
    564583        if (plotOriginal != null)
    565584        {
    566585            rc.add(plotOriginal);
    567586        }
    568         rc.add(plot);
    569587        rc.add(spectrumIterationForm);
    570588        rc.add(massRangeSelectionForm);
  • trunk/client/servlet/src/org/proteios/action/hit/ViewActiveHitSpectrum.java

    r4003 r4436  
    241241    {
    242242        plotOriginal = new Image();
     243        plotOriginal.setId("msPlotOriginal");
    243244        ActionLink viewOriginalAction = getActionFactory().getActionLink(
    244245        PlotFileSpectrum.class, "ViewOriginal");
     
    252253        (String) null, (String) null);
    253254        plotOriginal.setImageMap(imageMap);
     255        // Set onMousedown and onMouseup strings
     256        int spectrumOffsetLeft = plotFileSpectrum.getSpectrumOffsetLeft();
     257        int spectrumOffsetRight = plotFileSpectrum.getSpectrumOffsetRight();
     258        Double massMin = plotFileSpectrum.getSpectrumLimitMassMin();
     259        Double massMax = plotFileSpectrum.getSpectrumLimitMassMax();
     260        plotOriginal.setOnDragstartStr("return false;");
     261        plotOriginal.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     262        plotOriginal.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    254263    }
    255264    Image plot = new Image();
     265    plot.setId("msPlot");
    256266    ActionLink viewAction = getActionFactory().getActionLink(
    257267    PlotFileSpectrum.class, "View");
     
    267277    massCutoffLowStr, massCutoffHighStr);
    268278    plot.setImageMap(imageMap);
     279    // Set onMousedown and onMouseup strings
     280    int spectrumOffsetLeft = plotFileSpectrum.getSpectrumOffsetLeft();
     281    int spectrumOffsetRight = plotFileSpectrum.getSpectrumOffsetRight();
     282    Double massMin = plotFileSpectrum.getSpectrumLimitMassMin();
     283    Double massMax = plotFileSpectrum.getSpectrumLimitMassMax();
     284    plot.setOnDragstartStr("return false;");
     285    plot.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     286    plot.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    269287    /***********************************************************************
    270288        * Spectrum mass range selection form
     
    303321    ColumnContainer cc = new ColumnContainer();
    304322    RowContainer rc = new RowContainer();
     323    rc.add(plot);
    305324    if (plotOriginal != null)
    306325    {
    307326        rc.add(plotOriginal);
    308327    }
    309     rc.add(plot);
    310328    rc.add(massRangeSelectionForm);
    311329    cc.add(rc);
  • trunk/client/servlet/src/org/proteios/action/peakList/ViewActivePeakList.java

    r4003 r4436  
    127127        {
    128128            plotOriginal = new Image();
     129            plotOriginal.setId("msPlotOriginal");
    129130            ActionLink viewOriginalAction = getActionFactory().getActionLink(
    130131            PlotSpectrum.class, "ViewOriginal");
     
    137138            (String) null, (String) null);
    138139            plotOriginal.setImageMap(imageMap);
     140            // Set onMousedown and onMouseup strings
     141            int spectrumOffsetLeft = plotSpectrum.getSpectrumOffsetLeft();
     142            int spectrumOffsetRight = plotSpectrum.getSpectrumOffsetRight();
     143            Double massMin = plotSpectrum.getSpectrumLimitMassMin();
     144            Double massMax = plotSpectrum.getSpectrumLimitMassMax();
     145            plotOriginal.setOnDragstartStr("return false;");
     146            plotOriginal.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     147            plotOriginal.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    139148        }
    140149        Image plot = new Image();
     150        plot.setId("msPlot");
    141151        ActionLink viewAction = getActionFactory().getActionLink(
    142152        PlotSpectrum.class, "View");
     
    151161        massCutoffLowStr, massCutoffHighStr);
    152162        plot.setImageMap(imageMap);
     163        // Set onMousedown and onMouseup strings
     164        int spectrumOffsetLeft = plotSpectrum.getSpectrumOffsetLeft();
     165        int spectrumOffsetRight = plotSpectrum.getSpectrumOffsetRight();
     166        Double massMin = plotSpectrum.getSpectrumLimitMassMin();
     167        Double massMax = plotSpectrum.getSpectrumLimitMassMax();
     168        plot.setOnDragstartStr("return false;");
     169        plot.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     170        plot.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    153171        /***********************************************************************
    154172            * Spectrum mass range selection form
     
    174192        ColumnContainer cc = new ColumnContainer();
    175193        RowContainer rc = new RowContainer();
     194        rc.add(plot);
    176195        if (plotOriginal != null)
    177196        {
    178197            rc.add(plotOriginal);
    179198        }
    180         rc.add(plot);
    181         rc.add(massRangeSelectionForm);
     199       rc.add(massRangeSelectionForm);
    182200        cc.add(rc);
    183201        cc.add(propertiesForm);
  • trunk/client/servlet/src/org/proteios/action/spectrumSearch/ViewActivePeptideSearchResult.java

    r4011 r4436  
    193193            {
    194194                plotOriginal = new Image();
     195                plotOriginal.setId("msPlotOriginal");
    195196                ActionLink viewOriginalAction = getActionFactory().getActionLink(
    196197                PlotFileSpectrum.class, "ViewOriginal");
     
    204205                (String) null, (String) null);
    205206                plotOriginal.setImageMap(imageMap);
     207                // Set onMousedown and onMouseup strings
     208                int spectrumOffsetLeft = plotFileSpectrum.getSpectrumOffsetLeft();
     209                int spectrumOffsetRight = plotFileSpectrum.getSpectrumOffsetRight();
     210                Double massMin = plotFileSpectrum.getSpectrumLimitMassMin();
     211                Double massMax = plotFileSpectrum.getSpectrumLimitMassMax();
     212                plotOriginal.setOnDragstartStr("return false;");
     213                plotOriginal.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     214                plotOriginal.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plotOriginal.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    206215            }
    207216            Image plot = new Image();
     217            plot.setId("msPlot");
    208218            ActionLink viewAction = getActionFactory().getActionLink(
    209219            PlotFileSpectrum.class, "View");
     
    219229            massCutoffLowStr, massCutoffHighStr);
    220230            plot.setImageMap(imageMap);
     231            // Set onMousedown and onMouseup strings
     232            int spectrumOffsetLeft = plotFileSpectrum.getSpectrumOffsetLeft();
     233            int spectrumOffsetRight = plotFileSpectrum.getSpectrumOffsetRight();
     234            Double massMin = plotFileSpectrum.getSpectrumLimitMassMin();
     235            Double massMax = plotFileSpectrum.getSpectrumLimitMassMax();
     236            plot.setOnDragstartStr("return false;");
     237            plot.setOnMousedownStr("setMouseDownMassCutoffValue(event, 'massCutoffLowStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
     238            plot.setOnMouseupStr("setMouseUpMassCutoffValue(event, 'massCutoffHighStr', '" + plot.getId() + "', " + PlotFileSpectrum.WIDTH + ", " + spectrumOffsetLeft + ", " + spectrumOffsetRight + ", " + massMin + ", " + massMax + ")");
    221239            // Spectrum mass range selection form
    222240            Form massRangeSelectionForm = new MassRangeForm(massCutoffLowStr, massCutoffHighStr, spectrumId);
     
    233251            // Row container for plot and properties form
    234252            RowContainer rc = new RowContainer();
     253            rc.add(plot);
    235254            if (plotOriginal != null)
    236255            {
    237256                rc.add(plotOriginal);
    238257            }
    239             rc.add(plot);
    240258            rc.add(massRangeSelectionForm);
    241259            cc.add(rc);
  • trunk/client/servlet/www/static/js/script.js

    r4422 r4436  
    5959function getElement(id)
    6060{
    61   return document.all ? document.all[id] : document.getElementById(id);
     61  if (id != null && id != '')
     62  {
     63    return document.all ? document.all[id] : document.getElementById(id);
     64  }
     65  else
     66  {
     67    return null;
     68  }
    6269}
    6370
     
    171178    {
    172179        var tableRows = table.rows;
    173         for(var i = 0; i<tableRows.length;i++)
    174         {
    175             var row = tableRows[i];
    176             addHiliteEvents(row);
     180        if (tableRows != null)
     181        {
     182          for(var i = 0; i<tableRows.length;i++)
     183          {
     184              var row = tableRows[i];
     185              addHiliteEvents(row);
     186          }
    177187        }
    178188    }
     
    385395window.onresize=resize_all_iframes;
    386396
    387 function updateNodeText(nodeId, nodeText)
     397/**
     398 *  Returns a JSON object with element position for upper left corner.
     399 *  Code from http://www.kirupa.com/html5/get_element_position_using_javascript.htm
     400 *
     401 *  @param GUIelement element The GUI element to get the position for.
     402 *  @return JSON object with keys 'x' and 'y' with position values.
     403 */
     404function getElementPosition(element)
     405{
     406  var xPos = 0;
     407  var yPos = 0;
     408  // Add relative offsets for element parents
     409  while (element)
     410  {
     411    xPos += (element.offsetLeft - element.scrollLeft + element.clientLeft);
     412    yPos += (element.offsetTop - element.scrollTop + element.clientTop);
     413    element = element.offsetParent;
     414  }
     415  return {x: xPos, y: yPos};
     416}
     417
     418/**
     419 *  Returns the last element with a given name.
     420 *
     421 *  @param elementName Name of the GUIElements.
     422 *  @return GUIElement The last element with given name.
     423 */
     424function getLastElementByName(elementName)
     425{
     426  var element = null;
     427  if (elementName != null && elementName != '')
     428  {
     429    var elArray = document.getElementsByName(elementName);
     430    if (elArray != null)
     431    {
     432      // Get last element
     433      element = elArray[elArray.length - 1];
     434    }
     435  }
     436  return element;
     437}
     438
     439function updateNodeFirstChildText(nodeId, nodeText)
    388440{
    389441  var node = document.getElementById(nodeId);
     
    474526        }
    475527        // Update table cell data
    476         updateNodeText(cellId, "" + cellData);
     528        updateNodeFirstChildText(cellId, "" + cellData);
    477529      }
    478530    }
     
    485537{
    486538  setInterval('updateJobTableColumns()', 1000*secondsBetweenUpdates);
     539}
     540
     541/**
     542 *  Returns a mass value corresponding to an x-position in a mass spectrum image.
     543 *  Returns null if any argument values are invalid.
     544 *
     545 *  @param e event The event to get position from
     546 *  @param imgId String The element id of the spectrum img tag in the html page
     547 *  @param spectrumWidth int The spectrum width in pixels
     548 *  @param spectrumOffsetLeft int The spectrum offset from the left image border in pixels
     549 *  @param spectrumOffsetRight int The spectrum offset from the right image border in pixels
     550 *  @param massMin double The lowest mass value in the displayed spectrum
     551 *  @param massMax double The highest mass value in the displayed spectrum
     552 */
     553function fetchMassValue(e, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax)
     554{
     555  // Return if basic arguments are missing or have odd values
     556  if (imgId == null || imgId == '' || massMin == null || massMax == null || massMin == massMax)
     557  {
     558    //alert('Returned at check 1');
     559    return null;
     560  }
     561  // Return if effective spectrum width or massrange are <= 0
     562  var spectrumEffWidth = spectrumWidth - spectrumOffsetLeft - spectrumOffsetRight;
     563  var massRange = massMax - massMin;
     564  if (spectrumEffWidth <= 0 || massRange <= 0)
     565  {
     566    //alert('Returned at check 2 spectrumEffWidth = ' + spectrumEffWidth + ' massRange = ' + massRange);
     567    return null;
     568  }
     569  // Get image element
     570  var imgEl = document.getElementById(imgId);
     571  if (imgEl == null)
     572  {
     573    return null;
     574  }
     575  // Get position on page for event
     576  var x = e.pageX;
     577  // Get relative position inside current GUI element
     578  var xRel = 0;
     579  var pos = getElementPosition(imgEl);
     580  xRel = x - pos.x;
     581  var spectrumPixelOffsetLeft = xRel - spectrumOffsetLeft;
     582  var mass = null;
     583  // Return if basic arguments are missing or have odd values
     584  if (massMin == null || massMax == null || massMin == massMax)
     585  {
     586    //alert('Returned at check 3');
     587    return null;
     588  }
     589  // Return if effective spectrum width or massrange are <= 0
     590  var spectrumEffWidth = spectrumWidth - spectrumOffsetLeft - spectrumOffsetRight;
     591  var massRange = massMax - massMin;
     592  if (spectrumEffWidth <= 0 || massRange <= 0)
     593  {
     594    //alert('Returned at check 4 spectrumEffWidth = ' + spectrumEffWidth + ' massRange = ' + massRange);
     595    return null;
     596  }
     597  var spectrumPixelOffsetLeft = xRel - spectrumOffsetLeft;
     598  // Calculate mass value from event pixel coordinate
     599  mass = massMin + (spectrumPixelOffsetLeft/spectrumEffWidth)*massRange;
     600  // Round mass value to nearest integer
     601  mass = Math.floor(mass + 0.5);
     602  return mass;
     603}
     604
     605/**
     606 *  Returns a mass cuttoff string corresponding to an x-position in a mass spectrum image.
     607 *  Returns null if any argument values are invalid.
     608 *
     609 *  @param e event The event to get position from
     610 *  @param inputElName String The element name of the mass cutoff input field in the html page
     611 *  @param imgId String The element id of the spectrum img tag in the html page
     612 *  @param spectrumWidth int The spectrum width in pixels
     613 *  @param spectrumOffsetLeft int The spectrum offset from the left image border in pixels
     614 *  @param spectrumOffsetRight int The spectrum offset from the right image border in pixels
     615 *  @param massMin double The lowest mass value in the displayed spectrum
     616 *  @param massMax double The highest mass value in the displayed spectrum
     617 */
     618function fetchMassCutoffStr(e, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax)
     619{
     620  // Get mass value (equals null if any input argument values are invalid)
     621  var mass =  fetchMassValue(e, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax);
     622  if (mass == null)
     623  {
     624    return null;
     625  }
     626  // Get mass cutoff string
     627  var massCutoffStr = '';
     628  if (mass >= massMin && mass <= massMax)
     629  {
     630    // Mouse event inside spectrum range, set mass value
     631    massCutoffStr = '' + mass;
     632  }
     633  else if (mass < massMin)
     634  {
     635    // Mouse event below spectrum range, set mass value to below lowest mass
     636    massCutoffStr = '' + (massMin - 0.1).toFixed(1);
     637  }
     638  else if (mass > massMax)
     639  {
     640    // Mouse event above spectrum range, set mass value to above highest mass
     641    massCutoffStr = '' + (massMax + 0.1).toFixed(1);
     642  }
     643  return massCutoffStr;
     644}
     645
     646var lastMouseDownMassCutoffStr = '';
     647var isNextClickReservedForMouseUpEvent = false;
     648
     649/**
     650 *  Converts an event in a spectrum image to a mass value and
     651 *  sets mass cutoff value to the found mass.
     652 *  In order to support setting of cutoff masses using
     653 *  two clicks instead of dragging, a mass cutoff
     654 *  value will not be set if isMouseUpMassCutoffValueSet == 0.
     655 *
     656 *  @param e event The event to get position from
     657 *  @param inputElName String The element name of the mass cutoff input field in the html page
     658 *  @param imgId String The element id of the spectrum img tag in the html page
     659 *  @param spectrumWidth int The spectrum width in pixels
     660 *  @param spectrumOffsetLeft int The spectrum offset from the left image border in pixels
     661 *  @param spectrumOffsetRight int The spectrum offset from the right image border in pixels
     662 *  @param massMin double The lowest mass value in the displayed spectrum
     663 *  @param massMax double The highest mass value in the displayed spectrum
     664 */
     665function setMouseDownMassCutoffValue(e, inputElName, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax)
     666{
     667  if (isNextClickReservedForMouseUpEvent)
     668  {
     669    // Mouse click reserved for mouse up event
     670    //alert('setMouseDownMassCutoffValue(): isNextClickReservedForMouseUpEvent = ' + isNextClickReservedForMouseUpEvent);
     671    return;
     672  }
     673  // Prevent default dragging of image in older browsers
     674  e.preventDefault();
     675  if (inputElName == null || inputElName == '')
     676  {
     677    //alert('setMouseDownMassCutoffValue(): inputElName == ' + inputElName);
     678    return;
     679  }
     680  // Get mass cutoff string (equals null if any input argument values are invalid)
     681  var massCutoffStr = fetchMassCutoffStr(e, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax);
     682  if (massCutoffStr == null)
     683  {
     684    //alert('setMouseDownMassCutoffValue(): massCutoffStr == null');
     685    return;
     686  }
     687  // Get input field element
     688  var inputEl = getLastElementByName(inputElName);
     689  if (inputEl == null)
     690  {
     691    //alert('setMouseDownMassCutoffValue(): inputEl == null');
     692    return;
     693  }
     694  // Set input field value
     695  inputEl.value = massCutoffStr;
     696  // Set focus to input field
     697  inputEl.focus();
     698  // Store value set
     699  lastMouseDownMassCutoffStr = massCutoffStr;
     700}
     701
     702/**
     703 *  Converts an event in a spectrum image to a mass value and
     704 *  sets mass cutoff value to the found mass.
     705 *  In order to support setting of cutoff masses using
     706 *  two clicks instead of dragging, a mass cutoff
     707 *  value will not be set if the mass value equals lastMouseDownMassCutoffStr.
     708 *
     709 *  @param e event The event to get position from
     710 *  @param inputElName String The element name of the mass cutoff input field in the html page
     711 *  @param imgId String The element id of the spectrum img tag in the html page
     712 *  @param spectrumWidth int The spectrum width in pixels
     713 *  @param spectrumOffsetLeft int The spectrum offset from the left image border in pixels
     714 *  @param spectrumOffsetRight int The spectrum offset from the right image border in pixels
     715 *  @param massMin double The lowest mass value in the displayed spectrum
     716 *  @param massMax double The highest mass value in the displayed spectrum
     717 */
     718function setMouseUpMassCutoffValue(e, inputElName, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax)
     719{
     720  // Prevent default dragging of image in older browsers
     721  e.preventDefault();
     722  if (inputElName == null || inputElName == '')
     723  {
     724    //alert('setMouseUpMassCutoffValue(): inputElName == ' + inputElName);
     725    return;
     726  }
     727  // Get mass cutoff string (equals null if any input argument values are invalid)
     728  var massCutoffStr = fetchMassCutoffStr(e, imgId, spectrumWidth, spectrumOffsetLeft, spectrumOffsetRight, massMin, massMax);
     729  if (massCutoffStr == null)
     730  {
     731    //alert('setMouseUpMassCutoffValue(): massCutoffStr == null');
     732    return;
     733  }
     734  if (massCutoffStr == lastMouseDownMassCutoffStr)
     735  {
     736    // No drag, mouse click intended for mouse down event
     737    //alert('setMouseDownMassCutoffValue(): massCutoffStr == lastMouseDownMassCutoffStr = ' + massCutoffStr);
     738    isNextClickReservedForMouseUpEvent = true;
     739    return;
     740  }
     741  // Get input field element
     742  var inputEl = getLastElementByName(inputElName);
     743  if (inputEl == null)
     744  {
     745    //alert('setMouseUpMassCutoffValue(): inputEl == null');
     746    return;
     747  }
     748  // Set input field value
     749  inputEl.value = massCutoffStr;
     750  // Set focus to input field
     751  inputEl.focus();
     752  // Set isNextClickReservedForMouseUpEvent to false
     753  isNextClickReservedForMouseUpEvent = false;
    487754}
    488755
Note: See TracChangeset for help on using the changeset viewer.