Search in sources :

Example 31 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.

the class ProjectTreeMouseHandler method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if (command.equals("SHOW_TIC")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        TICVisualizerModule.setupNewTICVisualizer(selectedFiles);
    }
    if (command.equals("SHOW_SPECTRUM")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        SpectraVisualizerModule module = MZmineCore.getModuleInstance(SpectraVisualizerModule.class);
        ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(SpectraVisualizerModule.class);
        parameters.getParameter(SpectraVisualizerParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
        MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
        if (exitCode == ExitCode.OK)
            module.runModule(project, parameters, new ArrayList<Task>());
    }
    if (command.equals("SHOW_IDA")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        MsMsVisualizerModule.showIDAVisualizerSetupDialog(selectedFiles[0]);
    }
    if (command.equals("SHOW_2D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        TwoDVisualizerModule.show2DVisualizerSetupDialog(selectedFiles[0]);
    }
    if (command.equals("SHOW_3D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        Fx3DVisualizerModule.setupNew3DVisualizer(selectedFiles[0]);
    }
    if (command.equals("SORT_FILES")) {
        // save current selection
        TreePath[] savedSelection = tree.getSelectionPaths();
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        SortDataFilesModule module = MZmineCore.getModuleInstance(SortDataFilesModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(SortDataFilesModule.class);
        params.getParameter(SortDataFilesParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }
    if (command.equals("REMOVE_EXTENSION")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        for (RawDataFile file : selectedFiles) {
            file.setName(FilenameUtils.removeExtension(file.toString()));
        }
        tree.updateUI();
    }
    if (command.equals("EXPORT_FILE")) {
        RawDataExportModule exportModule = MZmineCore.getModuleInstance(RawDataExportModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(RawDataExportModule.class);
        ExitCode ec = params.showSetupDialog(null, true);
        if (ec == ExitCode.OK) {
            ParameterSet parametersCopy = params.cloneParameterSet();
            ArrayList<Task> tasks = new ArrayList<>();
            MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
            exportModule.runModule(project, parametersCopy, tasks);
            MZmineCore.getTaskController().addTasks(tasks.toArray(new Task[0]));
        }
    }
    if (command.equals("RENAME_FILE")) {
        TreePath path = tree.getSelectionPath();
        if (path == null)
            return;
        else
            tree.startEditingAtPath(path);
    }
    if (command.equals("REMOVE_FILE")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        PeakList[] allPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
        for (RawDataFile file : selectedFiles) {
            for (PeakList peakList : allPeakLists) {
                if (peakList.hasRawDataFile(file)) {
                    String msg = "Cannot remove file " + file.getName() + ", because it is present in the feature list " + peakList.getName();
                    MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), msg);
                    return;
                }
            }
            MZmineCore.getProjectManager().getCurrentProject().removeFile(file);
        }
    }
    if (command.equals("SHOW_SCAN")) {
        Scan[] selectedScans = tree.getSelectedObjects(Scan.class);
        for (Scan scan : selectedScans) {
            SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
        }
    }
    if (command.equals("EXPORT_SCAN")) {
        Scan[] selectedScans = tree.getSelectedObjects(Scan.class);
        ExportScansModule.showSetupDialog(selectedScans);
    }
    if (command.equals("SHOW_MASSLIST")) {
        MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            SpectraVisualizerWindow window = SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
            MassListDataSet dataset = new MassListDataSet(massList);
            window.addDataSet(dataset, Color.green);
        }
    }
    if (command.equals("REMOVE_MASSLIST")) {
        MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            scan.removeMassList(massList);
        }
    }
    if (command.equals("REMOVE_ALL_MASSLISTS")) {
        MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            String massListName = massList.getName();
            RawDataFile[] dataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
            for (RawDataFile dataFile : dataFiles) {
                int[] scanNumbers = dataFile.getScanNumbers();
                for (int scanNum : scanNumbers) {
                    Scan scan = dataFile.getScan(scanNum);
                    MassList ml = scan.getMassList(massListName);
                    if (ml != null)
                        scan.removeMassList(ml);
                }
            }
        }
    }
    if (command.equals("SHOW_PEAKLIST_TABLES")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            PeakListTableModule.showNewPeakListVisualizerWindow(peakList);
        }
    }
    if (command.equals("SHOW_PEAKLIST_INFO")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            InfoVisualizerModule.showNewPeakListInfo(peakList);
        }
    }
    if (command.equals("SHOW_SCATTER_PLOT")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            ScatterPlotVisualizerModule.showNewScatterPlotWindow(peakList);
        }
    }
    if (command.equals("SORT_PEAKLISTS")) {
        // save current selection
        TreePath[] savedSelection = tree.getSelectionPaths();
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        SortPeakListsModule module = MZmineCore.getModuleInstance(SortPeakListsModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(SortPeakListsModule.class);
        params.getParameter(SortPeakListsParameters.peakLists).setValue(PeakListsSelectionType.SPECIFIC_PEAKLISTS, selectedPeakLists);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }
    if (command.equals("RENAME_FEATURELIST")) {
        TreePath path = tree.getSelectionPath();
        if (path == null)
            return;
        else
            tree.startEditingAtPath(path);
    }
    if (command.equals("REMOVE_PEAKLIST")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) MZmineCore.getProjectManager().getCurrentProject().removePeakList(peakList);
    }
    if (command.equals("SHOW_PEAK_SUMMARY")) {
        PeakListRow[] selectedRows = tree.getSelectedObjects(PeakListRow.class);
        for (PeakListRow row : selectedRows) {
            PeakSummaryVisualizerModule.showNewPeakSummaryWindow(row);
        }
    }
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) ExitCode(net.sf.mzmine.util.ExitCode) ArrayList(java.util.ArrayList) SpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SpectraVisualizerModule(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerModule) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) MassListDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.MassListDataSet) ParameterSet(net.sf.mzmine.parameters.ParameterSet) SortDataFilesModule(net.sf.mzmine.modules.rawdatamethods.sortdatafiles.SortDataFilesModule) RawDataExportModule(net.sf.mzmine.modules.rawdatamethods.rawdataexport.RawDataExportModule) TreePath(javax.swing.tree.TreePath) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) PeakList(net.sf.mzmine.datamodel.PeakList) MassList(net.sf.mzmine.datamodel.MassList) SortPeakListsModule(net.sf.mzmine.modules.peaklistmethods.sortpeaklists.SortPeakListsModule)

