Initial commit
[debian/openrocket] / src / net / sf / openrocket / simulation / listeners / ApogeeEndListener.java
1 package net.sf.openrocket.simulation.listeners;
2
3 import java.util.Collection;
4 import java.util.Collections;
5
6 import net.sf.openrocket.simulation.FlightEvent;
7 import net.sf.openrocket.simulation.SimulationStatus;
8 import net.sf.openrocket.simulation.exception.SimulationException;
9
10
11 /**
12  * A simulation listeners that ends the simulation when apogee is reached.
13  * 
14  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
15  */
16 public class ApogeeEndListener extends AbstractSimulationListener {
17
18         public static final ApogeeEndListener INSTANCE = new ApogeeEndListener();
19         
20         @Override
21         public Collection<FlightEvent> handleEvent(FlightEvent event,
22                         SimulationStatus status) throws SimulationException {
23
24                 if (event.getType() == FlightEvent.Type.APOGEE) {
25                         return Collections.singleton(new FlightEvent(FlightEvent.Type.SIMULATION_END, 
26                                         status.time));
27                 }
28                 return null;
29         }
30
31 }