use of net.sf.mzmine.parameters.impl.SimpleParameterSet in project mzmine2 by mzmine.
the class PeakListsComponent method actionPerformed.
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == detailsButton) {
PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
if (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS) {
final MultiChoiceParameter<PeakList> plsParameter = new MultiChoiceParameter<PeakList>("Select feature lists", "Select feature lists", MZmineCore.getProjectManager().getCurrentProject().getPeakLists(), currentValue.getSpecificPeakLists());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { plsParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
PeakList[] pls = paramSet.getParameter(plsParameter).getValue();
currentValue.setSpecificPeakLists(pls);
}
}
if (type == PeakListsSelectionType.NAME_PATTERN) {
final StringParameter nameParameter = new StringParameter("Name pattern", "Set name pattern that may include wildcards (*), e.g. *mouse* matches any name that contains mouse", currentValue.getNamePattern());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { nameParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
String namePattern = paramSet.getParameter(nameParameter).getValue();
currentValue.setNamePattern(namePattern);
}
}
}
if (src == typeCombo) {
PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
currentValue.setSelectionType(type);
detailsButton.setEnabled((type == PeakListsSelectionType.NAME_PATTERN) || (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS));
}
updateNumPeakLists();
}
use of net.sf.mzmine.parameters.impl.SimpleParameterSet in project mzmine2 by mzmine.
the class RawDataFilesComponent method actionPerformed.
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == detailsButton) {
RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
if (type == RawDataFilesSelectionType.SPECIFIC_FILES) {
final MultiChoiceParameter<RawDataFile> filesParameter = new MultiChoiceParameter<RawDataFile>("Select files", "Select files", MZmineCore.getProjectManager().getCurrentProject().getDataFiles(), currentValue.getSpecificFiles());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { filesParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
RawDataFile[] files = paramSet.getParameter(filesParameter).getValue();
currentValue.setSpecificFiles(files);
}
}
if (type == RawDataFilesSelectionType.NAME_PATTERN) {
final StringParameter nameParameter = new StringParameter("Name pattern", "Set name pattern that may include wildcards (*), e.g. *mouse* matches any name that contains mouse", currentValue.getNamePattern());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { nameParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
String namePattern = paramSet.getParameter(nameParameter).getValue();
currentValue.setNamePattern(namePattern);
}
}
}
if (src == typeCombo) {
RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
currentValue.setSelectionType(type);
detailsButton.setEnabled((type == RawDataFilesSelectionType.NAME_PATTERN) || (type == RawDataFilesSelectionType.SPECIFIC_FILES));
}
updateNumFiles();
}
use of net.sf.mzmine.parameters.impl.SimpleParameterSet in project mzmine2 by mzmine.
the class MZmineConfigurationImpl method loadConfiguration.
@Override
public void loadConfiguration(File file) throws IOException {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document configuration = dBuilder.parse(file);
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
logger.finest("Loading desktop configuration");
XPathExpression expr = xpath.compile("//configuration/preferences");
NodeList nodes = (NodeList) expr.evaluate(configuration, XPathConstants.NODESET);
if (nodes.getLength() == 1) {
Element preferencesElement = (Element) nodes.item(0);
// that needs this key for encryption
if (file.equals(MZmineConfiguration.CONFIG_FILE))
new SimpleParameterSet(new Parameter[] { globalEncrypter }).loadValuesFromXML(preferencesElement);
preferences.loadValuesFromXML(preferencesElement);
}
logger.finest("Loading last projects");
expr = xpath.compile("//configuration/lastprojects");
nodes = (NodeList) expr.evaluate(configuration, XPathConstants.NODESET);
if (nodes.getLength() == 1) {
Element lastProjectsElement = (Element) nodes.item(0);
lastProjects.loadValueFromXML(lastProjectsElement);
}
logger.finest("Loading modules configuration");
for (MZmineModule module : MZmineCore.getAllModules()) {
String className = module.getClass().getName();
expr = xpath.compile("//configuration/modules/module[@class='" + className + "']/parameters");
nodes = (NodeList) expr.evaluate(configuration, XPathConstants.NODESET);
if (nodes.getLength() != 1)
continue;
Element moduleElement = (Element) nodes.item(0);
ParameterSet moduleParameters = getModuleParameters(module.getClass());
moduleParameters.loadValuesFromXML(moduleElement);
}
logger.info("Loaded configuration from file " + file);
} catch (Exception e) {
throw new IOException(e);
}
}
use of net.sf.mzmine.parameters.impl.SimpleParameterSet in project mzmine2 by mzmine.
the class MZmineConfigurationImpl method saveConfiguration.
@Override
public void saveConfiguration(File file) throws IOException {
try {
// write sensitive parameters only to the local config file
final boolean skipSensitive = !file.equals(MZmineConfiguration.CONFIG_FILE);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document configuration = dBuilder.newDocument();
Element configRoot = configuration.createElement("configuration");
configuration.appendChild(configRoot);
Element prefElement = configuration.createElement("preferences");
configRoot.appendChild(prefElement);
preferences.setSkipSensitiveParameters(skipSensitive);
preferences.saveValuesToXML(prefElement);
Element lastFilesElement = configuration.createElement("lastprojects");
configRoot.appendChild(lastFilesElement);
lastProjects.saveValueToXML(lastFilesElement);
Element modulesElement = configuration.createElement("modules");
configRoot.appendChild(modulesElement);
// traverse modules
for (MZmineModule module : MZmineCore.getAllModules()) {
String className = module.getClass().getName();
Element moduleElement = configuration.createElement("module");
moduleElement.setAttribute("class", className);
modulesElement.appendChild(moduleElement);
Element paramElement = configuration.createElement("parameters");
moduleElement.appendChild(paramElement);
ParameterSet moduleParameters = getModuleParameters(module.getClass());
moduleParameters.setSkipSensitiveParameters(skipSensitive);
moduleParameters.saveValuesToXML(paramElement);
}
// save encryption key to local config only
// ATTENTION: this should to be written after all other configs
final SimpleParameterSet encSet = new SimpleParameterSet(new Parameter[] { globalEncrypter });
encSet.setSkipSensitiveParameters(skipSensitive);
encSet.saveValuesToXML(prefElement);
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer transformer = transfac.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
// Create parent folder if it does not exist
File confParent = file.getParentFile();
if ((confParent != null) && (!confParent.exists())) {
confParent.mkdirs();
}
StreamResult result = new StreamResult(new FileOutputStream(file));
DOMSource source = new DOMSource(configuration);
transformer.transform(source, result);
// make user home config file invisible on windows
if ((!skipSensitive) && (System.getProperty("os.name").toLowerCase().contains("windows"))) {
Files.setAttribute(file.toPath(), "dos:hidden", Boolean.TRUE, LinkOption.NOFOLLOW_LINKS);
}
logger.info("Saved configuration to file " + file);
} catch (Exception e) {
throw new IOException(e);
}
}
use of net.sf.mzmine.parameters.impl.SimpleParameterSet 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);
}
}
Aggregations