I18 changes
[debian/openrocket] / src / net / sf / openrocket / simulation / FlightEvent.java
index 71162167b10a175ba255c26a7c66d950328f6f9b..ead84eecf0263929264a25235694fa93f4c69f79 100644 (file)
@@ -1,6 +1,8 @@
 package net.sf.openrocket.simulation;
 
+import net.sf.openrocket.l10n.Translator;
 import net.sf.openrocket.rocketcomponent.RocketComponent;
+import net.sf.openrocket.startup.Application;
 
 
 /**
@@ -9,6 +11,7 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
  */
 public class FlightEvent implements Comparable<FlightEvent> {
+       private static final Translator trans = Application.getTranslator();
 
        /**
         * The type of the flight event.
@@ -19,80 +22,96 @@ public class FlightEvent implements Comparable<FlightEvent> {
                /** 
                 * Rocket launch.
                 */
-               LAUNCH("Launch"),
+               //// Launch
+               LAUNCH(trans.get("FlightEvent.Type.LAUNCH")),
                /** 
-                * Ignition of a motor.  Source is the motor mount the motor of which has ignited. 
+                * Ignition of a motor.  Source is the motor mount the motor of which has ignited,
+                * and the data is the MotorId of the motor instance.
                 */
-               IGNITION("Motor ignition"),
+               //// Motor ignition
+               IGNITION(trans.get("FlightEvent.Type.IGNITION")),
                /**
                 * When the motor has lifted off the ground.
                 */
-               LIFTOFF("Lift-off"),
+               //// Lift-off
+               LIFTOFF(trans.get("FlightEvent.Type.LIFTOFF")),
                /**
                 * Launch rod has been cleared.
                 */
-               LAUNCHROD("Launch rod clearance"),
+               //// Launch rod clearance
+               LAUNCHROD(trans.get("FlightEvent.Type.LAUNCHROD")),
                /** 
-                * Burnout of a motor.  Source is the motor mount the motor of which has burnt out. 
+                * Burnout of a motor.  Source is the motor mount the motor of which has burnt out,
+                * and the data is the MotorId of the motor instance.
                 */
-               BURNOUT("Motor burnout"),
+               //// Motor burnout
+               BURNOUT(trans.get("FlightEvent.Type.BURNOUT")),
                /** 
                 * Ejection charge of a motor fired.  Source is the motor mount the motor of
-                * which has exploded its ejection charge
+                * which has exploded its ejection charge, and data is the MotorId of the motor instance.
                 */
-               EJECTION_CHARGE("Ejection charge"),
+               //// Ejection charge
+               EJECTION_CHARGE(trans.get("FlightEvent.Type.EJECTION_CHARGE")),
                /** 
                 * Separation of a stage.  Source is the stage which has separated all lower stages. 
                 */
-               STAGE_SEPARATION("Stage separation"),
+               //// Stage separation
+               STAGE_SEPARATION(trans.get("FlightEvent.Type.STAGE_SEPARATION")),
                /** 
                 * Apogee has been reached.
                 */
-               APOGEE("Apogee"),
+               //// Apogee
+               APOGEE(trans.get("FlightEvent.Type.APOGEE")),
                /** 
                 * Opening of a recovery device.  Source is the RecoveryComponent which has opened. 
                 */
-               RECOVERY_DEVICE_DEPLOYMENT("Recovery device deployment"),
+               //// Recovery device deployment
+               RECOVERY_DEVICE_DEPLOYMENT(trans.get("FlightEvent.Type.RECOVERY_DEVICE_DEPLOYMENT")),
                /** 
                 * Ground has been hit after flight.
                 */
-               GROUND_HIT("Ground hit"),
-               
+               //// Ground hit
+               GROUND_HIT(trans.get("FlightEvent.Type.GROUND_HIT")),
+
                /**
                 * End of simulation.  Placing this to the queue will end the simulation.
                 */
-               SIMULATION_END("Simulation end"),
-               
+               //// Simulation end
+               SIMULATION_END(trans.get("FlightEvent.Type.SIMULATION_END")),
+
                /**
                 * A change in altitude has occurred.  Data is a <code>Pair<Double,Double></code>
                 * which contains the old and new altitudes.
                 */
-               ALTITUDE("Altitude change");
-
+               //// Altitude change
+               ALTITUDE(trans.get("FlightEvent.Type.ALTITUDE"));
+               
                private final String name;
+               
                private Type(String name) {
                        this.name = name;
                }
+               
                @Override
                public String toString() {
                        return name;
                }
        }
-
+       
        private final Type type;
        private final double time;
        private final RocketComponent source;
        private final Object data;
-
+       
        
        public FlightEvent(Type type, double time) {
                this(type, time, null);
        }
        
        public FlightEvent(Type type, double time, RocketComponent source) {
-               this(type,time,source,null);
+               this(type, time, source, null);
        }
-
+       
        public FlightEvent(Type type, double time, RocketComponent source, Object data) {
                this.type = type;
                this.time = time;
@@ -100,8 +119,8 @@ public class FlightEvent implements Comparable<FlightEvent> {
                this.data = data;
        }
        
-
        
+
        public Type getType() {
                return type;
        }
@@ -119,10 +138,18 @@ public class FlightEvent implements Comparable<FlightEvent> {
        }
        
        
-       public FlightEvent resetSource() {
-               return new FlightEvent(type, time, null, data);
+       /**
+        * Return a new FlightEvent with the same information as the current event
+        * but with <code>null</code> source.  This is used to avoid memory leakage by
+        * retaining references to obsolete components.
+        * 
+        * @return      a new FlightEvent with same type, time and data.
+        */
+       public FlightEvent resetSourceAndData() {
+               return new FlightEvent(type, time, null, null);
        }
-
+       
+       
        /**
         * Compares this event to another event depending on the event time.  Secondary
         * sorting is performed based on the event type ordinal.
@@ -139,6 +166,6 @@ public class FlightEvent implements Comparable<FlightEvent> {
        
        @Override
        public String toString() {
-               return "FlightEvent[type="+type.name()+",time="+time+",source="+source+"]";
+               return "FlightEvent[type=" + type.name() + ",time=" + time + ",source=" + source + "]";
        }
 }