use of dr.inference.trace.LogFileTraces in project beast-mcmc by beast-dev.
the class CoalGenFrame method readFromFile.
protected boolean readFromFile(final File file) throws IOException {
try {
final String fileName = file.getName();
final ProgressMonitorInputStream in = new ProgressMonitorInputStream(this, "Reading " + fileName, new FileInputStream(file));
// final Reader reader = new InputStreamReader(in);
final JFrame frame = this;
// the monitored activity must be in a new thread.
Thread readThread = new Thread() {
public void run() {
try {
final File file1 = new File(fileName);
final LogFileTraces traces = new LogFileTraces(fileName, file1);
traces.loadTraces(in);
EventQueue.invokeLater(new Runnable() {
public void run() {
data.logFile = file;
data.traces = traces;
fireTracesChanged();
}
});
} catch (final TraceException tex) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(frame, "Error reading trace file: " + tex, "Error reading trace file", JOptionPane.ERROR_MESSAGE);
}
});
} catch (final InterruptedIOException iioex) {
// The cancel dialog button was pressed - do nothing
} catch (final IOException ioex) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(frame, "File I/O Error: " + ioex, "File I/O Error", JOptionPane.ERROR_MESSAGE);
}
});
} catch (final Exception ex) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(frame, "Fatal exception: " + ex, "Error reading file", JOptionPane.ERROR_MESSAGE);
}
});
}
}
};
readThread.start();
} catch (IOException ioex) {
JOptionPane.showMessageDialog(this, "File I/O Error: " + ioex, "File I/O Error", JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "Fatal exception: " + ex, "Error reading file", JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
Aggregations