Example 32 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.

the class BatchTask method processQueueStep.

private void processQueueStep(int stepNumber) {
    logger.info("Starting step # " + (stepNumber + 1));
    // Run next step of the batch
    MZmineProcessingStep<?> currentStep = queue.get(stepNumber);
    MZmineProcessingModule method = (MZmineProcessingModule) currentStep.getModule();
    ParameterSet batchStepParameters = currentStep.getParameterSet();
    // the ones from the previous step
    if (createdDataFiles.isEmpty())
        createdDataFiles.addAll(previousCreatedDataFiles);
    if (createdPeakLists.isEmpty())
        createdPeakLists.addAll(previousCreatedPeakLists);
    // state of the batch
    for (Parameter<?> p : batchStepParameters.getParameters()) {
        if (p instanceof RawDataFilesParameter) {
            RawDataFilesParameter rdp = (RawDataFilesParameter) p;
            RawDataFile[] createdFiles = createdDataFiles.toArray(new RawDataFile[0]);
            final RawDataFilesSelection selectedFiles = rdp.getValue();
            if (selectedFiles == null) {
                setStatus(TaskStatus.ERROR);
                setErrorMessage("Invalid parameter settings for module " + method.getName() + ": " + "Missing parameter value for " + p.getName());
                return;
            }
            selectedFiles.setBatchLastFiles(createdFiles);
        }
    }
    // state of the batch
    for (Parameter<?> p : batchStepParameters.getParameters()) {
        if (p instanceof PeakListsParameter) {
            PeakListsParameter rdp = (PeakListsParameter) p;
            PeakList[] createdPls = createdPeakLists.toArray(new PeakList[0]);
            final PeakListsSelection selectedPeakLists = rdp.getValue();
            if (selectedPeakLists == null) {
                setStatus(TaskStatus.ERROR);
                setErrorMessage("Invalid parameter settings for module " + method.getName() + ": " + "Missing parameter value for " + p.getName());
                return;
            }
            selectedPeakLists.setBatchLastPeakLists(createdPls);
        }
    }
    // Clear the saved data files and feature lists. Save them to the
    // "previous" lists, in case the next step does not produce any new data
    previousCreatedDataFiles.clear();
    previousCreatedDataFiles.addAll(createdDataFiles);
    previousCreatedPeakLists.clear();
    previousCreatedPeakLists.addAll(createdPeakLists);
    createdDataFiles.clear();
    createdPeakLists.clear();
    // Check if the parameter settings are valid
    ArrayList<String> messages = new ArrayList<String>();
    boolean paramsCheck = batchStepParameters.checkParameterValues(messages);
    if (!paramsCheck) {
        setStatus(TaskStatus.ERROR);
        setErrorMessage("Invalid parameter settings for module " + method.getName() + ": " + Arrays.toString(messages.toArray()));
    }
    ArrayList<Task> currentStepTasks = new ArrayList<Task>();
    ExitCode exitCode = method.runModule(project, batchStepParameters, currentStepTasks);
    if (exitCode != ExitCode.OK) {
        setStatus(TaskStatus.ERROR);
        setErrorMessage("Could not start batch step " + method.getName());
        return;
    }
    // If current step didn't produce any tasks, continue with next step
    if (currentStepTasks.isEmpty())
        return;
    boolean allTasksFinished = false;
    // Submit the tasks to the task controller for processing
    MZmineCore.getTaskController().addTasks(currentStepTasks.toArray(new Task[0]));
    while (!allTasksFinished) {
        // If we canceled the batch, cancel all running tasks
        if (isCanceled()) {
            for (Task stepTask : currentStepTasks) stepTask.cancel();
            return;
        }
        // First set to true, then check all tasks
        allTasksFinished = true;
        for (Task stepTask : currentStepTasks) {
            TaskStatus stepStatus = stepTask.getStatus();
            // If any of them is not finished, keep checking
            if (stepStatus != TaskStatus.FINISHED)
                allTasksFinished = false;
            // If there was an error, we have to stop the whole batch
            if (stepStatus == TaskStatus.ERROR) {
                setStatus(TaskStatus.ERROR);
                setErrorMessage(stepTask.getTaskDescription() + ": " + stepTask.getErrorMessage());
                return;
            }
            // whole batch
            if (stepStatus == TaskStatus.CANCELED) {
                setStatus(TaskStatus.CANCELED);
                for (Task t : currentStepTasks) t.cancel();
                return;
            }
        }
        // Wait 1s before checking the tasks again
        if (!allTasksFinished) {
            synchronized (this) {
                try {
                    this.wait(1000);
                } catch (InterruptedException e) {
                // ignore
                }
            }
        }
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) Task(net.sf.mzmine.taskcontrol.Task) AbstractTask(net.sf.mzmine.taskcontrol.AbstractTask) ExitCode(net.sf.mzmine.util.ExitCode) ArrayList(java.util.ArrayList) MZmineProcessingModule(net.sf.mzmine.modules.MZmineProcessingModule) TaskStatus(net.sf.mzmine.taskcontrol.TaskStatus) RawDataFilesSelection(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakListsSelection(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsSelection) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) PeakList(net.sf.mzmine.datamodel.PeakList) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 33 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet 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);
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) DOMSource(javax.xml.transform.dom.DOMSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) Element(org.w3c.dom.Element) IOException(java.io.IOException) Document(org.w3c.dom.Document) IOException(java.io.IOException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) FileOutputStream(java.io.FileOutputStream) File(java.io.File) MZmineModule(net.sf.mzmine.modules.MZmineModule)

