package net.sf.openrocket.rocketcomponent;
+import net.sf.openrocket.l10n.Translator;
+import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.simulation.FlightEvent;
+import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.ChangeSource;
+import net.sf.openrocket.util.Coordinate;
public interface MotorMount extends ChangeSource {
public static enum IgnitionEvent {
- AUTOMATIC("Automatic (launch or ejection charge)") {
+ //// Automatic (launch or ejection charge)
+ AUTOMATIC("MotorMount.IgnitionEvent.AUTOMATIC") {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
int count = source.getRocket().getStageCount();
int stage = source.getStageNumber();
- if (stage == count-1) {
+ if (stage == count - 1) {
return LAUNCH.isActivationEvent(e, source);
} else {
return EJECTION_CHARGE.isActivationEvent(e, source);
}
}
},
- LAUNCH("Launch") {
+ //// Launch
+ LAUNCH("MotorMount.IgnitionEvent.LAUNCH") {
@Override
- public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
+ public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return (e.getType() == FlightEvent.Type.LAUNCH);
}
},
- EJECTION_CHARGE("First ejection charge of previous stage") {
+ //// First ejection charge of previous stage
+ EJECTION_CHARGE("MotorMount.IgnitionEvent.EJECTION_CHARGE") {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
if (e.getType() != FlightEvent.Type.EJECTION_CHARGE)
return false;
-
+
int charge = e.getSource().getStageNumber();
int mount = source.getStageNumber();
- return (mount+1 == charge);
+ return (mount + 1 == charge);
}
},
- BURNOUT("First burnout of previous stage") {
+ //// First burnout of previous stage
+ BURNOUT("MotorMount.IgnitionEvent.BURNOUT") {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
if (e.getType() != FlightEvent.Type.BURNOUT)
return false;
-
+
int charge = e.getSource().getStageNumber();
int mount = source.getStageNumber();
- return (mount+1 == charge);
+ return (mount + 1 == charge);
}
},
- NEVER("Never") {
+ //// Never
+ NEVER("MotorMount.IgnitionEvent.NEVER") {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return false;
},
;
-
+
+ private static final Translator trans = Application.getTranslator();
private final String description;
IgnitionEvent(String description) {
@Override
public String toString() {
- return description;
+ return trans.get(description);
}
};
/**
* Return the motor for the motor configuration. May return <code>null</code>
* if no motor has been set. This method must return <code>null</code> if ID
- * is <code>null</code>.
+ * is <code>null</code> or if the ID is not valid for the current rocket
+ * (or if the component is not part of any rocket).
*
* @param id the motor configuration ID
* @return the motor, or <code>null</code> if not set.
* @param motor the motor, or <code>null</code>.
*/
public void setMotor(String id, Motor motor);
-
+
/**
* Get the number of similar motors clustered.
*
+ * TODO: HIGH: This should not be used, since the components themselves can be clustered
+ *
* @return the number of motors.
*/
+ @Deprecated
public int getMotorCount();
-
+
/**
* Return the ejection charge delay of given motor configuration.
* A "plugged" motor without an ejection charge is given by
public void setMotorOverhang(double overhang);
-
+
/**
* Return the inner diameter of the motor mount.
*
*/
public double getMotorMountDiameter();
+
+ /**
+ * Return the position of the motor relative to this component. The coordinate
+ * is that of the front cap of the motor.
+ *
+ * @return the position of the motor relative to this component.
+ * @throws IllegalArgumentException if a motor with the specified ID does not exist.
+ */
+ public Coordinate getMotorPosition(String id);
+
}