1 package net.sf.openrocket.simulation.listeners;
3 import net.sf.openrocket.simulation.SimulationStatus;
4 import net.sf.openrocket.simulation.exception.SimulationException;
8 public interface SimulationListener {
11 * Get the name of this simulation listener. Ideally this should be localized, as
12 * it can be displayed in the UI.
14 * @return the name of this simulation listener.
16 public String getName();
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
24 * @return the menu position of this simulation listener.
26 public String[] getMenuPosition();
30 * Called when starting a simulation.
32 * @param status the simulation status.
34 public void startSimulation(SimulationStatus status) throws SimulationException;
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.
41 * This method cannot throw a SimulationException, since the simulation is already being ended.
43 * @param status the simulation status.
44 * @param exception the exception that caused ending the simulation, or <code>null</code> if ending normally.
46 public void endSimulation(SimulationStatus status, SimulationException exception);
50 * Called before a simulation step is taken. This method may also prevent the normal
51 * stepping method from being called.
53 * @param status the simulation status.
54 * @return <code>true</code> to continue normally, <code>false</code> to skip taking the step
56 public boolean preStep(SimulationStatus status) throws SimulationException;
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.
63 * @param status the simulation status.
65 public void postStep(SimulationStatus status) throws SimulationException;
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>.
72 * System listeners do not cause warnings to be added to the simulation results when they affect
75 * @return whether this is a system listener
77 public boolean isSystemListener();