summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
df62f23)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@488
180e2498-e6e9-4542-8430-
84ac67f01cd8
28 files changed:
+2012-03-25 Sampo Niskanen
+
+ * [BUG] Removed locale-specific toLowerCase/toUpperCase
+
2012-03-25 Doug Pedrick
* Printed rocket figure in design report now honors rotation angle of main figure; fixed bug in layout where the
2012-03-25 Doug Pedrick
* Printed rocket figure in design report now honors rotation angle of main figure; fixed bug in layout where the
package net.sf.openrocket.arch;
import java.io.File;
package net.sf.openrocket.arch;
import java.io.File;
+import java.util.Locale;
import net.sf.openrocket.util.BugException;
public class SystemInfo {
import net.sf.openrocket.util.BugException;
public class SystemInfo {
/**
* Enumeration of supported operating systems.
*
/**
* Enumeration of supported operating systems.
*
* @return the operating system of the current system.
*/
public static Platform getPlatform() {
* @return the operating system of the current system.
*/
public static Platform getPlatform() {
- String os = System.getProperty("os.name").toLowerCase();
+ String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
if (os.indexOf("win") >= 0) {
return Platform.WINDOWS;
if (os.indexOf("win") >= 0) {
return Platform.WINDOWS;
/**
* Return the application data directory of this user. The location depends
* on the current platform.
/**
* Return the application data directory of this user. The location depends
* on the current platform.
/**
* Parse the data received from the server.
*
/**
* Parse the data received from the server.
*
reader = new BufferedReader(r);
}
reader = new BufferedReader(r);
}
String version = null;
ArrayList<ComparablePair<Integer, String>> updates =
new ArrayList<ComparablePair<Integer, String>>();
String version = null;
ArrayList<ComparablePair<Integer, String>> updates =
new ArrayList<ComparablePair<Integer, String>>();
/**
* An asynchronous task that fetches and parses the update info.
*
/**
* An asynchronous task that fetches and parses the update info.
*
String contentType = connection.getContentType();
if (contentType == null ||
String contentType = connection.getContentType();
if (contentType == null ||
- contentType.toLowerCase().indexOf(Communicator.UPDATE_INFO_CONTENT_TYPE) < 0) {
+ contentType.toLowerCase(Locale.ENGLISH).indexOf(Communicator.UPDATE_INFO_CONTENT_TYPE) < 0) {
// Unknown response type
log.warn("Unknown Content-type received:" + contentType);
return;
// Unknown response type
log.warn("Unknown Content-type received:" + contentType);
return;
info = new UpdateInfo(version, updates);
log.info("Found update: " + info);
} finally {
info = new UpdateInfo(version, updates);
log.info("Found update: " + info);
} finally {
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.zip.GZIPOutputStream;
import net.sf.openrocket.aerodynamics.Warning;
import java.util.zip.GZIPOutputStream;
import net.sf.openrocket.aerodynamics.Warning;
writeElement("launchaltitude", cond.getLaunchAltitude());
writeElement("launchlatitude", cond.getLaunchLatitude());
writeElement("launchlongitude", cond.getLaunchLongitude());
writeElement("launchaltitude", cond.getLaunchAltitude());
writeElement("launchlatitude", cond.getLaunchLatitude());
writeElement("launchlongitude", cond.getLaunchLongitude());
- writeElement("geodeticmethod", cond.getGeodeticComputation().name().toLowerCase());
+ writeElement("geodeticmethod", cond.getGeodeticComputation().name().toLowerCase(Locale.ENGLISH));
if (cond.isISAAtmosphere()) {
writeln("<atmosphere model=\"isa\"/>");
if (cond.isISAAtmosphere()) {
writeln("<atmosphere model=\"isa\"/>");
* @return the corresponding XML name.
*/
public static String enumToXMLName(Enum<?> e) {
* @return the corresponding XML name.
*/
public static String enumToXMLName(Enum<?> e) {
- return e.name().toLowerCase().replace("_", "");
+ return e.name().toLowerCase(Locale.ENGLISH).replace("_", "");
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
return null;
name = name.trim();
for (Enum<T> e : enumClass.getEnumConstants()) {
return null;
name = name.trim();
for (Enum<T> e : enumClass.getEnumConstants()) {
- if (e.name().toLowerCase().replace("_", "").equals(name)) {
+ if (e.name().toLowerCase(Locale.ENGLISH).replace("_", "").equals(name)) {
if (element.equals("ignitionevent")) {
MotorMount.IgnitionEvent event = null;
for (MotorMount.IgnitionEvent e : MotorMount.IgnitionEvent.values()) {
if (element.equals("ignitionevent")) {
MotorMount.IgnitionEvent event = null;
for (MotorMount.IgnitionEvent e : MotorMount.IgnitionEvent.values()) {
- if (e.name().toLowerCase().replaceAll("_", "").equals(content)) {
+ if (e.name().toLowerCase(Locale.ENGLISH).replaceAll("_", "").equals(content)) {
// Motor type
type = null;
for (Motor.Type t : Motor.Type.values()) {
// Motor type
type = null;
for (Motor.Type t : Motor.Type.values()) {
- if (t.name().toLowerCase().equals(content.trim())) {
+ if (t.name().toLowerCase(Locale.ENGLISH).equals(content.trim())) {
// Check type if specified
str = attributes.remove("type");
// Check type if specified
str = attributes.remove("type");
- if (str != null && !type.name().toLowerCase().equals(str)) {
+ if (str != null && !type.name().toLowerCase(Locale.ENGLISH).equals(str)) {
warnings.add(Warning.fromString("Illegal material type specified, ignoring."));
return;
}
warnings.add(Warning.fromString("Illegal material type specified, ignoring."));
return;
}
package net.sf.openrocket.file.openrocket.savers;
import java.util.List;
package net.sf.openrocket.file.openrocket.savers;
import java.util.List;
+import java.util.Locale;
import net.sf.openrocket.rocketcomponent.ExternalComponent;
public class ExternalComponentSaver extends RocketComponentSaver {
import net.sf.openrocket.rocketcomponent.ExternalComponent;
public class ExternalComponentSaver extends RocketComponentSaver {
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
- ExternalComponent ext = (ExternalComponent)c;
+ ExternalComponent ext = (ExternalComponent) c;
// Finish enum names are currently the same except for case
// Finish enum names are currently the same except for case
- elements.add("<finish>" + ext.getFinish().name().toLowerCase() + "</finish>");
+ elements.add("<finish>" + ext.getFinish().name().toLowerCase(Locale.ENGLISH) + "</finish>");
// Material
elements.add(materialParam(ext.getMaterial()));
}
// Material
elements.add(materialParam(ext.getMaterial()));
}
package net.sf.openrocket.file.openrocket.savers;
import java.util.List;
package net.sf.openrocket.file.openrocket.savers;
import java.util.List;
+import java.util.Locale;
import net.sf.openrocket.util.MathUtil;
public class FinSetSaver extends ExternalComponentSaver {
import net.sf.openrocket.util.MathUtil;
public class FinSetSaver extends ExternalComponentSaver {
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
net.sf.openrocket.rocketcomponent.FinSet fins = (net.sf.openrocket.rocketcomponent.FinSet) c;
elements.add("<fincount>" + fins.getFinCount() + "</fincount>");
elements.add("<rotation>" + (fins.getBaseRotation() * 180.0 / Math.PI) + "</rotation>");
elements.add("<thickness>" + fins.getThickness() + "</thickness>");
net.sf.openrocket.rocketcomponent.FinSet fins = (net.sf.openrocket.rocketcomponent.FinSet) c;
elements.add("<fincount>" + fins.getFinCount() + "</fincount>");
elements.add("<rotation>" + (fins.getBaseRotation() * 180.0 / Math.PI) + "</rotation>");
elements.add("<thickness>" + fins.getThickness() + "</thickness>");
- elements.add("<crosssection>" + fins.getCrossSection().name().toLowerCase()
+ elements.add("<crosssection>" + fins.getCrossSection().name().toLowerCase(Locale.ENGLISH)
+ "</crosssection>");
elements.add("<cant>" + (fins.getCantAngle() * 180.0 / Math.PI) + "</cant>");
// Save fin tabs only if they exist (compatibility with file version < 1.1)
+ "</crosssection>");
elements.add("<cant>" + (fins.getCantAngle() * 180.0 / Math.PI) + "</cant>");
// Save fin tabs only if they exist (compatibility with file version < 1.1)
- if (!MathUtil.equals(fins.getTabHeight(),0) &&
+ if (!MathUtil.equals(fins.getTabHeight(), 0) &&
!MathUtil.equals(fins.getTabLength(), 0)) {
elements.add("<tabheight>" + fins.getTabHeight() + "</tabheight>");
elements.add("<tablength>" + fins.getTabLength() + "</tablength>");
elements.add("<tabposition relativeto=\"" +
!MathUtil.equals(fins.getTabLength(), 0)) {
elements.add("<tabheight>" + fins.getTabHeight() + "</tabheight>");
elements.add("<tablength>" + fins.getTabLength() + "</tablength>");
elements.add("<tabposition relativeto=\"" +
- fins.getTabRelativePosition().name().toLowerCase() + "\">" +
+ fins.getTabRelativePosition().name().toLowerCase(Locale.ENGLISH) + "\">" +
fins.getTabShift() + "</tabposition>");
fins.getTabShift() + "</tabposition>");
package net.sf.openrocket.file.openrocket.savers;
import java.util.List;
package net.sf.openrocket.file.openrocket.savers;
import java.util.List;
+import java.util.Locale;
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
public class RecoveryDeviceSaver extends MassObjectSaver {
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
public class RecoveryDeviceSaver extends MassObjectSaver {
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
RecoveryDevice dev = (RecoveryDevice) c;
RecoveryDevice dev = (RecoveryDevice) c;
if (dev.isCDAutomatic())
elements.add("<cd>auto</cd>");
else
elements.add("<cd>" + dev.getCD() + "</cd>");
if (dev.isCDAutomatic())
elements.add("<cd>auto</cd>");
else
elements.add("<cd>" + dev.getCD() + "</cd>");
-
- elements.add("<deployevent>" + dev.getDeployEvent().name().toLowerCase() + "</deployevent>");
+
+ elements.add("<deployevent>" + dev.getDeployEvent().name().toLowerCase(Locale.ENGLISH) + "</deployevent>");
elements.add("<deployaltitude>" + dev.getDeployAltitude() + "</deployaltitude>");
elements.add("<deploydelay>" + dev.getDeployDelay() + "</deploydelay>");
elements.add(materialParam(dev.getMaterial()));
}
elements.add("<deployaltitude>" + dev.getDeployAltitude() + "</deployaltitude>");
elements.add("<deploydelay>" + dev.getDeployDelay() + "</deploydelay>");
elements.add(materialParam(dev.getMaterial()));
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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.material.Material;
import net.sf.openrocket.file.RocketSaver;
import net.sf.openrocket.material.Material;
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
elements.add("<name>" + RocketSaver.escapeXML(c.getName()) + "</name>");
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
elements.add("<name>" + RocketSaver.escapeXML(c.getName()) + "</name>");
// Save color and line style if significant
if (!(c instanceof Rocket || c instanceof ComponentAssembly)) {
Color color = c.getColor();
// 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.
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.
// 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>");
}
elements.add("<position type=\"" + type + "\">" + c.getPositionValue() + "</position>");
}
// Overrides
boolean overridden = false;
if (c.isMassOverridden()) {
// Overrides
boolean overridden = false;
if (c.isMassOverridden()) {
+ "</overridesubcomponents>");
}
+ "</overridesubcomponents>");
}
// Comment
if (c.getComment().length() > 0) {
elements.add("<comment>" + RocketSaver.escapeXML(c.getComment()) + "</comment>");
// Comment
if (c.getComment().length() > 0) {
elements.add("<comment>" + RocketSaver.escapeXML(c.getComment()) + "</comment>");
protected final String materialParam(Material mat) {
return materialParam("material", mat);
}
protected final String materialParam(Material mat) {
return materialParam("material", mat);
}
elements.add(" <motor configid=\"" + id + "\">");
if (motor.getMotorType() != Motor.Type.UNKNOWN) {
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;
}
if (motor instanceof ThrustCurveMotor) {
ThrustCurveMotor m = (ThrustCurveMotor) motor;
}
elements.add(" <ignitionevent>"
}
elements.add(" <ignitionevent>"
- + mount.getIgnitionEvent().name().toLowerCase().replace("_", "")
+ + mount.getIgnitionEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "")
+ "</ignitionevent>");
elements.add(" <ignitiondelay>" + mount.getIgnitionDelay() + "</ignitiondelay>");
+ "</ignitionevent>");
elements.add(" <ignitiondelay>" + mount.getIgnitionDelay() + "</ignitiondelay>");
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import net.sf.openrocket.rocketcomponent.ReferenceType;
import net.sf.openrocket.rocketcomponent.Rocket;
public class RocketSaver extends RocketComponentSaver {
import net.sf.openrocket.rocketcomponent.ReferenceType;
import net.sf.openrocket.rocketcomponent.Rocket;
public class RocketSaver extends RocketComponentSaver {
private static final RocketSaver instance = new RocketSaver();
private static final RocketSaver instance = new RocketSaver();
public static ArrayList<String> getElements(net.sf.openrocket.rocketcomponent.RocketComponent c) {
ArrayList<String> list = new ArrayList<String>();
public static ArrayList<String> getElements(net.sf.openrocket.rocketcomponent.RocketComponent c) {
ArrayList<String> list = new ArrayList<String>();
list.add("<rocket>");
instance.addParams(c, list);
list.add("</rocket>");
list.add("<rocket>");
instance.addParams(c, list);
list.add("</rocket>");
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
Rocket rocket = (Rocket) c;
if (rocket.getDesigner().length() > 0) {
Rocket rocket = (Rocket) c;
if (rocket.getDesigner().length() > 0) {
- elements.add("<designer>"
+ elements.add("<designer>"
+ net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getDesigner())
+ "</designer>");
}
if (rocket.getRevision().length() > 0) {
+ net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getDesigner())
+ "</designer>");
}
if (rocket.getRevision().length() > 0) {
- elements.add("<revision>"
- + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getRevision())
+ elements.add("<revision>"
+ + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getRevision())
// Motor configurations
String defId = rocket.getDefaultConfiguration().getMotorConfigurationID();
for (String id : rocket.getMotorConfigurationIDs()) {
if (id == null)
continue;
// Motor configurations
String defId = rocket.getDefaultConfiguration().getMotorConfigurationID();
for (String id : rocket.getMotorConfigurationIDs()) {
if (id == null)
continue;
String str = "<motorconfiguration configid=\"" + id + "\"";
if (id.equals(defId))
str += " default=\"true\"";
String str = "<motorconfiguration configid=\"" + id + "\"";
if (id.equals(defId))
str += " default=\"true\"";
str += "/>";
} else {
str += "><name>" + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getMotorConfigurationName(id))
str += "/>";
} else {
str += "><name>" + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getMotorConfigurationName(id))
- + "</name></motorconfiguration>";
+ + "</name></motorconfiguration>";
}
elements.add(str);
}
// Reference diameter
}
elements.add(str);
}
// Reference diameter
- elements.add("<referencetype>" + rocket.getReferenceType().name().toLowerCase()
+ elements.add("<referencetype>" + rocket.getReferenceType().name().toLowerCase(Locale.ENGLISH)
+ "</referencetype>");
if (rocket.getReferenceType() == ReferenceType.CUSTOM) {
elements.add("<customreference>" + rocket.getCustomReferenceLength()
+ "</customreference>");
}
+ "</referencetype>");
if (rocket.getReferenceType() == ReferenceType.CUSTOM) {
elements.add("<customreference>" + rocket.getCustomReferenceLength()
+ "</customreference>");
}
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Stage;
if (stage.getStageNumber() > 0) {
elements.add("<separationevent>"
if (stage.getStageNumber() > 0) {
elements.add("<separationevent>"
- + stage.getSeparationEvent().name().toLowerCase().replace("_", "")
+ + stage.getSeparationEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "")
+ "</separationevent>");
elements.add("<separationdelay>" + stage.getSeparationDelay() + "</separationdelay>");
}
+ "</separationevent>");
elements.add("<separationdelay>" + stage.getSeparationDelay() + "</separationdelay>");
}
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.Transition;
public class TransitionSaver extends SymmetricComponentSaver {
import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.Transition;
public class TransitionSaver extends SymmetricComponentSaver {
private static final TransitionSaver instance = new TransitionSaver();
private static final TransitionSaver instance = new TransitionSaver();
public static ArrayList<String> getElements(net.sf.openrocket.rocketcomponent.RocketComponent c) {
ArrayList<String> list = new ArrayList<String>();
public static ArrayList<String> getElements(net.sf.openrocket.rocketcomponent.RocketComponent c) {
ArrayList<String> list = new ArrayList<String>();
list.add("<transition>");
instance.addParams(c, list);
list.add("</transition>");
list.add("<transition>");
instance.addParams(c, list);
list.add("</transition>");
/*
* Note: This method must be capable of handling nose cones as well.
*/
/*
* Note: This method must be capable of handling nose cones as well.
*/
super.addParams(c, elements);
net.sf.openrocket.rocketcomponent.Transition trans = (net.sf.openrocket.rocketcomponent.Transition) c;
boolean nosecone = (trans instanceof NoseCone);
super.addParams(c, elements);
net.sf.openrocket.rocketcomponent.Transition trans = (net.sf.openrocket.rocketcomponent.Transition) c;
boolean nosecone = (trans instanceof NoseCone);
Transition.Shape shape = trans.getType();
Transition.Shape shape = trans.getType();
- elements.add("<shape>" + shape.name().toLowerCase() + "</shape>");
+ elements.add("<shape>" + shape.name().toLowerCase(Locale.ENGLISH) + "</shape>");
if (shape.isClippable()) {
elements.add("<shapeclipped>" + trans.isClipped() + "</shapeclipped>");
}
if (shape.usesParameter()) {
elements.add("<shapeparameter>" + trans.getShapeParameter() + "</shapeparameter>");
}
if (shape.isClippable()) {
elements.add("<shapeclipped>" + trans.isClipped() + "</shapeclipped>");
}
if (shape.usesParameter()) {
elements.add("<shapeparameter>" + trans.getShapeParameter() + "</shapeparameter>");
}
if (!nosecone) {
if (trans.isForeRadiusAutomatic())
elements.add("<foreradius>auto</foreradius>");
else
elements.add("<foreradius>" + trans.getForeRadius() + "</foreradius>");
}
if (!nosecone) {
if (trans.isForeRadiusAutomatic())
elements.add("<foreradius>auto</foreradius>");
else
elements.add("<foreradius>" + trans.getForeRadius() + "</foreradius>");
}
if (trans.isAftRadiusAutomatic())
elements.add("<aftradius>auto</aftradius>");
else
elements.add("<aftradius>" + trans.getAftRadius() + "</aftradius>");
if (trans.isAftRadiusAutomatic())
elements.add("<aftradius>auto</aftradius>");
else
elements.add("<aftradius>" + trans.getAftRadius() + "</aftradius>");
if (!nosecone) {
elements.add("<foreshoulderradius>" + trans.getForeShoulderRadius()
+ "</foreshoulderradius>");
if (!nosecone) {
elements.add("<foreshoulderradius>" + trans.getForeShoulderRadius()
+ "</foreshoulderradius>");
elements.add("<foreshouldercapped>" + trans.isForeShoulderCapped()
+ "</foreshouldercapped>");
}
elements.add("<foreshouldercapped>" + trans.isForeShoulderCapped()
+ "</foreshouldercapped>");
}
elements.add("<aftshoulderradius>" + trans.getAftShoulderRadius()
+ "</aftshoulderradius>");
elements.add("<aftshoulderlength>" + trans.getAftShoulderLength()
elements.add("<aftshoulderradius>" + trans.getAftShoulderRadius()
+ "</aftshoulderradius>");
elements.add("<aftshoulderlength>" + trans.getAftShoulderLength()
elements.add("<aftshouldercapped>" + trans.isAftShoulderCapped()
+ "</aftshouldercapped>");
}
elements.add("<aftshouldercapped>" + trans.isAftShoulderCapped()
+ "</aftshouldercapped>");
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.BorderFactory;
import javax.swing.JButton;
private final List<Invalidatable> invalidatables = new ArrayList<Invalidatable>();
private final List<Invalidatable> invalidatables = new ArrayList<Invalidatable>();
protected final JTextField componentNameField;
protected JTextArea commentTextArea;
private final TextFieldListener textFieldListener;
protected final JTextField componentNameField;
protected JTextArea commentTextArea;
private final TextFieldListener textFieldListener;
componentNameField.setToolTipText(trans.get("RocketCompCfg.ttip.Thecomponentname"));
this.add(componentNameField, "growx, growy 0, wrap");
componentNameField.setToolTipText(trans.get("RocketCompCfg.ttip.Thecomponentname"));
this.add(componentNameField, "growx, growy 0, wrap");
tabbedPane = new JTabbedPane();
this.add(tabbedPane, "growx, growy 1, wrap");
tabbedPane = new JTabbedPane();
this.add(tabbedPane, "growx, growy 1, wrap");
combo.setToolTipText(trans.get("RocketCompCfg.combo.ttip.componentmaterialaffects"));
panel.add(combo, "spanx 4, growx, wrap paragraph");
combo.setToolTipText(trans.get("RocketCompCfg.combo.ttip.componentmaterialaffects"));
panel.add(combo, "spanx 4, growx, wrap paragraph");
if (component instanceof ExternalComponent) {
label = new JLabel(finishString);
////<html>The component finish affects the aerodynamic drag of the component.<br>
if (component instanceof ExternalComponent) {
label = new JLabel(finishString);
////<html>The component finish affects the aerodynamic drag of the component.<br>
bm.addEnableComponent(bs);
panel.add(bs, "growx 5, w 100lp, wrap");
bm.addEnableComponent(bs);
panel.add(bs, "growx 5, w 100lp, wrap");
//// CG override
bm = new BooleanModel(component, "CGOverridden");
check = new JCheckBox(bm);
//// CG override
bm = new BooleanModel(component, "CGOverridden");
check = new JCheckBox(bm);
bm.addEnableComponent(bs);
panel.add(bs, "growx 5, w 100lp, wrap 35lp");
bm.addEnableComponent(bs);
panel.add(bs, "growx 5, w 100lp, wrap 35lp");
// Override subcomponents checkbox
bm = new BooleanModel(component, "OverrideSubcomponents");
check = new JCheckBox(bm);
// Override subcomponents checkbox
bm = new BooleanModel(component, "OverrideSubcomponents");
check = new JCheckBox(bm);
panel.add(new StyledLabel(trans.get("RocketCompCfg.lbl.longB1") +
//// The center of gravity is measured from the front end of the
trans.get("RocketCompCfg.lbl.longB2") + " " +
panel.add(new StyledLabel(trans.get("RocketCompCfg.lbl.longB1") +
//// The center of gravity is measured from the front end of the
trans.get("RocketCompCfg.lbl.longB2") + " " +
- component.getComponentName().toLowerCase() + ".", -1),
+ component.getComponentName().toLowerCase(Locale.getDefault()) + ".", -1),
"spanx, wrap, gap para, height 0::30lp");
return panel;
"spanx, wrap, gap para, height 0::30lp");
return panel;
private JPanel figureTab() {
JPanel panel = new JPanel(new MigLayout("align 20% 20%"));
private JPanel figureTab() {
JPanel panel = new JPanel(new MigLayout("align 20% 20%"));
- Color awtColor = ColorConversion.toAwtColor(c);
+ Color awtColor = ColorConversion.toAwtColor(c);
awtColor = JColorChooser.showDialog(tabbedPane, trans.get("RocketCompCfg.lbl.Choosecolor"), awtColor);
c = ColorConversion.fromAwtColor(awtColor);
if (c != null) {
awtColor = JColorChooser.showDialog(tabbedPane, trans.get("RocketCompCfg.lbl.Choosecolor"), awtColor);
c = ColorConversion.fromAwtColor(awtColor);
if (c != null) {
protected JPanel shoulderTab() {
JPanel panel = new JPanel(new MigLayout("fill"));
JPanel sub;
protected JPanel shoulderTab() {
JPanel panel = new JPanel(new MigLayout("fill"));
JPanel sub;
JCheckBox check;
JSpinner spin;
JCheckBox check;
JSpinner spin;
//// Fore shoulder, not for NoseCone
if (!(component instanceof NoseCone)) {
//// Fore shoulder, not for NoseCone
if (!(component instanceof NoseCone)) {
//// Fore shoulder
sub.setBorder(BorderFactory.createTitledBorder(trans.get("RocketCompCfg.border.Foreshoulder")));
//// Fore shoulder
sub.setBorder(BorderFactory.createTitledBorder(trans.get("RocketCompCfg.border.Foreshoulder")));
//// Radius
//// Diameter:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Diameter")));
//// Radius
//// Diameter:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Diameter")));
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
//// Length:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Length")));
//// Length:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Length")));
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(0, 0.02, 0.2)), "w 100lp, wrap");
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(0, 0.02, 0.2)), "w 100lp, wrap");
//// Thickness:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Thickness")));
//// Thickness:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Thickness")));
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
//// Capped
bm = new BooleanModel(component, "ForeShoulderCapped");
check = new JCheckBox(bm);
//// Capped
bm = new BooleanModel(component, "ForeShoulderCapped");
check = new JCheckBox(bm);
check.setToolTipText(trans.get("RocketCompCfg.ttip.Endcapped"));
sub.add(check, "spanx");
check.setToolTipText(trans.get("RocketCompCfg.ttip.Endcapped"));
sub.add(check, "spanx");
//// Aft shoulder
sub = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]", ""));
//// Aft shoulder
sub = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]", ""));
//// Aft shoulder
sub.setBorder(BorderFactory.createTitledBorder(trans.get("RocketCompCfg.title.Aftshoulder")));
//// Aft shoulder
sub.setBorder(BorderFactory.createTitledBorder(trans.get("RocketCompCfg.title.Aftshoulder")));
//// Radius
//// Diameter:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Diameter")));
//// Radius
//// Diameter:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Diameter")));
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
//// Length:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Length")));
//// Length:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Length")));
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(0, 0.02, 0.2)), "w 100lp, wrap");
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(0, 0.02, 0.2)), "w 100lp, wrap");
//// Thickness:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Thickness")));
//// Thickness:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Thickness")));
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
sub.add(new UnitSelector(m), "growx");
sub.add(new BasicSlider(m.getSliderModel(m0, m2)), "w 100lp, wrap");
//// Capped
bm = new BooleanModel(component, "AftShoulderCapped");
check = new JCheckBox(bm);
//// Capped
bm = new BooleanModel(component, "AftShoulderCapped");
check = new JCheckBox(bm);
check.setToolTipText(trans.get("RocketCompCfg.ttip.Endcapped"));
sub.add(check, "spanx");
check.setToolTipText(trans.get("RocketCompCfg.ttip.Endcapped"));
sub.add(check, "spanx");
/*
* Private inner class to handle events in componentNameField.
*/
/*
* Private inner class to handle events in componentNameField.
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.prefs.Preferences;
import javax.swing.BorderFactory;
import java.util.prefs.Preferences;
import javax.swing.BorderFactory;
String[] split = text.split("\\s+");
ArrayList<String> list = new ArrayList<String>();
for (String s : split) {
String[] split = text.split("\\s+");
ArrayList<String> list = new ArrayList<String>();
for (String s : split) {
- s = s.trim().toLowerCase();
+ s = s.trim().toLowerCase(Locale.getDefault());
if (s.length() > 0) {
list.add(s);
}
if (s.length() > 0) {
list.add(s);
}
public boolean filterByString(ThrustCurveMotorSet m) {
main: for (String s : searchTerms) {
for (ThrustCurveMotorColumns col : ThrustCurveMotorColumns.values()) {
public boolean filterByString(ThrustCurveMotorSet m) {
main: for (String s : searchTerms) {
for (ThrustCurveMotorColumns col : ThrustCurveMotorColumns.values()) {
- String str = col.getValue(m).toString().toLowerCase();
+ String str = col.getValue(m).toString().toLowerCase(Locale.getDefault());
if (str.indexOf(s) >= 0)
continue main;
}
if (str.indexOf(s) >= 0)
continue main;
}
//////////////////////////
private static final LogHelper log = Application.getLogger();
//////////////////////////
private static final LogHelper log = Application.getLogger();
- country = country.toUpperCase();
+ country = country.toUpperCase(Locale.ENGLISH);
for (String c : letterCountries) {
if (c.equals(country)) {
return LETTER;
for (String c : letterCountries) {
if (c.equals(country)) {
return LETTER;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.EventObject;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.EventObject;
+import java.util.Locale;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JComboBox;
import net.sf.openrocket.util.StateChangeListener;
public class ScaleSelector extends JPanel {
import net.sf.openrocket.util.StateChangeListener;
public class ScaleSelector extends JPanel {
// Ready zoom settings
private static final DecimalFormat PERCENT_FORMAT = new DecimalFormat("0.#%");
// Ready zoom settings
private static final DecimalFormat PERCENT_FORMAT = new DecimalFormat("0.#%");
-
- private static final double[] ZOOM_LEVELS = { 0.15, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0 };
+
+ private static final double[] ZOOM_LEVELS = { 0.15, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0 };
private static final String ZOOM_FIT = "Fit";
private static final String[] ZOOM_SETTINGS;
static {
private static final String ZOOM_FIT = "Fit";
private static final String[] ZOOM_SETTINGS;
static {
- ZOOM_SETTINGS = new String[ZOOM_LEVELS.length+1];
- for (int i=0; i<ZOOM_LEVELS.length; i++)
+ ZOOM_SETTINGS = new String[ZOOM_LEVELS.length + 1];
+ for (int i = 0; i < ZOOM_LEVELS.length; i++)
ZOOM_SETTINGS[i] = PERCENT_FORMAT.format(ZOOM_LEVELS[i]);
ZOOM_SETTINGS[i] = PERCENT_FORMAT.format(ZOOM_LEVELS[i]);
- ZOOM_SETTINGS[ZOOM_SETTINGS.length-1] = ZOOM_FIT;
+ ZOOM_SETTINGS[ZOOM_SETTINGS.length - 1] = ZOOM_FIT;
public ScaleSelector(ScaleScrollPane scroll) {
super(new MigLayout());
public ScaleSelector(ScaleScrollPane scroll) {
super(new MigLayout());
this.scrollPane = scroll;
// Zoom out button
JButton button = new JButton(Icons.ZOOM_OUT);
button.addActionListener(new ActionListener() {
this.scrollPane = scroll;
// Zoom out button
JButton button = new JButton(Icons.ZOOM_OUT);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
double scale = scrollPane.getScaling();
scale = getPreviousScale(scale);
public void actionPerformed(ActionEvent e) {
double scale = scrollPane.getScaling();
scale = getPreviousScale(scale);
}
});
add(button, "gap");
}
});
add(button, "gap");
// Zoom level selector
String[] settings = ZOOM_SETTINGS;
if (!scrollPane.isFittingAllowed()) {
// Zoom level selector
String[] settings = ZOOM_SETTINGS;
if (!scrollPane.isFittingAllowed()) {
- settings = Arrays.copyOf(settings, settings.length-1);
+ settings = Arrays.copyOf(settings, settings.length - 1);
}
zoomSelector = new JComboBox(settings);
zoomSelector.setEditable(true);
setZoomText();
zoomSelector.addActionListener(new ActionListener() {
}
zoomSelector = new JComboBox(settings);
zoomSelector.setEditable(true);
setZoomText();
zoomSelector.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
public void actionPerformed(ActionEvent e) {
try {
- String text = (String)zoomSelector.getSelectedItem();
+ String text = (String) zoomSelector.getSelectedItem();
text = text.replaceAll("%", "").trim();
text = text.replaceAll("%", "").trim();
-
- if (text.toLowerCase().startsWith(ZOOM_FIT.toLowerCase()) &&
+
+ if (text.toLowerCase(Locale.getDefault()).startsWith(ZOOM_FIT.toLowerCase(Locale.getDefault())) &&
scrollPane.isFittingAllowed()) {
scrollPane.setFitting(true);
setZoomText();
return;
}
scrollPane.isFittingAllowed()) {
scrollPane.setFitting(true);
setZoomText();
return;
}
double n = Double.parseDouble(text);
n /= 100;
if (n <= 0.005)
n = 0.005;
double n = Double.parseDouble(text);
n /= 100;
if (n <= 0.005)
n = 0.005;
scrollPane.setScaling(n);
setZoomText();
} catch (NumberFormatException ignore) {
scrollPane.setScaling(n);
setZoomText();
} catch (NumberFormatException ignore) {
- add(zoomSelector,"gap rel");
-
-
+ add(zoomSelector, "gap rel");
+
+
// Zoom in button
button = new JButton(Icons.ZOOM_IN);
button.addActionListener(new ActionListener() {
// Zoom in button
button = new JButton(Icons.ZOOM_IN);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
double scale = scrollPane.getScaling();
scale = getNextScale(scale);
scrollPane.setScaling(scale);
}
});
public void actionPerformed(ActionEvent e) {
double scale = scrollPane.getScaling();
scale = getNextScale(scale);
scrollPane.setScaling(scale);
}
});
- add(button,"gapleft rel");
-
- }
-
+ add(button, "gapleft rel");
+
+ }
+
+
private void setZoomText() {
String text;
double zoom = scrollPane.getScaling();
text = PERCENT_FORMAT.format(zoom);
if (scrollPane.isFitting()) {
private void setZoomText() {
String text;
double zoom = scrollPane.getScaling();
text = PERCENT_FORMAT.format(zoom);
if (scrollPane.isFitting()) {
- text = "Fit ("+text+")";
+ text = "Fit (" + text + ")";
}
if (!text.equals(zoomSelector.getSelectedItem()))
zoomSelector.setSelectedItem(text);
}
}
if (!text.equals(zoomSelector.getSelectedItem()))
zoomSelector.setSelectedItem(text);
}
private double getPreviousScale(double scale) {
int i;
private double getPreviousScale(double scale) {
int i;
- for (i=0; i<ZOOM_LEVELS.length-1; i++) {
- if (scale > ZOOM_LEVELS[i]+0.05 && scale < ZOOM_LEVELS[i+1]+0.05)
+ for (i = 0; i < ZOOM_LEVELS.length - 1; i++) {
+ if (scale > ZOOM_LEVELS[i] + 0.05 && scale < ZOOM_LEVELS[i + 1] + 0.05)
- if (scale > ZOOM_LEVELS[ZOOM_LEVELS.length/2]) {
+ if (scale > ZOOM_LEVELS[ZOOM_LEVELS.length / 2]) {
// scale is large, drop to next lowest full 100%
// scale is large, drop to next lowest full 100%
- scale = Math.ceil(scale-1.05);
+ scale = Math.ceil(scale - 1.05);
return Math.max(scale, ZOOM_LEVELS[i]);
}
// scale is small
return Math.max(scale, ZOOM_LEVELS[i]);
}
// scale is small
}
private double getNextScale(double scale) {
int i;
}
private double getNextScale(double scale) {
int i;
- for (i=0; i<ZOOM_LEVELS.length-1; i++) {
- if (scale > ZOOM_LEVELS[i]-0.05 && scale < ZOOM_LEVELS[i+1]-0.05)
- return ZOOM_LEVELS[i+1];
+ for (i = 0; i < ZOOM_LEVELS.length - 1; i++) {
+ if (scale > ZOOM_LEVELS[i] - 0.05 && scale < ZOOM_LEVELS[i + 1] - 0.05)
+ return ZOOM_LEVELS[i + 1];
- if (scale > ZOOM_LEVELS[ZOOM_LEVELS.length/2]) {
+ if (scale > ZOOM_LEVELS[ZOOM_LEVELS.length / 2]) {
// scale is large, give next full 100%
// scale is large, give next full 100%
- scale = Math.floor(scale+1.05);
+ scale = Math.floor(scale + 1.05);
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Locale;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
public static FileFilter getImageFileFilter() {
String[] extensions = ImageIO.getReaderFileSuffixes();
for (int i = 0; i < extensions.length; i++) {
public static FileFilter getImageFileFilter() {
String[] extensions = ImageIO.getReaderFileSuffixes();
for (int i = 0; i < extensions.length; i++) {
- extensions[i] = extensions[i].toLowerCase();
+ extensions[i] = extensions[i].toLowerCase(Locale.ENGLISH);
}
Arrays.sort(extensions);
}
Arrays.sort(extensions);
*/
public static File forceExtension(File original, String extension) {
*/
public static File forceExtension(File original, String extension) {
- if (!original.getName().toLowerCase().endsWith(extension.toLowerCase())) {
+ if (!original.getName().toLowerCase(Locale.ENGLISH).endsWith(extension.toLowerCase(Locale.ENGLISH))) {
log.debug(1, "File name does not contain extension, adding '" + extension + "'");
String name = original.getAbsolutePath();
if (extension.startsWith(".")) {
log.debug(1, "File name does not contain extension, adding '" + extension + "'");
String name = original.getAbsolutePath();
if (extension.startsWith(".")) {
package net.sf.openrocket.gui.util;
import java.io.File;
package net.sf.openrocket.gui.util;
import java.io.File;
+import java.util.Locale;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileFilter;
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/
public class SimpleFileFilter extends FileFilter implements java.io.FileFilter {
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/
public class SimpleFileFilter extends FileFilter implements java.io.FileFilter {
private final String description;
private final boolean acceptDir;
private final String[] extensions;
private final String description;
private final boolean acceptDir;
private final String[] extensions;
* @param description the description of this file filter.
* @param extensions an array of extensions that match this filter.
*/
* @param description the description of this file filter.
* @param extensions an array of extensions that match this filter.
*/
- public SimpleFileFilter(String description, String ... extensions) {
+ public SimpleFileFilter(String description, String... extensions) {
this(description, true, extensions);
}
this(description, true, extensions);
}
/**
* Create filter that accepts files with the provided extensions.
*
/**
* Create filter that accepts files with the provided extensions.
*
* @param acceptDir whether to accept directories
* @param extensions an array of extensions that match this filter.
*/
* @param acceptDir whether to accept directories
* @param extensions an array of extensions that match this filter.
*/
- public SimpleFileFilter(String description, boolean acceptDir, String ... extensions) {
+ public SimpleFileFilter(String description, boolean acceptDir, String... extensions) {
this.description = description;
this.acceptDir = acceptDir;
this.extensions = new String[extensions.length];
this.description = description;
this.acceptDir = acceptDir;
this.extensions = new String[extensions.length];
- for (int i=0; i<extensions.length; i++) {
- String ext = extensions[i].toLowerCase();
+ for (int i = 0; i < extensions.length; i++) {
+ String ext = extensions[i].toLowerCase(Locale.ENGLISH);
if (ext.charAt(0) == '.') {
this.extensions[i] = ext;
} else {
if (ext.charAt(0) == '.') {
this.extensions[i] = ext;
} else {
return acceptDir;
String filename = file.getName();
return acceptDir;
String filename = file.getName();
- filename = filename.toLowerCase();
- for (String ext: extensions) {
+ filename = filename.toLowerCase(Locale.ENGLISH);
+ for (String ext : extensions) {
if (filename.endsWith(ext))
return true;
}
return false;
}
if (filename.endsWith(ext))
return true;
}
return false;
}
@Override
public String getDescription() {
return description;
}
@Override
public String getDescription() {
return description;
}
package net.sf.openrocket.logging;
package net.sf.openrocket.logging;
+import java.util.Locale;
+
/**
* The logging level. The natural order of the LogLevel orders the levels
* from highest priority to lowest priority. Comparisons of the relative levels
/**
* The logging level. The natural order of the LogLevel orders the levels
* from highest priority to lowest priority. Comparisons of the relative levels
* No ERROR level events _should_ occur while running the program.
*/
ERROR,
* No ERROR level events _should_ occur while running the program.
*/
ERROR,
/**
* Level for indicating error conditions or atypical events that can occur during
* normal operation (errors while loading files, weird computation results etc).
*/
WARN,
/**
* Level for indicating error conditions or atypical events that can occur during
* normal operation (errors while loading files, weird computation results etc).
*/
WARN,
/**
* Level for logging user actions (adding and modifying components, running
* simulations etc). A user action should be logged as soon as possible on this
/**
* Level for logging user actions (adding and modifying components, running
* simulations etc). A user action should be logged as soon as possible on this
* user actions from a bounded log buffer.
*/
USER,
* user actions from a bounded log buffer.
*/
USER,
/**
* Level for indicating general level actions the software is performing and
* other notable events during execution (dialogs shown, simulations run etc).
*/
INFO,
/**
* Level for indicating general level actions the software is performing and
* other notable events during execution (dialogs shown, simulations run etc).
*/
INFO,
/**
* Level for indicating mid-results, outcomes of methods and other debugging
* information. The data logged should be of value when analyzing error
/**
* Level for indicating mid-results, outcomes of methods and other debugging
* information. The data logged should be of value when analyzing error
* during e.g. flight simulation should use the VBOSE level instead.
*/
DEBUG,
* during e.g. flight simulation should use the VBOSE level instead.
*/
DEBUG,
/**
* Level of verbose debug logging to be used in areas which are called repeatedly,
* such as computational methods used in simulations. This level is separated to
/**
* Level of verbose debug logging to be used in areas which are called repeatedly,
* such as computational methods used in simulations. This level is separated to
if (value == null) {
return defaultLevel;
}
if (value == null) {
return defaultLevel;
}
- value = value.toUpperCase().trim();
+ value = value.toUpperCase(Locale.ENGLISH).trim();
// Find the correct level
LogLevel level = defaultLevel;
// Find the correct level
LogLevel level = defaultLevel;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
/**
import java.util.Set;
/**
"WECO", "WECO FEUERWERKS", "SF", "SACHSEN", "SACHSEN FEUERWERK",
"SACHSEN FEUERWERKS"));
"WECO", "WECO FEUERWERKS", "SF", "SACHSEN", "SACHSEN FEUERWERK",
"SACHSEN FEUERWERKS"));
// Check that no duplicates have appeared
for (Manufacturer m1 : manufacturers) {
for (Manufacturer m2 : manufacturers) {
// Check that no duplicates have appeared
for (Manufacturer m1 : manufacturers) {
for (Manufacturer m2 : manufacturers) {
private final String displayName;
private final String simpleName;
private final Set<String> allNames;
private final String displayName;
private final String simpleName;
private final Set<String> allNames;
private String generateSearchString(String str) {
private String generateSearchString(String str) {
- return str.toLowerCase().replaceAll("[^a-zA-Z0-9]+", " ").trim();
+ return str.toLowerCase(Locale.getDefault()).replaceAll("[^a-zA-Z0-9]+", " ").trim();
package net.sf.openrocket.optimization.rocketoptimization.modifiers;
package net.sf.openrocket.optimization.rocketoptimization.modifiers;
+import java.util.Locale;
+
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.optimization.general.OptimizationException;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.optimization.general.OptimizationException;
- methodName = methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
+ methodName = methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1);
getter = new Method(modifiedClass.getMethod("get" + methodName));
setter = new Method(modifiedClass.getMethod("set" + methodName, double.class));
} catch (SecurityException e) {
getter = new Method(modifiedClass.getMethod("get" + methodName));
setter = new Method(modifiedClass.getMethod("set" + methodName, double.class));
} catch (SecurityException e) {
@Override
public double getCurrentSIValue(Simulation simulation) throws OptimizationException {
T modifiable = getModifiedObject(simulation);
@Override
public double getCurrentSIValue(Simulation simulation) throws OptimizationException {
T modifiable = getModifiedObject(simulation);
protected abstract T getModifiedObject(Simulation simulation) throws OptimizationException;
protected abstract T getModifiedObject(Simulation simulation) throws OptimizationException;
@Override
public String toString() {
return "GenericModifier[modifiedClass=" + modifiedClass.getCanonicalName() + ", methodName=" + methodName + ", multiplier=" + multiplier + "]";
@Override
public String toString() {
return "GenericModifier[modifiedClass=" + modifiedClass.getCanonicalName() + ", methodName=" + methodName + ", multiplier=" + multiplier + "]";
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import net.sf.openrocket.document.OpenRocketDocument;
import java.util.Map;
import net.sf.openrocket.document.OpenRocketDocument;
private static final double DEFAULT_RANGE_MULTIPLIER = 2.0;
private static final double DEFAULT_RANGE_MULTIPLIER = 2.0;
private static final Map<Class<?>, List<ModifierDefinition>> definitions = new HashMap<Class<?>, List<ModifierDefinition>>();
static {
//addModifier("optimization.modifier.", unitGroup, multiplier, componentClass, methodName);
private static final Map<Class<?>, List<ModifierDefinition>> definitions = new HashMap<Class<?>, List<ModifierDefinition>>();
static {
//addModifier("optimization.modifier.", unitGroup, multiplier, componentClass, methodName);
* For example, body tube does not have inner diameter definition because it is
* defined by the outer diameter and thickness.
*/
* For example, body tube does not have inner diameter definition because it is
* defined by the outer diameter and thickness.
*/
addModifier("optimization.modifier.nosecone.length", UnitGroup.UNITS_LENGTH, 1.0, NoseCone.class, "Length");
addModifier("optimization.modifier.nosecone.diameter", UnitGroup.UNITS_LENGTH, 2.0, NoseCone.class, "AftRadius", "isAftRadiusAutomatic");
addModifier("optimization.modifier.nosecone.thickness", UnitGroup.UNITS_LENGTH, 1.0, NoseCone.class, "Thickness", "isFilled");
addModifier("optimization.modifier.nosecone.length", UnitGroup.UNITS_LENGTH, 1.0, NoseCone.class, "Length");
addModifier("optimization.modifier.nosecone.diameter", UnitGroup.UNITS_LENGTH, 2.0, NoseCone.class, "AftRadius", "isAftRadiusAutomatic");
addModifier("optimization.modifier.nosecone.thickness", UnitGroup.UNITS_LENGTH, 1.0, NoseCone.class, "Thickness", "isFilled");
addModifier("optimization.modifier.launchlug.outerDiameter", UnitGroup.UNITS_LENGTH, 2.0, LaunchLug.class, "OuterRadius");
addModifier("optimization.modifier.launchlug.thickness", UnitGroup.UNITS_LENGTH, 1.0, LaunchLug.class, "Thickness");
addModifier("optimization.modifier.launchlug.outerDiameter", UnitGroup.UNITS_LENGTH, 2.0, LaunchLug.class, "OuterRadius");
addModifier("optimization.modifier.launchlug.thickness", UnitGroup.UNITS_LENGTH, 1.0, LaunchLug.class, "Thickness");
addModifier("optimization.modifier.masscomponent.mass", UnitGroup.UNITS_MASS, 1.0, MassComponent.class, "ComponentMass");
addModifier("optimization.modifier.parachute.diameter", UnitGroup.UNITS_LENGTH, 1.0, Parachute.class, "Diameter");
addModifier("optimization.modifier.masscomponent.mass", UnitGroup.UNITS_MASS, 1.0, MassComponent.class, "ComponentMass");
addModifier("optimization.modifier.parachute.diameter", UnitGroup.UNITS_LENGTH, 1.0, Parachute.class, "Diameter");
}
private static void addModifier(String modifierNameKey, UnitGroup unitGroup, double multiplier,
}
private static void addModifier(String modifierNameKey, UnitGroup unitGroup, double multiplier,
- Class<? extends RocketComponent> componentClass, String methodName, String autoMethod) {
+ Class<? extends RocketComponent> componentClass, String methodName, String autoMethod) {
String modifierDescriptionKey = modifierNameKey + ".desc";
String modifierDescriptionKey = modifierNameKey + ".desc";
@Override
public Collection<SimulationModifier> getModifiers(OpenRocketDocument document) {
List<SimulationModifier> modifiers = new ArrayList<SimulationModifier>();
@Override
public Collection<SimulationModifier> getModifiers(OpenRocketDocument document) {
List<SimulationModifier> modifiers = new ArrayList<SimulationModifier>();
// Add override modifiers if mass/CG is overridden
if (c.isMassOverridden()) {
SimulationModifier mod = new GenericComponentModifier(
// Add override modifiers if mass/CG is overridden
if (c.isMassOverridden()) {
SimulationModifier mod = new GenericComponentModifier(
// Conditional motor mount parameters
if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c;
// Conditional motor mount parameters
if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c;
// Inner component positioning
if (c instanceof InternalComponent) {
RocketComponent parent = c.getParent();
// Inner component positioning
if (c instanceof InternalComponent) {
RocketComponent parent = c.getParent();
// Custom min/max for fin set position
if (c instanceof FinSet) {
RocketComponent parent = c.getParent();
// Custom min/max for fin set position
if (c instanceof FinSet) {
RocketComponent parent = c.getParent();
// Custom min/max for launch lug position
if (c instanceof LaunchLug) {
RocketComponent parent = c.getParent();
// Custom min/max for launch lug position
if (c instanceof LaunchLug) {
RocketComponent parent = c.getParent();
// Recovery device deployment altitude and delay
if (c instanceof RecoveryDevice) {
RecoveryDevice device = (RecoveryDevice) c;
// Recovery device deployment altitude and delay
if (c instanceof RecoveryDevice) {
RecoveryDevice device = (RecoveryDevice) c;
// Conditional shape parameter of Transition
if (c instanceof Transition) {
Transition transition = (Transition) c;
Transition.Shape shape = transition.getType();
if (shape.usesParameter()) {
SimulationModifier mod = new GenericComponentModifier(
// Conditional shape parameter of Transition
if (c instanceof Transition) {
Transition transition = (Transition) c;
Transition.Shape shape = transition.getType();
if (shape.usesParameter()) {
SimulationModifier mod = new GenericComponentModifier(
- trans.get("optimization.modifier." + c.getClass().getSimpleName().toLowerCase() + ".shapeparameter"),
- trans.get("optimization.modifier." + c.getClass().getSimpleName().toLowerCase() + ".shapeparameter.desc"),
+ trans.get("optimization.modifier." + c.getClass().getSimpleName().toLowerCase(Locale.ENGLISH) + ".shapeparameter"),
+ trans.get("optimization.modifier." + c.getClass().getSimpleName().toLowerCase(Locale.ENGLISH) + ".shapeparameter.desc"),
c, UnitGroup.UNITS_NONE,
1.0, c.getClass(), c.getID(), "ShapeParameter");
mod.setMinValue(shape.minParameter());
c, UnitGroup.UNITS_NONE,
1.0, c.getClass(), c.getID(), "ShapeParameter");
mod.setMinValue(shape.minParameter());
* String modifierName, Object relatedObject, UnitGroup unitGroup,
double multiplier, Class<? extends RocketComponent> componentClass, String componentId, String methodName
*/
* String modifierName, Object relatedObject, UnitGroup unitGroup,
double multiplier, Class<? extends RocketComponent> componentClass, String componentId, String methodName
*/
private static class ModifierDefinition {
private final String modifierNameKey;
private final String modifierDescriptionKey;
private static class ModifierDefinition {
private final String modifierNameKey;
private final String modifierDescriptionKey;
package net.sf.openrocket.simulation;
import java.util.HashMap;
package net.sf.openrocket.simulation;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import net.sf.openrocket.l10n.Translator;
import java.util.Map;
import net.sf.openrocket.l10n.Translator;
/** List of existing types. MUST BE DEFINED BEFORE ANY TYPES!! */
private static final Map<String, FlightDataType> EXISTING_TYPES = new HashMap<String, FlightDataType>();
/** List of existing types. MUST BE DEFINED BEFORE ANY TYPES!! */
private static final Map<String, FlightDataType> EXISTING_TYPES = new HashMap<String, FlightDataType>();
//// Time
public static final FlightDataType TYPE_TIME = newType(trans.get("FlightDataType.TYPE_TIME"), UnitGroup.UNITS_FLIGHT_TIME, 1);
//// Time
public static final FlightDataType TYPE_TIME = newType(trans.get("FlightDataType.TYPE_TIME"), UnitGroup.UNITS_FLIGHT_TIME, 1);
//// Vertical position and motion
//// Altitude
public static final FlightDataType TYPE_ALTITUDE = newType(trans.get("FlightDataType.TYPE_ALTITUDE"), UnitGroup.UNITS_DISTANCE, 10);
//// Vertical position and motion
//// Altitude
public static final FlightDataType TYPE_ALTITUDE = newType(trans.get("FlightDataType.TYPE_ALTITUDE"), UnitGroup.UNITS_DISTANCE, 10);
//// Vertical acceleration
public static final FlightDataType TYPE_ACCELERATION_Z = newType(trans.get("FlightDataType.TYPE_ACCELERATION_Z"), UnitGroup.UNITS_ACCELERATION, 12);
//// Vertical acceleration
public static final FlightDataType TYPE_ACCELERATION_Z = newType(trans.get("FlightDataType.TYPE_ACCELERATION_Z"), UnitGroup.UNITS_ACCELERATION, 12);
//// Total motion
//// Total velocity
public static final FlightDataType TYPE_VELOCITY_TOTAL = newType(trans.get("FlightDataType.TYPE_VELOCITY_TOTAL"), UnitGroup.UNITS_VELOCITY, 20);
//// Total acceleration
public static final FlightDataType TYPE_ACCELERATION_TOTAL = newType(trans.get("FlightDataType.TYPE_ACCELERATION_TOTAL"), UnitGroup.UNITS_ACCELERATION, 21);
//// Total motion
//// Total velocity
public static final FlightDataType TYPE_VELOCITY_TOTAL = newType(trans.get("FlightDataType.TYPE_VELOCITY_TOTAL"), UnitGroup.UNITS_VELOCITY, 20);
//// Total acceleration
public static final FlightDataType TYPE_ACCELERATION_TOTAL = newType(trans.get("FlightDataType.TYPE_ACCELERATION_TOTAL"), UnitGroup.UNITS_ACCELERATION, 21);
//// Lateral position and motion
//// Position upwind
public static final FlightDataType TYPE_POSITION_X = newType(trans.get("FlightDataType.TYPE_POSITION_X"), UnitGroup.UNITS_DISTANCE, 30);
//// Lateral position and motion
//// Position upwind
public static final FlightDataType TYPE_POSITION_X = newType(trans.get("FlightDataType.TYPE_POSITION_X"), UnitGroup.UNITS_DISTANCE, 30);
//// Yaw rate
public static final FlightDataType TYPE_YAW_RATE = newType(trans.get("FlightDataType.TYPE_YAW_RATE"), UnitGroup.UNITS_ROLL, 43);
//// Yaw rate
public static final FlightDataType TYPE_YAW_RATE = newType(trans.get("FlightDataType.TYPE_YAW_RATE"), UnitGroup.UNITS_ROLL, 43);
//// Stability information
//// Mass
public static final FlightDataType TYPE_MASS = newType(trans.get("FlightDataType.TYPE_MASS"), UnitGroup.UNITS_MASS, 50);
//// Stability information
//// Mass
public static final FlightDataType TYPE_MASS = newType(trans.get("FlightDataType.TYPE_MASS"), UnitGroup.UNITS_MASS, 50);
//// Stability margin calibers
public static final FlightDataType TYPE_STABILITY = newType(trans.get("FlightDataType.TYPE_STABILITY"), UnitGroup.UNITS_COEFFICIENT, 55);
//// Stability margin calibers
public static final FlightDataType TYPE_STABILITY = newType(trans.get("FlightDataType.TYPE_STABILITY"), UnitGroup.UNITS_COEFFICIENT, 55);
//// Characteristic numbers
//// Mach number
public static final FlightDataType TYPE_MACH_NUMBER = newType(trans.get("FlightDataType.TYPE_MACH_NUMBER"), UnitGroup.UNITS_COEFFICIENT, 60);
//// Reynolds number
public static final FlightDataType TYPE_REYNOLDS_NUMBER = newType(trans.get("FlightDataType.TYPE_REYNOLDS_NUMBER"), UnitGroup.UNITS_COEFFICIENT, 61);
//// Characteristic numbers
//// Mach number
public static final FlightDataType TYPE_MACH_NUMBER = newType(trans.get("FlightDataType.TYPE_MACH_NUMBER"), UnitGroup.UNITS_COEFFICIENT, 60);
//// Reynolds number
public static final FlightDataType TYPE_REYNOLDS_NUMBER = newType(trans.get("FlightDataType.TYPE_REYNOLDS_NUMBER"), UnitGroup.UNITS_COEFFICIENT, 61);
//// Thrust and drag
//// Thrust
public static final FlightDataType TYPE_THRUST_FORCE = newType(trans.get("FlightDataType.TYPE_THRUST_FORCE"), UnitGroup.UNITS_FORCE, 70);
//// Thrust and drag
//// Thrust
public static final FlightDataType TYPE_THRUST_FORCE = newType(trans.get("FlightDataType.TYPE_THRUST_FORCE"), UnitGroup.UNITS_FORCE, 70);
//// Axial drag coefficient
public static final FlightDataType TYPE_AXIAL_DRAG_COEFF = newType(trans.get("FlightDataType.TYPE_AXIAL_DRAG_COEFF"), UnitGroup.UNITS_COEFFICIENT, 73);
//// Axial drag coefficient
public static final FlightDataType TYPE_AXIAL_DRAG_COEFF = newType(trans.get("FlightDataType.TYPE_AXIAL_DRAG_COEFF"), UnitGroup.UNITS_COEFFICIENT, 73);
//// Component drag coefficients
//// Friction drag coefficient
public static final FlightDataType TYPE_FRICTION_DRAG_COEFF = newType(trans.get("FlightDataType.TYPE_FRICTION_DRAG_COEFF"), UnitGroup.UNITS_COEFFICIENT, 80);
//// Component drag coefficients
//// Friction drag coefficient
public static final FlightDataType TYPE_FRICTION_DRAG_COEFF = newType(trans.get("FlightDataType.TYPE_FRICTION_DRAG_COEFF"), UnitGroup.UNITS_COEFFICIENT, 80);
//// Base drag coefficient
public static final FlightDataType TYPE_BASE_DRAG_COEFF = newType(trans.get("FlightDataType.TYPE_BASE_DRAG_COEFF"), UnitGroup.UNITS_COEFFICIENT, 82);
//// Base drag coefficient
public static final FlightDataType TYPE_BASE_DRAG_COEFF = newType(trans.get("FlightDataType.TYPE_BASE_DRAG_COEFF"), UnitGroup.UNITS_COEFFICIENT, 82);
//// Other coefficients
//// Normal force coefficient
public static final FlightDataType TYPE_NORMAL_FORCE_COEFF = newType(trans.get("FlightDataType.TYPE_NORMAL_FORCE_COEFF"), UnitGroup.UNITS_COEFFICIENT, 90);
//// Other coefficients
//// Normal force coefficient
public static final FlightDataType TYPE_NORMAL_FORCE_COEFF = newType(trans.get("FlightDataType.TYPE_NORMAL_FORCE_COEFF"), UnitGroup.UNITS_COEFFICIENT, 90);
//// Coriolis acceleration
public static final FlightDataType TYPE_CORIOLIS_ACCELERATION = newType(trans.get("FlightDataType.TYPE_CORIOLIS_ACCELERATION"), UnitGroup.UNITS_ACCELERATION, 99);
//// Coriolis acceleration
public static final FlightDataType TYPE_CORIOLIS_ACCELERATION = newType(trans.get("FlightDataType.TYPE_CORIOLIS_ACCELERATION"), UnitGroup.UNITS_ACCELERATION, 99);
//// Reference length + area
//// Reference length
public static final FlightDataType TYPE_REFERENCE_LENGTH = newType(trans.get("FlightDataType.TYPE_REFERENCE_LENGTH"), UnitGroup.UNITS_LENGTH, 100);
//// Reference area
public static final FlightDataType TYPE_REFERENCE_AREA = newType(trans.get("FlightDataType.TYPE_REFERENCE_AREA"), UnitGroup.UNITS_AREA, 101);
//// Reference length + area
//// Reference length
public static final FlightDataType TYPE_REFERENCE_LENGTH = newType(trans.get("FlightDataType.TYPE_REFERENCE_LENGTH"), UnitGroup.UNITS_LENGTH, 100);
//// Reference area
public static final FlightDataType TYPE_REFERENCE_AREA = newType(trans.get("FlightDataType.TYPE_REFERENCE_AREA"), UnitGroup.UNITS_AREA, 101);
//// Orientation
//// Vertical orientation (zenith)
public static final FlightDataType TYPE_ORIENTATION_THETA = newType(trans.get("FlightDataType.TYPE_ORIENTATION_THETA"), UnitGroup.UNITS_ANGLE, 106);
//// Lateral orientation (azimuth)
public static final FlightDataType TYPE_ORIENTATION_PHI = newType(trans.get("FlightDataType.TYPE_ORIENTATION_PHI"), UnitGroup.UNITS_ANGLE, 107);
//// Orientation
//// Vertical orientation (zenith)
public static final FlightDataType TYPE_ORIENTATION_THETA = newType(trans.get("FlightDataType.TYPE_ORIENTATION_THETA"), UnitGroup.UNITS_ANGLE, 106);
//// Lateral orientation (azimuth)
public static final FlightDataType TYPE_ORIENTATION_PHI = newType(trans.get("FlightDataType.TYPE_ORIENTATION_PHI"), UnitGroup.UNITS_ANGLE, 107);
//// Atmospheric conditions
//// Wind velocity
public static final FlightDataType TYPE_WIND_VELOCITY = newType(trans.get("FlightDataType.TYPE_WIND_VELOCITY"), UnitGroup.UNITS_VELOCITY, 110);
//// Atmospheric conditions
//// Wind velocity
public static final FlightDataType TYPE_WIND_VELOCITY = newType(trans.get("FlightDataType.TYPE_WIND_VELOCITY"), UnitGroup.UNITS_VELOCITY, 110);
public static final FlightDataType TYPE_COMPUTATION_TIME = newType(trans.get("FlightDataType.TYPE_COMPUTATION_TIME"), UnitGroup.UNITS_SHORT_TIME, 201);
public static final FlightDataType TYPE_COMPUTATION_TIME = newType(trans.get("FlightDataType.TYPE_COMPUTATION_TIME"), UnitGroup.UNITS_SHORT_TIME, 201);
/**
* Return a {@link FlightDataType} based on a string description. This returns known data types
* if possible, or a new type otherwise.
/**
* Return a {@link FlightDataType} based on a string description. This returns known data types
* if possible, or a new type otherwise.
* @return a data type.
*/
public static synchronized FlightDataType getType(String s, UnitGroup u) {
* @return a data type.
*/
public static synchronized FlightDataType getType(String s, UnitGroup u) {
- FlightDataType type = EXISTING_TYPES.get(s.toLowerCase());
+ FlightDataType type = EXISTING_TYPES.get(s.toLowerCase(Locale.ENGLISH));
if (type != null) {
return type;
}
if (type != null) {
return type;
}
*/
private static synchronized FlightDataType newType(String s, UnitGroup u, int priority) {
FlightDataType type = new FlightDataType(s, u, priority);
*/
private static synchronized FlightDataType newType(String s, UnitGroup u, int priority) {
FlightDataType type = new FlightDataType(s, u, priority);
- EXISTING_TYPES.put(s.toLowerCase(), type);
+ EXISTING_TYPES.put(s.toLowerCase(Locale.ENGLISH), type);
this.name = typeName;
this.units = units;
this.priority = priority;
this.name = typeName;
this.units = units;
this.priority = priority;
- this.hashCode = this.name.toLowerCase().hashCode();
+ this.hashCode = this.name.toLowerCase(Locale.ENGLISH).hashCode();
public String getName() {
return name;
}
public String getName() {
return name;
}
//// SimulationListener ////
//// SimulationListener ////
+ @Override
+ public String getName() {
+ return this.getClass().getSimpleName();
+ }
+
+ @Override
+ public String[] getMenuPosition() {
+ return new String[0];
+ }
+
@Override
public void startSimulation(SimulationStatus status) throws SimulationException {
// No-op
@Override
public void startSimulation(SimulationStatus status) throws SimulationException {
// No-op
//// SimulationEventListener ////
@Override
//// SimulationEventListener ////
@Override
//// SimulationComputationListener ////
@Override
//// SimulationComputationListener ////
@Override
public interface SimulationListener {
public interface SimulationListener {
+ /**
+ * Get the name of this simulation listener. Ideally this should be localized, as
+ * it can be displayed in the UI.
+ *
+ * @return the name of this simulation listener.
+ */
+ public String getName();
+
+
+ /**
+ * Get the menu position of this simulation listener. This should be an array
+ * of localized submenu names in descending order, or an empty array for positioning
+ * in the base menu.
+ *
+ * @return the menu position of this simulation listener.
+ */
+ public String[] getMenuPosition();
+
+
/**
* Called when starting a simulation.
*
/**
* Called when starting a simulation.
*
package net.sf.openrocket.startup;
import java.awt.GraphicsEnvironment;
package net.sf.openrocket.startup;
import java.awt.GraphicsEnvironment;
+import java.util.Locale;
import javax.swing.JOptionPane;
import javax.swing.JOptionPane;
*/
static void checkOpenJDK() {
*/
static void checkOpenJDK() {
- if (System.getProperty("java.runtime.name", "").toLowerCase().indexOf("icedtea") >= 0 ||
- System.getProperty("java.vm.name", "").toLowerCase().indexOf("openjdk") >= 0) {
+ if (System.getProperty("java.runtime.name", "").toLowerCase(Locale.ENGLISH).indexOf("icedtea") >= 0 ||
+ System.getProperty("java.vm.name", "").toLowerCase(Locale.ENGLISH).indexOf("openjdk") >= 0) {
String jreName = System.getProperty("java.vm.name", "(unknown)");
String jreVersion = System.getProperty("java.runtime.version", "(unknown)");
String jreName = System.getProperty("java.vm.name", "(unknown)");
String jreVersion = System.getProperty("java.runtime.version", "(unknown)");
/////////// Helper methods //////////
/**
/////////// Helper methods //////////
/**
if (!GraphicsEnvironment.isHeadless()) {
JOptionPane.showMessageDialog(null, message, "Error starting OpenRocket",
if (!GraphicsEnvironment.isHeadless()) {
JOptionPane.showMessageDialog(null, message, "Error starting OpenRocket",
package net.sf.openrocket.util;
package net.sf.openrocket.util;
+import java.util.Locale;
+
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
*/
public enum GeodeticComputationStrategy {
*/
public enum GeodeticComputationStrategy {
/**
* Perform computations using a flat Earth approximation. addCoordinate computes the
* location using a direct meters-per-degree scaling and getCoriolisAcceleration always
/**
* Perform computations using a flat Earth approximation. addCoordinate computes the
* location using a direct meters-per-degree scaling and getCoriolisAcceleration always
private static final Translator trans = Application.getTranslator();
private static final double PRECISION_LIMIT = 0.5e-13;
private static final Translator trans = Application.getTranslator();
private static final double PRECISION_LIMIT = 0.5e-13;
* Return the name of this geodetic computation method.
*/
public String getName() {
* Return the name of this geodetic computation method.
*/
public String getName() {
- return trans.get(name().toLowerCase() + ".name");
+ return trans.get(name().toLowerCase(Locale.ENGLISH) + ".name");
}
/**
* Return a description of the geodetic computation methods.
*/
public String getDescription() {
}
/**
* Return a description of the geodetic computation methods.
*/
public String getDescription() {
- return trans.get(name().toLowerCase() + ".desc");
+ return trans.get(name().toLowerCase(Locale.ENGLISH) + ".desc");
public abstract Coordinate getCoriolisAcceleration(WorldCoordinate location, Coordinate velocity);
public abstract Coordinate getCoriolisAcceleration(WorldCoordinate location, Coordinate velocity);
private static Coordinate computeCoriolisAcceleration(WorldCoordinate latlon, Coordinate velocity) {
double sinlat = Math.sin(latlon.getLatitudeRad());
private static Coordinate computeCoriolisAcceleration(WorldCoordinate latlon, Coordinate velocity) {
double sinlat = Math.sin(latlon.getLatitudeRad());
// able to be set independently and in terms of bearing with north == +ve y.
Coordinate coriolis = new Coordinate(2.0 * WorldCoordinate.EROT * (v_n * sinlat - v_u * coslat),
// able to be set independently and in terms of bearing with north == +ve y.
Coordinate coriolis = new Coordinate(2.0 * WorldCoordinate.EROT * (v_n * sinlat - v_u * coslat),
- 2.0 * WorldCoordinate.EROT * (-1.0 * v_e * sinlat),
- 2.0 * WorldCoordinate.EROT * (v_e * coslat)
- );
+ 2.0 * WorldCoordinate.EROT * (-1.0 * v_e * sinlat),
+ 2.0 * WorldCoordinate.EROT * (v_e * coslat)
+ );
// ******************************************************************** //
// The Vincenty Direct Solution.
// Code from GeoConstants.java, Ian Cameron Smith, GPL
// ******************************************************************** //
// The Vincenty Direct Solution.
// Code from GeoConstants.java, Ian Cameron Smith, GPL
* point, in radians clockwise from north.
*/
private static double[] dirct1(double glat1, double glon1,
* point, in radians clockwise from north.
*/
private static double[] dirct1(double glat1, double glon1,
- double azimuth, double dist,
- double axis, double flat) {
+ double azimuth, double dist,
+ double axis, double flat) {
double r = 1.0 - flat;
double tu = r * Math.sin(glat1) / Math.cos(glat1);
double r = 1.0 - flat;
double tu = r * Math.sin(glat1) / Math.cos(glat1);
x = e * cy;
y = e + e - 1.0;
y = (((sy * sy * 4.0 - 3.0) * y * cz * d / 6.0 + x) *
x = e * cy;
y = e + e - 1.0;
y = (((sy * sy * 4.0 - 3.0) * y * cz * d / 6.0 + x) *
- d / 4.0 - cz) * sy * d + tu;
+ d / 4.0 - cz) * sy * d + tu;
} while (Math.abs(y - c) > PRECISION_LIMIT);
baz = cu * cy * cf - su * sy;
} while (Math.abs(y - c) > PRECISION_LIMIT);
baz = cu * cy * cf - su * sy;
import java.security.Permission;
import java.util.HashMap;
import java.util.List;
import java.security.Permission;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import net.sf.openrocket.util.BugException;
public class HttpURLConnectionMock extends HttpURLConnection {
import java.util.Map;
import net.sf.openrocket.util.BugException;
public class HttpURLConnectionMock extends HttpURLConnection {
private static final URL MOCK_URL;
static {
try {
private static final URL MOCK_URL;
static {
try {
@Override
public void connect() {
if (!connected) {
@Override
public void connect() {
if (!connected) {
@Override
public void disconnect() {
}
@Override
public void disconnect() {
}
@Override
public boolean usingProxy() {
return false;
}
@Override
public boolean usingProxy() {
return false;
}
public boolean getInstanceFollowRedirects() {
return this.instanceFollowRedirects;
}
public boolean getInstanceFollowRedirects() {
return this.instanceFollowRedirects;
}
@Override
public void setInstanceFollowRedirects(boolean followRedirects) {
assertFalse(connected);
this.instanceFollowRedirects = followRedirects;
}
@Override
public void setInstanceFollowRedirects(boolean followRedirects) {
assertFalse(connected);
this.instanceFollowRedirects = followRedirects;
}
@Override
public String getRequestMethod() {
@Override
public String getRequestMethod() {
- return this.requestMethod;
+ return this.requestMethod;
@Override
public void setRequestMethod(String method) throws ProtocolException {
assertFalse(connected);
this.requestMethod = method;
}
@Override
public void setRequestMethod(String method) throws ProtocolException {
assertFalse(connected);
this.requestMethod = method;
}
@Override
public int getResponseCode() throws IOException {
connect();
return this.responseCode;
}
@Override
public int getResponseCode() throws IOException {
connect();
return this.responseCode;
}
public void setResponseCode(int code) {
this.responseCode = code;
}
public void setResponseCode(int code) {
this.responseCode = code;
}
@Override
public void addRequestProperty(String key, String value) {
assertFalse(connected);
@Override
public void addRequestProperty(String key, String value) {
assertFalse(connected);
- assertFalse(this.requestProperties.containsKey(key.toLowerCase()));
- this.requestProperties.put(key.toLowerCase(), value);
+ assertFalse(this.requestProperties.containsKey(key.toLowerCase(Locale.ENGLISH)));
+ this.requestProperties.put(key.toLowerCase(Locale.ENGLISH), value);
@Override
public void setRequestProperty(String key, String value) {
assertFalse(connected);
@Override
public void setRequestProperty(String key, String value) {
assertFalse(connected);
- this.requestProperties.put(key.toLowerCase(), value);
+ this.requestProperties.put(key.toLowerCase(Locale.ENGLISH), value);
@Override
public String getRequestProperty(String key) {
@Override
public String getRequestProperty(String key) {
- return this.requestProperties.get(key.toLowerCase());
+ return this.requestProperties.get(key.toLowerCase(Locale.ENGLISH));
@Override
public int getConnectTimeout() {
return this.connectTimeout;
}
@Override
public int getConnectTimeout() {
return this.connectTimeout;
}
@Override
public void setConnectTimeout(int timeout) {
assertFalse(connected);
this.connectTimeout = timeout;
}
@Override
public void setConnectTimeout(int timeout) {
assertFalse(connected);
this.connectTimeout = timeout;
}
@Override
public String getContentEncoding() {
connect();
@Override
public String getContentEncoding() {
connect();
public void setContentEncoding(String encoding) {
this.contentEncoding = encoding;
}
public void setContentEncoding(String encoding) {
this.contentEncoding = encoding;
}
@Override
public int getContentLength() {
connect();
@Override
public int getContentLength() {
connect();
return 0;
return content.length;
}
return 0;
return content.length;
}
public void setContent(byte[] content) {
this.content = content;
}
public void setContent(byte[] content) {
this.content = content;
}
@Override
public String getContentType() {
connect();
@Override
public String getContentType() {
connect();
public void setContentType(String type) {
this.contentType = type;
}
public void setContentType(String type) {
this.contentType = type;
}
@Override
public boolean getDoInput() {
return this.doInput;
}
@Override
public boolean getDoInput() {
return this.doInput;
}
@Override
public void setDoInput(boolean doinput) {
assertFalse(connected);
this.doInput = doinput;
}
@Override
public void setDoInput(boolean doinput) {
assertFalse(connected);
this.doInput = doinput;
}
@Override
public boolean getDoOutput() {
return this.doOutput;
}
@Override
public boolean getDoOutput() {
return this.doOutput;
}
@Override
public void setDoOutput(boolean dooutput) {
assertFalse(connected);
this.doOutput = dooutput;
}
@Override
public void setDoOutput(boolean dooutput) {
assertFalse(connected);
this.doOutput = dooutput;
}
@Override
public InputStream getInputStream() throws IOException {
assertTrue(doInput);
@Override
public InputStream getInputStream() throws IOException {
assertTrue(doInput);
inputStream = new ByteArrayInputStream(content);
return inputStream;
}
inputStream = new ByteArrayInputStream(content);
return inputStream;
}
@Override
public OutputStream getOutputStream() throws IOException {
assertTrue(doOutput);
@Override
public OutputStream getOutputStream() throws IOException {
assertTrue(doOutput);
@Override
public void setUseCaches(boolean usecaches) {
assertFalse(connected);
this.useCaches = usecaches;
}
@Override
public void setUseCaches(boolean usecaches) {
assertFalse(connected);
this.useCaches = usecaches;
}
@Override
public boolean getUseCaches() {
return this.useCaches;
}
@Override
public boolean getUseCaches() {
return this.useCaches;
}
private void assertNull(Object o) {
try {
org.junit.Assert.assertNull(o);
private void assertNull(Object o) {
try {
org.junit.Assert.assertNull(o);
private void assertNotNull(Object o) {
try {
org.junit.Assert.assertNotNull(o);
private void assertNotNull(Object o) {
try {
org.junit.Assert.assertNotNull(o);
private void assertTrue(boolean o) {
try {
org.junit.Assert.assertTrue(o);
private void assertTrue(boolean o) {
try {
org.junit.Assert.assertTrue(o);
private void assertFalse(boolean o) {
try {
org.junit.Assert.assertFalse(o);
private void assertFalse(boolean o) {
try {
org.junit.Assert.assertFalse(o);
private void fail(String msg) {
failed = true;
org.junit.Assert.fail(msg);
}
private void fail(String msg) {
failed = true;
org.junit.Assert.fail(msg);
}
@Override
public InputStream getErrorStream() {
throw new UnsupportedOperationException();
}
@Override
public InputStream getErrorStream() {
throw new UnsupportedOperationException();
}
@Override
public String getHeaderField(int n) {
throw new UnsupportedOperationException();
}
@Override
public String getHeaderField(int n) {
throw new UnsupportedOperationException();
}
@Override
public long getHeaderFieldDate(String name, long Default) {
throw new UnsupportedOperationException();
}
@Override
public long getHeaderFieldDate(String name, long Default) {
throw new UnsupportedOperationException();
}
@Override
public String getHeaderFieldKey(int n) {
throw new UnsupportedOperationException();
}
@Override
public String getHeaderFieldKey(int n) {
throw new UnsupportedOperationException();
}
@Override
public Permission getPermission() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public Permission getPermission() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public String getResponseMessage() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public String getResponseMessage() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void setChunkedStreamingMode(int chunklen) {
throw new UnsupportedOperationException();
}
@Override
public void setChunkedStreamingMode(int chunklen) {
throw new UnsupportedOperationException();
}
@Override
public void setFixedLengthStreamingMode(int contentLength) {
throw new UnsupportedOperationException();
}
@Override
public void setFixedLengthStreamingMode(int contentLength) {
throw new UnsupportedOperationException();
}
@Override
public boolean getAllowUserInteraction() {
throw new UnsupportedOperationException();
}
@Override
public boolean getAllowUserInteraction() {
throw new UnsupportedOperationException();
}
@Override
public Object getContent() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public Object getContent() throws IOException {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
@Override
public Object getContent(Class[] classes) throws IOException {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
@Override
public Object getContent(Class[] classes) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public long getDate() {
throw new UnsupportedOperationException();
}
@Override
public long getDate() {
throw new UnsupportedOperationException();
}
@Override
public boolean getDefaultUseCaches() {
throw new UnsupportedOperationException();
}
@Override
public boolean getDefaultUseCaches() {
throw new UnsupportedOperationException();
}
@Override
public long getExpiration() {
throw new UnsupportedOperationException();
}
@Override
public long getExpiration() {
throw new UnsupportedOperationException();
}
@Override
public String getHeaderField(String name) {
throw new UnsupportedOperationException();
}
@Override
public String getHeaderField(String name) {
throw new UnsupportedOperationException();
}
@Override
public int getHeaderFieldInt(String name, int Default) {
throw new UnsupportedOperationException();
}
@Override
public int getHeaderFieldInt(String name, int Default) {
throw new UnsupportedOperationException();
}
@Override
public Map<String, List<String>> getHeaderFields() {
throw new UnsupportedOperationException();
}
@Override
public Map<String, List<String>> getHeaderFields() {
throw new UnsupportedOperationException();
}
@Override
public long getIfModifiedSince() {
throw new UnsupportedOperationException();
}
@Override
public long getIfModifiedSince() {
throw new UnsupportedOperationException();
}
@Override
public long getLastModified() {
throw new UnsupportedOperationException();
}
@Override
public long getLastModified() {
throw new UnsupportedOperationException();
}
@Override
public int getReadTimeout() {
throw new UnsupportedOperationException();
}
@Override
public int getReadTimeout() {
throw new UnsupportedOperationException();
}
@Override
public Map<String, List<String>> getRequestProperties() {
throw new UnsupportedOperationException();
}
@Override
public Map<String, List<String>> getRequestProperties() {
throw new UnsupportedOperationException();
}
@Override
public URL getURL() {
throw new UnsupportedOperationException();
}
@Override
public URL getURL() {
throw new UnsupportedOperationException();
}
@Override
public void setAllowUserInteraction(boolean allowuserinteraction) {
throw new UnsupportedOperationException();
}
@Override
public void setAllowUserInteraction(boolean allowuserinteraction) {
throw new UnsupportedOperationException();
}
@Override
public void setDefaultUseCaches(boolean defaultusecaches) {
throw new UnsupportedOperationException();
}
@Override
public void setDefaultUseCaches(boolean defaultusecaches) {
throw new UnsupportedOperationException();
}
@Override
public void setIfModifiedSince(long ifmodifiedsince) {
throw new UnsupportedOperationException();
}
@Override
public void setIfModifiedSince(long ifmodifiedsince) {
throw new UnsupportedOperationException();
}
@Override
public void setReadTimeout(int timeout) {
throw new UnsupportedOperationException();
}
@Override
public void setReadTimeout(int timeout) {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
throw new UnsupportedOperationException();
}