use of net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex in project mzmine2 by mzmine.
the class KovatsIndexExtractionDialog method handleKovatsSelectionChange.
/**
* Kovats list selection has changed
*/
private void handleKovatsSelectionChange() {
updateParameterSetFromComponents();
// keep rt values
StringBuilder s = new StringBuilder();
int i = 0;
double lastRT = 0;
for (KovatsIndex ki : selectedKovats) {
Double rt = lastRT + 1;
if (parsedValues != null)
rt = parsedValues.getOrDefault(ki, rt);
s.append(ki.name() + ":" + rtFormat.format(rt) + ",");
i++;
lastRT = rt;
}
valuesComponent.setText(s.toString());
kovatsValuesChanged();
}
use of net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex in project mzmine2 by mzmine.
the class KovatsIndexExtractionDialog method saveToFile.
private synchronized void saveToFile() {
// need to parse
if (!parseValues()) {
logger.log(Level.WARNING, "Parsing of Kovats values failed (text box). Maybe you have to select more markers: " + MIN_MARKERS + " (at least)");
return;
}
final TreeMap<KovatsIndex, Double> values = parsedValues;
File lastFile = parameterSet.getParameter(KovatsIndexExtractionParameters.lastSavedFile).getValue();
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter ff = new FileNameExtensionFilter("Comma-separated values", "csv");
chooser.addChoosableFileFilter(ff);
chooser.setFileFilter(ff);
if (lastFile != null)
chooser.setSelectedFile(lastFile);
if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
File f = chooser.getSelectedFile();
// set last file
setLastFile(f);
f = FileAndPathUtil.getRealFilePath(f, "csv");
try {
// save to file in GNPS GC format
String exp = getCsvTable(values);
if (TxtWriter.write(exp, f, false))
saveFileListener.accept(f);
} catch (Exception e) {
logger.log(Level.WARNING, "Error while saving Kovats file to " + f.getAbsolutePath(), e);
}
}
}
Aggregations