use of net.sf.mzmine.modules.MZmineModule in project mzmine2 by mzmine.
the class ProcessingComponent method setupTreeViews.
private void setupTreeViews() {
tiProcessingRoot = new DefaultMutableTreeNode("Processing queues");
msLevelNodes = new DPPMSLevelTreeNode[MSLevel.cropValues().length];
for (MSLevel mslevel : MSLevel.cropValues()) {
msLevelNodes[mslevel.ordinal()] = new DPPMSLevelTreeNode(mslevel);
tiProcessingRoot.add(msLevelNodes[mslevel.ordinal()]);
}
tiAllModulesRoot = new DefaultMutableTreeNode("Modules");
// create category items dynamically, if a new category is added later on.
DPPModuleCategoryTreeNode[] moduleCategories = new DPPModuleCategoryTreeNode[ModuleSubCategory.values().length];
for (int i = 0; i < moduleCategories.length; i++) {
moduleCategories[i] = new DPPModuleCategoryTreeNode(ModuleSubCategory.values()[i]);
tiAllModulesRoot.add(moduleCategories[i]);
}
// add modules to their module category items
Collection<MZmineModule> moduleList = MZmineCore.getAllModules();
for (MZmineModule module : moduleList) {
if (module instanceof DataPointProcessingModule) {
DataPointProcessingModule dppm = (DataPointProcessingModule) module;
// add each module as a child of the module category items
for (DPPModuleCategoryTreeNode catItem : moduleCategories) {
if (dppm.getModuleSubCategory().equals(catItem.getCategory())) {
catItem.add(new DPPModuleTreeNode(dppm));
}
}
}
}
// add the categories to the root item
tvProcessing = new JTree(tiProcessingRoot);
tvAllModules = new JTree(tiAllModulesRoot);
tvProcessing.setCellRenderer(new DisableableTreeCellRenderer());
tvAllModules.setRootVisible(true);
tvProcessing.setRootVisible(true);
expandAllNodes(tvAllModules);
}
use of net.sf.mzmine.modules.MZmineModule in project mzmine2 by mzmine.
the class BatchQueue method loadFromXml.
/**
* De-serialize from XML.
*
* @param xmlElement the element that holds the XML.
* @return the de-serialized value.
*/
public static BatchQueue loadFromXml(final Element xmlElement) {
// Set the parameter choice for the RowsFilterModule
String[] choices;
choices = new String[1];
choices[0] = "No parameters defined";
MZmineCore.getConfiguration().getModuleParameters(RowsFilterModule.class).getParameter(RowsFilterParameters.GROUPSPARAMETER).setChoices(choices);
// Create an empty queue.
final BatchQueue queue = new BatchQueue();
// Get the loaded modules.
final Collection<MZmineModule> allModules = MZmineCore.getAllModules();
// Process the batch step elements.
final NodeList nodes = xmlElement.getElementsByTagName(BATCH_STEP_ELEMENT);
final int nodesLength = nodes.getLength();
for (int i = 0; i < nodesLength; i++) {
final Element stepElement = (Element) nodes.item(i);
final String methodName = stepElement.getAttribute(METHOD_ELEMENT);
// Find a matching module.
for (final MZmineModule module : allModules) {
if (module instanceof MZmineProcessingModule && module.getClass().getName().equals(methodName)) {
// Get parameters and add step to queue.
final ParameterSet parameterSet = MZmineCore.getConfiguration().getModuleParameters(module.getClass());
final ParameterSet methodParams = parameterSet.cloneParameterSet();
methodParams.loadValuesFromXML(stepElement);
queue.add(new MZmineProcessingStepImpl<MZmineProcessingModule>((MZmineProcessingModule) module, methodParams));
break;
}
}
}
return queue;
}
use of net.sf.mzmine.modules.MZmineModule 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.modules.MZmineModule in project mzmine2 by mzmine.
the class MZmineConfigurationImpl method setModuleParameters.
@Override
public void setModuleParameters(Class<? extends MZmineModule> moduleClass, ParameterSet parameters) {
assert moduleClass != null;
assert parameters != null;
MZmineModule moduleInstance = MZmineCore.getModuleInstance(moduleClass);
Class<? extends ParameterSet> parametersClass = moduleInstance.getParameterSetClass();
if (!parametersClass.isInstance(parameters)) {
throw new IllegalArgumentException("Given parameter set is an instance of " + parameters.getClass() + " instead of " + parametersClass);
}
moduleParameters.put(moduleClass, parameters);
}
use of net.sf.mzmine.modules.MZmineModule in project mzmine2 by mzmine.
the class DataPointProcessingQueue method loadfromXML.
@Nonnull
public static DataPointProcessingQueue loadfromXML(@Nonnull final Element xmlElement) {
DataPointProcessingQueue queue = new DataPointProcessingQueue();
// Get the loaded modules.
final Collection<MZmineModule> allModules = MZmineCore.getAllModules();
// Process the processing step elements.
final NodeList nodes = xmlElement.getElementsByTagName(DATA_POINT_PROCESSING_STEP_ELEMENT);
final int nodesLength = nodes.getLength();
for (int i = 0; i < nodesLength; i++) {
final Element stepElement = (Element) nodes.item(i);
final String methodName = stepElement.getAttribute(METHOD_ELEMENT);
logger.finest("loading method " + methodName);
for (MZmineModule module : allModules) {
if (module instanceof DataPointProcessingModule && module.getClass().getName().equals(methodName)) {
// since the same module can be used in different ms levels, we need to clone the
// parameter set, so we can have different values for every ms level
ParameterSet parameterSet = MZmineCore.getConfiguration().getModuleParameters(module.getClass()).cloneParameterSet();
parameterSet.loadValuesFromXML(stepElement);
queue.add(new MZmineProcessingStepImpl<DataPointProcessingModule>((DataPointProcessingModule) module, parameterSet));
// add to treeView
break;
}
}
}
return queue;
}
Aggregations