private static final LogHelper log = Application.getLogger();
private static final Translator trans = Application.getTranslator();
-
+
/** Update the dialog status every this many ms */
private static final long UPDATE_MS = 200;
/** Flight progress at apogee */
private static final double APOGEE_PROGRESS = 0.7;
-
- /*
- * The executor service is not static since we want concurrent simulation
- * dialogs to run in parallel, ie. they both have their own executor service.
- */
- private final ExecutorService executor = Executors.newFixedThreadPool(
+
+ private final static ExecutorService executor = Executors.newFixedThreadPool(
SwingPreferences.getMaxThreadCount());
-
+
private final JLabel simLabel, timeLabel, altLabel, velLabel;
private final JProgressBar progressBar;
-
+
/*
* NOTE: Care must be used when accessing the simulation parameters, since they
* are being run in another thread. Mutexes are used to avoid concurrent usage, which
public SimulationRunDialog(Window window, Simulation... simulations) {
//// Running simulations...
- super(window, trans.get("SimuRunDlg.title.RunSim"), Dialog.ModalityType.DOCUMENT_MODAL);
+ super(window, trans.get("SimuRunDlg.title.RunSim"), Dialog.ModalityType.APPLICATION_MODAL);
if (simulations.length == 0) {
throw new IllegalArgumentException("Called with no simulations to run");
this.simulations = simulations;
-
+
// Randomize the simulation random seeds
for (Simulation sim : simulations) {
sim.getOptions().randomizeSeed();
progressBar = new JProgressBar();
panel.add(progressBar, "spanx, growx, wrap para");
-
+
// Add cancel button
JButton cancel = new JButton(trans.get("dlg.but.cancel"));
cancel.addActionListener(new ActionListener() {
});
panel.add(cancel, "spanx, tag cancel");
-
+
// Cancel simulations when user closes the window
this.addWindowListener(new WindowAdapter() {
@Override
}
});
-
+
this.add(panel);
this.setMinimumSize(new Dimension(300, 0));
this.setLocationByPlatform(true);
}
-
-
+
+
private void updateProgress() {
int index;
for (index = 0; index < simulations.length; index++) {
}
-
+
/**
* A SwingWorker that performs a flight simulation. It periodically updates the
* simulation statuses of the parent class and calls updateProgress().