use of ij.io.OpenDialog in project GDSC-SMLM by aherbert.
the class CreateData method saveImageResults.
private void saveImageResults(MemoryPeakResults results) {
if (!settings.saveImageResults)
return;
String[] path = Utils.decodePath(settings.imageResultsFilename);
OpenDialog chooser = new OpenDialog("Image_Results_File", path[0], path[1]);
if (chooser.getFileName() != null) {
settings.imageResultsFilename = chooser.getDirectory() + chooser.getFileName();
settings.imageResultsFilename = Utils.replaceExtension(settings.imageResultsFilename, "xls");
FilePeakResults r = new FilePeakResults(settings.imageResultsFilename, false);
r.copySettings(results);
r.setPeakIdColumnName("Frame");
r.begin();
r.addAll(results.getResults());
r.end();
}
}
use of ij.io.OpenDialog in project GDSC-SMLM by aherbert.
the class Configuration method mouseClicked.
/*
* (non-Javadoc)
*
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*/
public void mouseClicked(MouseEvent e) {
if (// Double-click
e.getClickCount() > 1) {
if (e.getSource() == textConfigFile) {
String[] path = Utils.decodePath(textConfigFile.getText());
OpenDialog chooser = new OpenDialog("Configuration_File", path[0], path[1]);
if (chooser.getFileName() != null) {
String newFilename = chooser.getDirectory() + chooser.getFileName();
textConfigFile.setText(newFilename);
}
}
}
}
use of ij.io.OpenDialog in project GDSC-SMLM by aherbert.
the class CreateData method saveFluorophores.
/**
* Save the fluorophores to a text file
*
* @param fluorophores
*/
private void saveFluorophores(List<? extends FluorophoreSequenceModel> fluorophores) {
if (!settings.saveFluorophores || fluorophores == null)
return;
String[] path = Utils.decodePath(settings.fluorophoresFilename);
OpenDialog chooser = new OpenDialog("Fluorophores_File", path[0], path[1]);
if (chooser.getFileName() != null) {
settings.fluorophoresFilename = chooser.getDirectory() + chooser.getFileName();
settings.fluorophoresFilename = Utils.replaceExtension(settings.fluorophoresFilename, "xls");
BufferedWriter output = null;
try {
output = new BufferedWriter(new FileWriter(settings.fluorophoresFilename));
output.write(createResultsFileHeader());
output.write("#Id\tn-Blinks\tStart\tStop\t...");
output.newLine();
for (int id = 1; id <= fluorophores.size(); id++) {
FluorophoreSequenceModel f = fluorophores.get(id - 1);
StringBuffer sb = new StringBuffer();
sb.append(f.getId()).append("\t");
sb.append(f.getNumberOfBlinks()).append("\t");
for (double[] burst : f.getBurstSequence()) {
sb.append(Utils.rounded(burst[0], 3)).append("\t").append(Utils.rounded(burst[1], 3)).append("\t");
}
output.write(sb.toString());
output.newLine();
}
} catch (Exception e) {
// Q. Add better handling of errors?
e.printStackTrace();
IJ.log("Failed to save fluorophores to file: " + settings.fluorophoresFilename);
} finally {
if (output != null) {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
Aggregations