Example 34 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.

the class MainMenu method actionPerformed.

/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
@Override
public void actionPerformed(ActionEvent e) {
    Object src = e.getSource();
    MZmineRunnableModule module = moduleMenuItems.get(src);
    if (module != null) {
        ParameterSet moduleParameters = MZmineCore.getConfiguration().getModuleParameters(module.getClass());
        RawDataFile[] selectedFiles = MZmineCore.getDesktop().getSelectedDataFiles();
        if (selectedFiles.length > 0) {
            for (Parameter<?> p : moduleParameters.getParameters()) {
                if (p instanceof RawDataFilesParameter) {
                    RawDataFilesParameter rdp = (RawDataFilesParameter) p;
                    rdp.setValue(RawDataFilesSelectionType.GUI_SELECTED_FILES);
                }
            }
        }
        PeakList[] selectedPeakLists = MZmineCore.getDesktop().getSelectedPeakLists();
        if (selectedPeakLists.length > 0) {
            for (Parameter<?> p : moduleParameters.getParameters()) {
                if (p instanceof PeakListsParameter) {
                    PeakListsParameter plp = (PeakListsParameter) p;
                    plp.setValue(PeakListsSelectionType.GUI_SELECTED_PEAKLISTS);
                }
            }
        }
        logger.finest("Setting parameters for module " + module.getName());
        ExitCode exitCode = moduleParameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
        if (exitCode == ExitCode.OK) {
            ParameterSet parametersCopy = moduleParameters.cloneParameterSet();
            logger.finest("Starting module " + module.getName() + " with parameters " + parametersCopy);
            ArrayList<Task> tasks = new ArrayList<Task>();
            MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
            module.runModule(project, parametersCopy, tasks);
            MZmineCore.getTaskController().addTasks(tasks.toArray(new Task[0]));
        }
        return;
    }
    if (src == projectExit) {
        MZmineCore.getDesktop().exitMZmine();
    }
    if (src == projectSaveParameters) {
        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showSaveDialog(MZmineCore.getDesktop().getMainWindow());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File configFile = chooser.getSelectedFile();
            try {
                MZmineCore.getConfiguration().saveConfiguration(configFile);
            } catch (Exception ex) {
                MZmineCore.getDesktop().displayException(MZmineCore.getDesktop().getMainWindow(), ex);
            }
        }
    }
    if (src == projectLoadParameters) {
        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showOpenDialog(MZmineCore.getDesktop().getMainWindow());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File configFile = chooser.getSelectedFile();
            try {
                MZmineCore.getConfiguration().loadConfiguration(configFile);
            } catch (Exception ex) {
                MZmineCore.getDesktop().displayException(MZmineCore.getDesktop().getMainWindow(), ex);
            }
        }
    }
    if (src == projectSampleParameters) {
        ProjectParametersSetupDialog dialog = new ProjectParametersSetupDialog();
        dialog.setVisible(true);
    }
    if (src == projectPreferences) {
        MZminePreferences preferences = MZmineCore.getConfiguration().getPreferences();
        preferences.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    }
    if (src == showAbout) {
        MainWindow mainWindow = (MainWindow) MZmineCore.getDesktop();
        mainWindow.showAboutDialog();
    }
    if (src == checkUpdate) {
        // Check for updated version
        NewVersionCheck NVC = new NewVersionCheck(CheckType.MENU);
        new Thread(NVC).start();
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ProjectOpeningTask(net.sf.mzmine.modules.projectmethods.projectload.ProjectOpeningTask) Task(net.sf.mzmine.taskcontrol.Task) MZmineRunnableModule(net.sf.mzmine.modules.MZmineRunnableModule) ProjectParametersSetupDialog(net.sf.mzmine.project.parameterssetup.ProjectParametersSetupDialog) ExitCode(net.sf.mzmine.util.ExitCode) ArrayList(java.util.ArrayList) NewVersionCheck(net.sf.mzmine.main.NewVersionCheck) MZminePreferences(net.sf.mzmine.desktop.preferences.MZminePreferences) JFileChooser(javax.swing.JFileChooser) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) PeakList(net.sf.mzmine.datamodel.PeakList) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) File(java.io.File) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 35 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.

