use of net.sf.mzmine.parameters.parametertypes.DoubleParameter in project mzmine2 by mzmine.
the class UserParameterOpenHandler_2_3 method startElement.
/**
* @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String,
* java.lang.String, org.xml.sax.Attributes)
*/
public void startElement(String namespaceURI, String lName, String qName, Attributes attrs) throws SAXException {
if (canceled)
throw new SAXException("Parsing canceled");
// <PARAMETERS>
if (qName.equals(UserParameterElementName_2_3.PARAMETERS.getElementName())) {
String count = attrs.getValue(UserParameterElementName_2_3.COUNT.getElementName());
totalParams = Integer.parseInt(count);
}
// <PARAMETER>
if (qName.equals(UserParameterElementName_2_3.PARAMETER.getElementName())) {
String name = attrs.getValue(UserParameterElementName_2_3.NAME.getElementName());
String type = attrs.getValue(UserParameterElementName_2_3.TYPE.getElementName());
if (type.equals(DoubleParameter.class.getSimpleName())) {
currentParameter = new DoubleParameter(name, null);
} else if (type.equals(StringParameter.class.getSimpleName())) {
currentParameter = new StringParameter(name, null);
} else if (type.equals(ComboParameter.class.getSimpleName())) {
currentParameter = new ComboParameter<String>(name, null, new String[0]);
} else {
throw new SAXException("Unknown parameter type: " + type);
}
logger.finest("Loading parameter " + name);
currentOptions.clear();
currentValues.clear();
}
// <VALUE>
if (qName.equals(UserParameterElementName_2_3.VALUE.getElementName())) {
currentDataFileID = attrs.getValue(UserParameterElementName_2_3.DATA_FILE.getElementName());
}
}
use of net.sf.mzmine.parameters.parametertypes.DoubleParameter in project mzmine2 by mzmine.
the class UserParameterOpenHandler_2_5 method endElement.
/**
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String,
* java.lang.String)
*/
@SuppressWarnings("unchecked")
public void endElement(String namespaceURI, String sName, String qName) throws SAXException {
if (canceled)
throw new SAXException("Parsing canceled");
// <OPTION>
if (qName.equals(UserParameterElementName_2_5.OPTION.getElementName())) {
String optionValue = getTextOfElement();
currentOptions.add(optionValue);
}
// <VALUE>
if (qName.equals(UserParameterElementName_2_5.VALUE.getElementName())) {
RawDataFile currentDataFile = dataFilesIDMap.get(currentDataFileID);
String valueString = getTextOfElement();
Object value;
if (currentParameter instanceof DoubleParameter) {
value = new Double(valueString);
} else
value = valueString;
currentValues.put(currentDataFile, value);
}
// <PARAMETER>
if (qName.equals(UserParameterElementName_2_5.PARAMETER.getElementName())) {
if (currentParameter instanceof ComboParameter) {
String[] newChoices = currentOptions.toArray(new String[0]);
((ComboParameter<String>) currentParameter).setChoices(newChoices);
}
newProject.addParameter(currentParameter);
for (RawDataFile dataFile : currentValues.keySet()) {
Object value = currentValues.get(dataFile);
newProject.setParameterValue(currentParameter, dataFile, value);
}
parsedParams++;
}
}
use of net.sf.mzmine.parameters.parametertypes.DoubleParameter in project mzmine2 by mzmine.
the class UserParameterOpenHandler_2_5 method startElement.
/**
* @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String,
* java.lang.String, org.xml.sax.Attributes)
*/
public void startElement(String namespaceURI, String lName, String qName, Attributes attrs) throws SAXException {
if (canceled)
throw new SAXException("Parsing canceled");
// <PARAMETERS>
if (qName.equals(UserParameterElementName_2_5.PARAMETERS.getElementName())) {
String count = attrs.getValue(UserParameterElementName_2_5.COUNT.getElementName());
totalParams = Integer.parseInt(count);
}
// <PARAMETER>
if (qName.equals(UserParameterElementName_2_5.PARAMETER.getElementName())) {
String name = attrs.getValue(UserParameterElementName_2_5.NAME.getElementName());
String type = attrs.getValue(UserParameterElementName_2_5.TYPE.getElementName());
if (type.equals(DoubleParameter.class.getSimpleName())) {
currentParameter = new DoubleParameter(name, null);
} else if (type.equals(StringParameter.class.getSimpleName())) {
currentParameter = new StringParameter(name, null);
} else if (type.equals(ComboParameter.class.getSimpleName())) {
currentParameter = new ComboParameter<String>(name, null, new String[0]);
} else {
throw new SAXException("Unknown parameter type: " + type);
}
logger.finest("Loading parameter " + name);
currentOptions.clear();
currentValues.clear();
}
// <VALUE>
if (qName.equals(UserParameterElementName_2_5.VALUE.getElementName())) {
currentDataFileID = attrs.getValue(UserParameterElementName_2_5.DATA_FILE.getElementName());
}
}
use of net.sf.mzmine.parameters.parametertypes.DoubleParameter in project mzmine2 by mzmine.
the class MsMsVisualizerWindow method actionPerformed.
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("SHOW_SPECTRUM")) {
CursorPosition pos = getCursorPosition();
if (pos != null) {
SpectraVisualizerModule.showNewSpectrumWindow(pos.getDataFile(), pos.getScanNumber());
}
}
if (command.equals("SETUP_AXES")) {
AxesSetupDialog dialog = new AxesSetupDialog(this, IDAPlot.getXYPlot());
dialog.setVisible(true);
}
if (command.equals("SHOW_DATA_POINTS")) {
IDAPlot.switchDataPointsVisible();
}
if (command.equals("SWITCH_TOOLTIPS")) {
if (tooltipMode) {
IDAPlot.showPeaksTooltips(false);
toolBar.setTooltipButton(false);
tooltipMode = false;
} else {
IDAPlot.showPeaksTooltips(true);
toolBar.setTooltipButton(true);
tooltipMode = true;
}
}
if (command.equals("FIND_SPECTRA")) {
// Parameters
final DoubleParameter inputMZ = new DoubleParameter("Ion m/z", "m/z value of ion to search for.");
final MZToleranceParameter inputMZTolerance = new MZToleranceParameter();
final DoubleParameter inputIntensity = new DoubleParameter("Min. ion intensity", "Only ions with intensities above this value will be searched for.");
final BooleanParameter inputNL = new BooleanParameter("Neutral Loss", "If selected, the ion to be searched for will be a neutral loss ion.\nIn this case, only ions above the min. intensity will be examined.", false);
final ComboParameter<Colors> inputColors = new ComboParameter<Colors>("Color", "The color which the data points will be marked with.", Colors.values());
Parameter<?>[] parameters = new Parameter<?>[5];
parameters[0] = inputMZ;
parameters[1] = inputMZTolerance;
parameters[2] = inputIntensity;
parameters[3] = inputNL;
parameters[4] = inputColors;
final ParameterSet parametersSearch = new SimpleParameterSet(parameters);
ExitCode exitCode = parametersSearch.showSetupDialog(this, true);
if (exitCode != ExitCode.OK)
return;
double searchMZ = parametersSearch.getParameter(inputMZ).getValue();
MZTolerance searchMZTolerance = parametersSearch.getParameter(inputMZTolerance).getValue();
double minIntensity = parametersSearch.getParameter(inputIntensity).getValue();
boolean neutralLoss = parametersSearch.getParameter(inputNL).getValue();
Color highligtColor = Color.red;
;
if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.green)) {
highligtColor = Color.green;
}
if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.blue)) {
highligtColor = Color.blue;
}
// Find and highlight spectra with specific ion
dataset.highlightSpectra(searchMZ, searchMZTolerance, minIntensity, neutralLoss, highligtColor);
// Add legend entry
LegendItemCollection chartLegend = IDAPlot.getXYPlot().getLegendItems();
chartLegend.add(new LegendItem("Ion: " + searchMZ, "", "MS/MS spectra which contain the " + searchMZ + " ion\nTolerance: " + searchMZTolerance.toString() + "\nMin intensity: " + minIntensity, "", new Ellipse2D.Double(0, 0, 7, 7), highligtColor));
IDAPlot.getXYPlot().setFixedLegendItems(chartLegend);
}
}
use of net.sf.mzmine.parameters.parametertypes.DoubleParameter in project mzmine2 by mzmine.
the class AddProjectParameterDialog method actionPerformed.
public void actionPerformed(ActionEvent actionEvent) {
Object src = actionEvent.getSource();
Desktop desktop = MZmineCore.getDesktop();
if (src == buttonAddParameter) {
if (fieldName.getText().length() == 0) {
desktop.displayErrorMessage(this, "Give a name for the parameter first.");
return;
}
String paramName = fieldName.getText();
UserParameter<?, ?> parameter = null;
if (radiobuttonNumerical.isSelected()) {
parameter = new DoubleParameter(paramName, null);
}
if (radiobuttonFreeText.isSelected()) {
parameter = new StringParameter(paramName, null);
}
if (radiobuttonCategorical.isSelected()) {
String[] possibleValues = new String[categories.size()];
if (possibleValues.length == 0) {
desktop.displayErrorMessage(this, "Give at least a single parameter value.");
return;
}
for (int valueIndex = 0; valueIndex < categories.size(); valueIndex++) possibleValues[valueIndex] = (String) categories.get(valueIndex);
parameter = new ComboParameter<String>(paramName, null, possibleValues);
}
mainDialog.addParameter(parameter);
dispose();
}
if (src == buttonCancel) {
dispose();
}
if ((src == radiobuttonNumerical) || (src == radiobuttonCategorical) || (src == radiobuttonFreeText)) {
if (radiobuttonCategorical.isSelected()) {
switchCategoricalFields(true);
} else {
switchCategoricalFields(false);
}
}
if (src == buttonAddCategory) {
String inputValue = JOptionPane.showInputDialog("Please input a new value");
if ((inputValue == null) || (inputValue.trim().length() == 0))
return;
if (((DefaultListModel<String>) listCategories.getModel()).contains(inputValue)) {
desktop.displayErrorMessage(this, "Value already exists.");
return;
}
((DefaultListModel<String>) listCategories.getModel()).addElement(inputValue);
}
if (src == buttonRemoveCategory) {
int[] selectedIndices = listCategories.getSelectedIndices();
if ((selectedIndices == null) || (selectedIndices.length == 0)) {
desktop.displayErrorMessage(this, "Select at least one value first.");
return;
}
for (int selectedIndex : selectedIndices) {
((DefaultListModel<String>) listCategories.getModel()).removeElementAt(selectedIndex);
}
}
}
Aggregations