create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / print / PrintSimulationWorker.java
1 /*
2  * PrintSimulationWorker.java
3  */
4 package net.sf.openrocket.gui.print;
5
6 import net.sf.openrocket.document.Simulation;
7 import net.sf.openrocket.gui.main.SimulationWorker;
8 import net.sf.openrocket.simulation.FlightData;
9
10 /**
11  * A SimulationWorker that simulates the rocket flight in the background and sets the results to the extra text when
12  * finished.  The worker can be cancelled if necessary.
13  */
14 public class PrintSimulationWorker {
15         
16         public static FlightData doit(Simulation sim) {
17                 return new InnerPrintSimulationWorker(sim).doit();
18         }
19         
20         static class InnerPrintSimulationWorker extends SimulationWorker {
21                 
22                 public InnerPrintSimulationWorker(Simulation sim) {
23                         super(sim);
24                 }
25                 
26                 public FlightData doit() {
27                         return doInBackground();
28                 }
29                 
30                 @Override
31                 protected void simulationDone() {
32                         // Do nothing if cancelled
33                         if (isCancelled()) {
34                                 return;
35                         }
36                         
37                         simulation.getSimulatedData();
38                 }
39                 
40                 
41                 /**
42                  * Called if the simulation is interrupted due to an exception.
43                  *
44                  * @param t the Throwable that caused the interruption
45                  */
46                 @Override
47                 protected void simulationInterrupted(final Throwable t) {
48                 }
49         }
50 }