d5663ccbdc05441112f4bbcfed37627c23d0f4c9
[debian/openrocket] / core / src / net / sf / openrocket / simulation / listeners / SimulationListener.java
1 package net.sf.openrocket.simulation.listeners;
2
3 import net.sf.openrocket.simulation.SimulationStatus;
4 import net.sf.openrocket.simulation.exception.SimulationException;
5
6
7
8 public interface SimulationListener {
9         
10         /**
11          * Get the name of this simulation listener.  Ideally this should be localized, as
12          * it can be displayed in the UI.
13          * 
14          * @return      the name of this simulation listener.
15          */
16         public String getName();
17         
18         
19         /**
20          * Get the menu position of this simulation listener.  This should be an array
21          * of localized submenu names in descending order, or an empty array for positioning
22          * in the base menu.
23          * 
24          * @return      the menu position of this simulation listener.
25          */
26         public String[] getMenuPosition();
27         
28         
29         /**
30          * Called when starting a simulation.
31          * 
32          * @param status        the simulation status.
33          */
34         public void startSimulation(SimulationStatus status) throws SimulationException;
35         
36         
37         /**
38          * Called when ending a simulation.  This is called either when the simulation ends normally
39          * (due to an end simulation event) or when a SimulationException is thrown.
40          * <p>
41          * This method cannot throw a SimulationException, since the simulation is already being ended.
42          * 
43          * @param status        the simulation status.
44          * @param exception     the exception that caused ending the simulation, or <code>null</code> if ending normally.
45          */
46         public void endSimulation(SimulationStatus status, SimulationException exception);
47         
48         
49         /**
50          * Called before a simulation step is taken.  This method may also prevent the normal
51          * stepping method from being called.
52          * 
53          * @param status        the simulation status.
54          * @return                      <code>true</code> to continue normally, <code>false</code> to skip taking the step
55          */
56         public boolean preStep(SimulationStatus status) throws SimulationException;
57         
58         
59         /**
60          * Called immediately after a simulation step has been taken.  This method is called whether the
61          * {@link #preStep(SimulationStatus)} aborted the step or not.
62          * 
63          * @param status        the simulation status.
64          */
65         public void postStep(SimulationStatus status) throws SimulationException;
66         
67         
68         /**
69          * Return whether this is a system listener.  System listeners are used internally for various
70          * purposes by OpenRocket.  User-written listeners should always return <code>false</code>.
71          * <p>
72          * System listeners do not cause warnings to be added to the simulation results when they affect
73          * the simulation.
74          * 
75          * @return              whether this is a system listener
76          */
77         public boolean isSystemListener();
78         
79 }