use of net.sf.mzmine.datamodel.MassList in project mzmine2 by mzmine.
the class StorableScan method addMassList.
@Override
public synchronized void addMassList(@Nonnull final MassList massList) {
// Remove all mass lists with same name, if there are any
MassList[] currentMassLists = massLists.toArray(new MassList[0]);
for (MassList ml : currentMassLists) {
if (ml.getName().equals(massList.getName()))
removeMassList(ml);
}
StorableMassList storedMassList;
if (massList instanceof StorableMassList) {
storedMassList = (StorableMassList) massList;
} else {
DataPoint[] massListDataPoints = massList.getDataPoints();
try {
int mlStorageID = rawDataFile.storeDataPoints(massListDataPoints);
storedMassList = new StorableMassList(rawDataFile, mlStorageID, massList.getName(), this);
} catch (IOException e) {
logger.severe("Could not write data to temporary file " + e.toString());
return;
}
}
// Add the new mass list
massLists.add(storedMassList);
// Add the mass list to the tree model
MZmineProjectImpl project = (MZmineProjectImpl) MZmineCore.getProjectManager().getCurrentProject();
// Check if we are adding to the current project
if (Arrays.asList(project.getDataFiles()).contains(rawDataFile)) {
final RawDataTreeModel treeModel = project.getRawDataTreeModel();
treeModel.addObjectWithoutGUIUpdate(storedMassList);
}
}
Aggregations