the class MainWindow method initModule.

public void initModule() {
    assert SwingUtilities.isEventDispatchThread();
    try {
        final InputStream mzmineIconStream = DesktopSetup.class.getClassLoader().getResourceAsStream("MZmineIcon.png");
        this.mzmineIcon = ImageIO.read(mzmineIconStream);
        mzmineIconStream.close();
        setIconImage(mzmineIcon);
    } catch (Throwable e) {
        e.printStackTrace();
        logger.log(Level.WARNING, "Could not set application icon", e);
    }
    DesktopSetup desktopSetup = new DesktopSetup();
    desktopSetup.init();
    setLayout(new BorderLayout());
    mainPanel = new MainPanel();
    add(mainPanel, BorderLayout.CENTER);
    statusBar = new StatusBar();
    add(statusBar, BorderLayout.SOUTH);
    // Construct menu
    menuBar = new MainMenu();
    setJMenuBar(menuBar);
    // Initialize window listener for responding to user events
    addWindowListener(this);
    pack();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension screenSize = toolkit.getScreenSize();
    // Set initial window size to 1000x700 pixels, but check the screen size
    // first
    int width = Math.min(screenSize.width, 1000);
    int height = Math.min(screenSize.height, 700);
    setBounds(0, 0, width, height);
    setLocationRelativeTo(null);
    // Application wants to control closing by itself
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    updateTitle();
    // get the window settings parameter
    ParameterSet paramSet = MZmineCore.getConfiguration().getPreferences();
    WindowSettingsParameter settings = paramSet.getParameter(MZminePreferences.windowSetttings);
    // listen for changes
    this.addComponentListener(settings);
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) WindowSettingsParameter(net.sf.mzmine.parameters.parametertypes.WindowSettingsParameter) BorderLayout(java.awt.BorderLayout) InputStream(java.io.InputStream) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension)

Aggregations

ParameterSet (net.sf.mzmine.parameters.ParameterSet)53 ExitCode (net.sf.mzmine.util.ExitCode)19 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)11 File (java.io.File)9 ArrayList (java.util.ArrayList)8 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)8 Task (net.sf.mzmine.taskcontrol.Task)8 Element (org.w3c.dom.Element)8 PeakList (net.sf.mzmine.datamodel.PeakList)6 MZmineModule (net.sf.mzmine.modules.MZmineModule)6 Document (org.w3c.dom.Document)6 IOException (java.io.IOException)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)5 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)5 Scan (net.sf.mzmine.datamodel.Scan)5 MZmineProcessingModule (net.sf.mzmine.modules.MZmineProcessingModule)5 Nonnull (javax.annotation.Nonnull)4 Feature (net.sf.mzmine.datamodel.Feature)4 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)4 PeakListsParameter (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter)4