Search in sources :

Example 1 with SearchDefinition

use of net.sf.mzmine.util.SearchDefinition in project mzmine2 by mzmine.

the class ScatterPlotBottomPanel method actionPerformed.

public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("DATA_CHANGE")) {
        ScatterPlotAxisSelection optionX = (ScatterPlotAxisSelection) comboX.getSelectedItem();
        ScatterPlotAxisSelection optionY = (ScatterPlotAxisSelection) comboY.getSelectedItem();
        if ((optionX == null) || (optionY == null))
            return;
        String foldText = foldXvalues[comboFold.getSelectedIndex()];
        int foldValue = Integer.parseInt(foldText);
        if (foldValue <= 0)
            foldValue = 2;
        chart.setDisplayedAxes(optionX, optionY, foldValue);
        return;
    }
    if (command.equals("LABEL_ITEMS")) {
        chart.setItemLabels(labeledItems.isSelected());
    }
    if (command.equals("SEARCH")) {
        SearchDefinitionType searchType = (SearchDefinitionType) comboSearchDataType.getSelectedItem();
        String searchRegex = txtSearchField.getText();
        Number minValue = ((Number) minSearchField.getValue());
        if (minValue == null)
            minValue = 0;
        Number maxValue = ((Number) maxSearchField.getValue());
        if (maxValue == null)
            maxValue = 0;
        Range<Double> searchRange = Range.closed(minValue.doubleValue(), maxValue.doubleValue());
        try {
            SearchDefinition newSearch = new SearchDefinition(searchType, searchRegex, searchRange);
            chart.updateSearchDefinition(newSearch);
        } catch (PatternSyntaxException pe) {
            MZmineCore.getDesktop().displayErrorMessage(window, "The regular expression's syntax is invalid: " + pe);
        }
        return;
    }
    if (command.equals("SEARCH_DATA_TYPE")) {
        SearchDefinitionType searchType = (SearchDefinitionType) comboSearchDataType.getSelectedItem();
        switch(searchType) {
            case MASS:
                minSearchField.setVisible(true);
                maxSearchField.setVisible(true);
                labelRange.setVisible(true);
                txtSearchField.setVisible(false);
                NumberFormat mzFormatter = MZmineCore.getConfiguration().getMZFormat();
                Range<Double> mzRange = peakList.getRowsMZRange();
                DefaultFormatterFactory mzFormatFac = new DefaultFormatterFactory(new NumberFormatter(mzFormatter));
                minSearchField.setFormatterFactory(mzFormatFac);
                minSearchField.setValue(mzRange.lowerEndpoint());
                maxSearchField.setFormatterFactory(mzFormatFac);
                maxSearchField.setValue(mzRange.upperEndpoint());
                break;
            case RT:
                minSearchField.setVisible(true);
                maxSearchField.setVisible(true);
                labelRange.setVisible(true);
                txtSearchField.setVisible(false);
                NumberFormat rtFormatter = MZmineCore.getConfiguration().getRTFormat();
                Range<Double> rtRange = peakList.getRowsRTRange();
                DefaultFormatterFactory rtFormatFac = new DefaultFormatterFactory(new NumberFormatter(rtFormatter));
                minSearchField.setFormatterFactory(rtFormatFac);
                minSearchField.setValue(rtRange.lowerEndpoint());
                maxSearchField.setFormatterFactory(rtFormatFac);
                maxSearchField.setValue(rtRange.upperEndpoint());
                break;
            case NAME:
                minSearchField.setVisible(false);
                maxSearchField.setVisible(false);
                labelRange.setVisible(false);
                txtSearchField.setVisible(true);
                break;
        }
        return;
    }
}
Also used : SearchDefinitionType(net.sf.mzmine.util.SearchDefinitionType) DefaultFormatterFactory(javax.swing.text.DefaultFormatterFactory) SearchDefinition(net.sf.mzmine.util.SearchDefinition) PatternSyntaxException(java.util.regex.PatternSyntaxException) NumberFormat(java.text.NumberFormat) NumberFormatter(javax.swing.text.NumberFormatter)

Aggregations

NumberFormat (java.text.NumberFormat)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 DefaultFormatterFactory (javax.swing.text.DefaultFormatterFactory)1 NumberFormatter (javax.swing.text.NumberFormatter)1 SearchDefinition (net.sf.mzmine.util.SearchDefinition)1 SearchDefinitionType (net.sf.mzmine.util.SearchDefinitionType)1