1 package net.sf.openrocket.simulation.listeners;
5 import net.sf.openrocket.simulation.FlightDataType;
6 import net.sf.openrocket.simulation.SimulationStatus;
7 import net.sf.openrocket.simulation.exception.SimulationException;
11 public interface SimulationListener {
14 * Get the name of this simulation listener. Ideally this should be localized, as
15 * it can be displayed in the UI.
17 * @return the name of this simulation listener.
19 public String getName();
23 * Get the menu position of this simulation listener. This should be an array
24 * of localized submenu names in descending order, or an empty array for positioning
27 * @return the menu position of this simulation listener.
29 public String[] getMenuPosition();
33 * Called when starting a simulation.
35 * @param status the simulation status.
37 public void startSimulation(SimulationStatus status) throws SimulationException;
41 * Called when ending a simulation. This is called either when the simulation ends normally
42 * (due to an end simulation event) or when a SimulationException is thrown.
44 * This method cannot throw a SimulationException, since the simulation is already being ended.
46 * @param status the simulation status.
47 * @param exception the exception that caused ending the simulation, or <code>null</code> if ending normally.
49 public void endSimulation(SimulationStatus status, SimulationException exception);
53 * Called before a simulation step is taken. This method may also prevent the normal
54 * stepping method from being called.
56 * @param status the simulation status.
57 * @return <code>true</code> to continue normally, <code>false</code> to skip taking the step
59 public boolean preStep(SimulationStatus status) throws SimulationException;
63 * Called immediately after a simulation step has been taken. This method is called whether the
64 * {@link #preStep(SimulationStatus)} aborted the step or not.
66 * @param status the simulation status.
68 public void postStep(SimulationStatus status) throws SimulationException;
72 * Return whether this is a system listener. System listeners are used internally for various
73 * purposes by OpenRocket. User-written listeners should always return <code>false</code>.
75 * System listeners do not cause warnings to be added to the simulation results when they affect
78 * @return whether this is a system listener
80 public boolean isSystemListener();
84 * Return a list of any flight data types this listener creates.
86 public FlightDataType[] getFlightDataTypes();