use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class ProjectTreeMouseHandler method handlePopupTriggerEvent.
private void handlePopupTriggerEvent(MouseEvent e) {
TreePath clickedPath = tree.getPathForLocation(e.getX(), e.getY());
if (clickedPath == null)
return;
DefaultMutableTreeNode node = (DefaultMutableTreeNode) clickedPath.getLastPathComponent();
Object clickedObject = node.getUserObject();
if (clickedObject instanceof RawDataFile)
dataFilePopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof Scan)
scanPopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof MassList)
massListPopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof PeakList)
peakListPopupMenu.show(e.getComponent(), e.getX(), e.getY());
if (clickedObject instanceof PeakListRow)
peakListRowPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class ProjectTreeRenderer method getTreeCellRendererComponent.
public Component getTreeCellRendererComponent(JTree tree, Object node, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, node, sel, expanded, leaf, row, hasFocus);
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
Object embeddedObject = treeNode.getUserObject();
if (embeddedObject instanceof MZmineProject) {
label.setIcon(projectIcon);
label.setFont(bigFont);
}
if (embeddedObject == RawDataTreeModel.dataFilesNodeName) {
label.setIcon(dataFileIcon);
label.setFont(bigFont);
}
if (embeddedObject == PeakListTreeModel.peakListsNodeName) {
label.setFont(bigFont);
label.setIcon(peakListsIcon);
}
if (embeddedObject instanceof RawDataFile) {
label.setFont(smallerFont);
boolean hasMassList = RawDataFileUtils.hasMassLists((RawDataFile) embeddedObject);
if (hasMassList)
label.setIcon(fileWithMassListIcon);
else
label.setIcon(fileIcon);
}
if (embeddedObject instanceof Scan) {
Scan s = (Scan) embeddedObject;
label.setIcon(spectrumIcon);
label.setFont(smallFont);
// could get blue text on blue background
if (!sel) {
if (s.getMSLevel() > 1)
label.setForeground(Color.red);
else
label.setForeground(Color.blue);
}
}
if (embeddedObject instanceof MassList) {
label.setIcon(peakListIcon);
label.setFont(smallFont);
}
if (embeddedObject instanceof PeakList) {
PeakList p = (PeakList) embeddedObject;
if (p.getNumberOfRawDataFiles() > 1) {
label.setFont(smallerFont.deriveFont(Font.BOLD));
label.setIcon(alignedPeaklistIcon);
} else {
label.setFont(smallerFont);
label.setIcon(peakListIcon);
}
}
if (embeddedObject instanceof PeakListRow) {
PeakListRow r = (PeakListRow) embeddedObject;
label.setIcon(peakIcon);
label.setFont(smallFont);
// Change the color only if the row is not selected
if (!sel) {
if (r.getPreferredPeakIdentity() != null) {
label.setForeground(Color.red);
}
}
}
return label;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class BatchTask method run.
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Starting a batch of " + totalSteps + " steps");
// Listen for new items in the project
MZmineProjectListener listener = new MZmineProjectListener() {
@Override
public void peakListAdded(PeakList newPeakList) {
createdPeakLists.add(newPeakList);
}
@Override
public void dataFileAdded(RawDataFile newFile) {
createdDataFiles.add(newFile);
}
};
project.addProjectListener(listener);
// Process individual batch steps
for (int i = 0; i < totalSteps; i++) {
processQueueStep(i);
processedSteps++;
// Update the project reference in case new project was loaded
if (project != MZmineCore.getProjectManager().getCurrentProject()) {
project.removeProjectListener(listener);
project = MZmineCore.getProjectManager().getCurrentProject();
project.addProjectListener(listener);
}
// If we are canceled or ran into error, stop here
if (isCanceled() || (getStatus() == TaskStatus.ERROR)) {
return;
}
}
project.removeProjectListener(listener);
logger.info("Finished a batch of " + totalSteps + " steps");
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.datamodel.PeakList 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
}
}
}
}
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class ProjectTreeEditor method isCellEditable.
public boolean isCellEditable(EventObject e) {
if (e instanceof MouseEvent) {
MouseEvent me = (MouseEvent) e;
TreePath clickedPath = projectTree.getPathForLocation(me.getX(), me.getY());
if (clickedPath == null)
return false;
DefaultMutableTreeNode node = (DefaultMutableTreeNode) clickedPath.getLastPathComponent();
Object editedObject = node.getUserObject();
return ((editedObject instanceof RawDataFile) || (editedObject instanceof PeakList));
}
return true;
}
Aggregations