import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import net.sf.openrocket.file.RocketSaver;
+import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.motor.ThrustCurveMotor;
+import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.LineStyle;
public class RocketComponentSaver {
+ private static final Translator trans = Application.getTranslator();
protected RocketComponentSaver() {
// Prevent instantiation from outside the package
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
elements.add("<name>" + RocketSaver.escapeXML(c.getName()) + "</name>");
-
+ ComponentPreset preset = c.getPresetComponent();
+ if (preset != null) {
+ elements.add("<preset type=\"" + preset.getType() +
+ "\" manufacturer=\"" + preset.getManufacturer().getSimpleName() +
+ "\" partno=\"" + preset.getPartNo() + "\" digest=\"" + preset.getDigest() + "\"/>");
+ }
+
+
// Save color and line style if significant
if (!(c instanceof Rocket || c instanceof ComponentAssembly)) {
Color color = c.getColor();
LineStyle style = c.getLineStyle();
if (style != null) {
// Type names currently equivalent to the enum names except for case.
- elements.add("<linestyle>" + style.name().toLowerCase() + "</linestyle>");
+ elements.add("<linestyle>" + style.name().toLowerCase(Locale.ENGLISH) + "</linestyle>");
}
}
-
+
// Save position unless "AFTER"
if (c.getRelativePosition() != RocketComponent.Position.AFTER) {
// The type names are currently equivalent to the enum names except for case.
- String type = c.getRelativePosition().name().toLowerCase();
+ String type = c.getRelativePosition().name().toLowerCase(Locale.ENGLISH);
elements.add("<position type=\"" + type + "\">" + c.getPositionValue() + "</position>");
}
-
+
// Overrides
boolean overridden = false;
if (c.isMassOverridden()) {
+ "</overridesubcomponents>");
}
-
+
// Comment
if (c.getComment().length() > 0) {
elements.add("<comment>" + RocketSaver.escapeXML(c.getComment()) + "</comment>");
}
-
-
+
+
protected final String materialParam(Material mat) {
return materialParam("material", mat);
}
throw new BugException("Unknown material type: " + mat.getType());
}
- return str + " density=\"" + mat.getDensity() + "\">" + RocketSaver.escapeXML(mat.getName()) + "</" + tag + ">";
+ String baseName = trans.getBaseText("material", mat.getName());
+
+ return str + " density=\"" + mat.getDensity() + "\">" + RocketSaver.escapeXML(baseName) + "</" + tag + ">";
}
elements.add(" <motor configid=\"" + id + "\">");
if (motor.getMotorType() != Motor.Type.UNKNOWN) {
- elements.add(" <type>" + motor.getMotorType().name().toLowerCase() + "</type>");
+ elements.add(" <type>" + motor.getMotorType().name().toLowerCase(Locale.ENGLISH) + "</type>");
}
if (motor instanceof ThrustCurveMotor) {
ThrustCurveMotor m = (ThrustCurveMotor) motor;
}
elements.add(" <ignitionevent>"
- + mount.getIgnitionEvent().name().toLowerCase().replace("_", "")
+ + mount.getIgnitionEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "")
+ "</ignitionevent>");
elements.add(" <ignitiondelay>" + mount.getIgnitionDelay() + "</ignitiondelay>");