Change toLowerCase() to toLowerCase(Locale.ENGLISH)

This commit is contained in:
Sampo Niskanen 2012-03-27 11:42:31 +00:00
parent 3fa0f9ce67
commit 9c6b275e84
28 changed files with 417 additions and 371 deletions

View File

@ -1,3 +1,7 @@
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

View File

@ -1,12 +1,13 @@
package net.sf.openrocket.arch;
import java.io.File;
import java.util.Locale;
import net.sf.openrocket.util.BugException;
public class SystemInfo {
/**
* Enumeration of supported operating systems.
*
@ -26,7 +27,7 @@ public class SystemInfo {
* @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;
@ -41,8 +42,8 @@ public class SystemInfo {
}
/**
* Return the application data directory of this user. The location depends
* on the current platform.

View File

@ -67,7 +67,7 @@ public class UpdateInfoRetriever {
}
/**
* Parse the data received from the server.
*
@ -84,7 +84,7 @@ public class UpdateInfoRetriever {
reader = new BufferedReader(r);
}
String version = null;
ArrayList<ComparablePair<Integer, String>> updates =
new ArrayList<ComparablePair<Integer, String>>();
@ -113,7 +113,7 @@ public class UpdateInfoRetriever {
}
/**
* An asynchronous task that fetches and parses the update info.
*
@ -183,7 +183,7 @@ public class UpdateInfoRetriever {
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;
@ -223,7 +223,7 @@ public class UpdateInfoRetriever {
return;
}
info = new UpdateInfo(version, updates);
log.info("Found update: " + info);
} finally {

View File

@ -8,6 +8,7 @@ import java.io.Writer;
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;
@ -318,7 +319,7 @@ public class OpenRocketSaver extends RocketSaver {
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\"/>");
@ -553,7 +554,7 @@ public class OpenRocketSaver extends RocketSaver {
* @return the corresponding XML name.
*/
public static String enumToXMLName(Enum<?> e) {
return e.name().toLowerCase().replace("_", "");
return e.name().toLowerCase(Locale.ENGLISH).replace("_", "");
}
}

View File

@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException;
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;
@ -508,7 +509,7 @@ class DocumentConfig {
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)) {
return e;
}
}
@ -926,7 +927,7 @@ class MotorMountHandler extends AbstractElementHandler {
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)) {
event = e;
break;
}
@ -1084,7 +1085,7 @@ class MotorHandler extends AbstractElementHandler {
// 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())) {
type = t;
break;
}
@ -1985,7 +1986,7 @@ class MaterialSetter implements Setter {
// 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;
}

View File

@ -1,23 +1,24 @@
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 {
@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
elements.add("<finish>" + ext.getFinish().name().toLowerCase() + "</finish>");
elements.add("<finish>" + ext.getFinish().name().toLowerCase(Locale.ENGLISH) + "</finish>");
// Material
elements.add(materialParam(ext.getMaterial()));
}
}

View File

@ -1,34 +1,35 @@
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 {
@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>");
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)
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=\"" +
fins.getTabRelativePosition().name().toLowerCase() + "\">" +
fins.getTabRelativePosition().name().toLowerCase(Locale.ENGLISH) + "\">" +
fins.getTabShift() + "</tabposition>");
}
}
}

View File

@ -1,27 +1,28 @@
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 {
@Override
protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List<String> elements) {
super.addParams(c, elements);
RecoveryDevice dev = (RecoveryDevice) c;
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()));
}
}

View File

@ -3,6 +3,7 @@ package net.sf.openrocket.file.openrocket.savers;
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;
@ -26,7 +27,7 @@ public class RocketComponentSaver {
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();
@ -38,19 +39,19 @@ public class RocketComponentSaver {
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()) {
@ -66,7 +67,7 @@ public class RocketComponentSaver {
+ "</overridesubcomponents>");
}
// Comment
if (c.getComment().length() > 0) {
elements.add("<comment>" + RocketSaver.escapeXML(c.getComment()) + "</comment>");
@ -75,8 +76,8 @@ public class RocketComponentSaver {
}
protected final String materialParam(Material mat) {
return materialParam("material", mat);
}
@ -121,7 +122,7 @@ public class RocketComponentSaver {
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;
@ -144,7 +145,7 @@ public class RocketComponentSaver {
}
elements.add(" <ignitionevent>"
+ mount.getIgnitionEvent().name().toLowerCase().replace("_", "")
+ mount.getIgnitionEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "")
+ "</ignitionevent>");
elements.add(" <ignitiondelay>" + mount.getIgnitionDelay() + "</ignitiondelay>");

View File

@ -2,51 +2,52 @@ package net.sf.openrocket.file.openrocket.savers;
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 {
private static final RocketSaver instance = new RocketSaver();
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>");
return list;
}
@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) {
elements.add("<designer>"
elements.add("<designer>"
+ 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())
+ "</revision>");
}
// 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\"";
@ -55,19 +56,19 @@ public class RocketSaver extends RocketComponentSaver {
str += "/>";
} else {
str += "><name>" + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getMotorConfigurationName(id))
+ "</name></motorconfiguration>";
+ "</name></motorconfiguration>";
}
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>");
}
}
}

View File

@ -2,6 +2,7 @@ package net.sf.openrocket.file.openrocket.savers;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Stage;
@ -27,7 +28,7 @@ public class StageSaver extends ComponentAssemblySaver {
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>");
}

View File

@ -2,26 +2,27 @@ package net.sf.openrocket.file.openrocket.savers;
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 {
private static final TransitionSaver instance = new TransitionSaver();
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>");
return list;
}
/*
* Note: This method must be capable of handling nose cones as well.
*/
@ -30,31 +31,31 @@ public class TransitionSaver extends SymmetricComponentSaver {
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();
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 (!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 (!nosecone) {
elements.add("<foreshoulderradius>" + trans.getForeShoulderRadius()
+ "</foreshoulderradius>");
@ -65,7 +66,7 @@ public class TransitionSaver extends SymmetricComponentSaver {
elements.add("<foreshouldercapped>" + trans.isForeShoulderCapped()
+ "</foreshouldercapped>");
}
elements.add("<aftshoulderradius>" + trans.getAftShoulderRadius()
+ "</aftshoulderradius>");
elements.add("<aftshoulderlength>" + trans.getAftShoulderLength()
@ -75,5 +76,5 @@ public class TransitionSaver extends SymmetricComponentSaver {
elements.add("<aftshouldercapped>" + trans.isAftShoulderCapped()
+ "</aftshouldercapped>");
}
}

View File

@ -9,6 +9,7 @@ import java.awt.event.FocusListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.JButton;
@ -60,7 +61,7 @@ public class RocketComponentConfig extends JPanel {
private final List<Invalidatable> invalidatables = new ArrayList<Invalidatable>();
protected final JTextField componentNameField;
protected JTextArea commentTextArea;
private final TextFieldListener textFieldListener;
@ -90,7 +91,7 @@ public class RocketComponentConfig extends JPanel {
componentNameField.setToolTipText(trans.get("RocketCompCfg.ttip.Thecomponentname"));
this.add(componentNameField, "growx, growy 0, wrap");
tabbedPane = new JTabbedPane();
this.add(tabbedPane, "growx, growy 1, wrap");
@ -207,7 +208,7 @@ public class RocketComponentConfig extends JPanel {
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>
@ -286,7 +287,7 @@ public class RocketComponentConfig extends JPanel {
bm.addEnableComponent(bs);
panel.add(bs, "growx 5, w 100lp, wrap");
//// CG override
bm = new BooleanModel(component, "CGOverridden");
check = new JCheckBox(bm);
@ -324,7 +325,7 @@ public class RocketComponentConfig extends JPanel {
bm.addEnableComponent(bs);
panel.add(bs, "growx 5, w 100lp, wrap 35lp");
// Override subcomponents checkbox
bm = new BooleanModel(component, "OverrideSubcomponents");
check = new JCheckBox(bm);
@ -336,7 +337,7 @@ public class RocketComponentConfig extends JPanel {
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;
@ -364,7 +365,7 @@ public class RocketComponentConfig extends JPanel {
}
private JPanel figureTab() {
JPanel panel = new JPanel(new MigLayout("align 20% 20%"));
@ -384,7 +385,7 @@ public class RocketComponentConfig extends JPanel {
}
//// Choose color
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) {
@ -450,7 +451,7 @@ public class RocketComponentConfig extends JPanel {
}
protected JPanel shoulderTab() {
JPanel panel = new JPanel(new MigLayout("fill"));
JPanel sub;
@ -460,7 +461,7 @@ public class RocketComponentConfig extends JPanel {
JCheckBox check;
JSpinner spin;
//// Fore shoulder, not for NoseCone
if (!(component instanceof NoseCone)) {
@ -469,7 +470,7 @@ public class RocketComponentConfig extends JPanel {
//// Fore shoulder
sub.setBorder(BorderFactory.createTitledBorder(trans.get("RocketCompCfg.border.Foreshoulder")));
//// Radius
//// Diameter:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Diameter")));
@ -484,7 +485,7 @@ public class RocketComponentConfig extends JPanel {
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")));
@ -497,7 +498,7 @@ public class RocketComponentConfig extends JPanel {
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")));
@ -511,7 +512,7 @@ public class RocketComponentConfig extends JPanel {
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);
@ -521,11 +522,11 @@ public class RocketComponentConfig extends JPanel {
check.setToolTipText(trans.get("RocketCompCfg.ttip.Endcapped"));
sub.add(check, "spanx");
panel.add(sub);
}
//// Aft shoulder
sub = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]", ""));
@ -536,7 +537,7 @@ public class RocketComponentConfig extends JPanel {
//// Aft shoulder
sub.setBorder(BorderFactory.createTitledBorder(trans.get("RocketCompCfg.title.Aftshoulder")));
//// Radius
//// Diameter:
sub.add(new JLabel(trans.get("RocketCompCfg.lbl.Diameter")));
@ -551,7 +552,7 @@ public class RocketComponentConfig extends JPanel {
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")));
@ -564,7 +565,7 @@ public class RocketComponentConfig extends JPanel {
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")));
@ -578,7 +579,7 @@ public class RocketComponentConfig extends JPanel {
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);
@ -588,16 +589,16 @@ public class RocketComponentConfig extends JPanel {
check.setToolTipText(trans.get("RocketCompCfg.ttip.Endcapped"));
sub.add(check, "spanx");
panel.add(sub);
return panel;
}
/*
* Private inner class to handle events in componentNameField.
*/

View File

@ -14,6 +14,7 @@ import java.awt.event.MouseEvent;
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;
@ -333,7 +334,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
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);
}
@ -943,7 +944,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
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;
}

View File

@ -36,7 +36,7 @@ public enum PaperSize {
}
//////////////////////////
private static final LogHelper log = Application.getLogger();
@ -181,7 +181,7 @@ public enum PaperSize {
return null;
}
country = country.toUpperCase();
country = country.toUpperCase(Locale.ENGLISH);
for (String c : letterCountries) {
if (c.equals(country)) {
return LETTER;

View File

@ -5,6 +5,7 @@ import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.EventObject;
import java.util.Locale;
import javax.swing.JButton;
import javax.swing.JComboBox;
@ -15,18 +16,18 @@ import net.sf.openrocket.gui.util.Icons;
import net.sf.openrocket.util.StateChangeListener;
public class ScaleSelector extends JPanel {
// 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 {
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[ZOOM_SETTINGS.length-1] = ZOOM_FIT;
ZOOM_SETTINGS[ZOOM_SETTINGS.length - 1] = ZOOM_FIT;
}
@ -36,12 +37,13 @@ public class ScaleSelector extends JPanel {
public ScaleSelector(ScaleScrollPane scroll) {
super(new MigLayout());
this.scrollPane = scroll;
// Zoom out button
JButton button = new JButton(Icons.ZOOM_OUT);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
double scale = scrollPane.getScaling();
scale = getPreviousScale(scale);
@ -49,34 +51,35 @@ public class ScaleSelector extends JPanel {
}
});
add(button, "gap");
// 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() {
@Override
public void actionPerformed(ActionEvent e) {
try {
String text = (String)zoomSelector.getSelectedItem();
String text = (String) zoomSelector.getSelectedItem();
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;
}
double n = Double.parseDouble(text);
n /= 100;
if (n <= 0.005)
n = 0.005;
scrollPane.setScaling(n);
setZoomText();
} catch (NumberFormatException ignore) {
@ -91,65 +94,66 @@ public class ScaleSelector extends JPanel {
setZoomText();
}
});
add(zoomSelector,"gap rel");
add(zoomSelector, "gap rel");
// Zoom in button
button = new JButton(Icons.ZOOM_IN);
button.addActionListener(new ActionListener() {
@Override
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()) {
text = "Fit ("+text+")";
text = "Fit (" + text + ")";
}
if (!text.equals(zoomSelector.getSelectedItem()))
zoomSelector.setSelectedItem(text);
}
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)
return ZOOM_LEVELS[i];
}
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 = Math.ceil(scale-1.05);
scale = Math.ceil(scale - 1.05);
return Math.max(scale, ZOOM_LEVELS[i]);
}
// scale is small
return scale/1.5;
return scale / 1.5;
}
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 = Math.floor(scale+1.05);
scale = Math.floor(scale + 1.05);
return scale;
}
return scale*1.5;
return scale * 1.5;
}
}

View File

@ -4,6 +4,7 @@ import java.awt.Component;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Locale;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
@ -60,7 +61,7 @@ public final class FileHelper {
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);
@ -110,7 +111,7 @@ public final class FileHelper {
*/
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(".")) {

View File

@ -1,6 +1,7 @@
package net.sf.openrocket.gui.util;
import java.io.File;
import java.util.Locale;
import javax.swing.filechooser.FileFilter;
@ -12,7 +13,7 @@ import javax.swing.filechooser.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;
@ -25,11 +26,11 @@ public class SimpleFileFilter extends FileFilter implements java.io.FileFilter {
* @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);
}
/**
* Create filter that accepts files with the provided extensions.
*
@ -37,12 +38,12 @@ public class SimpleFileFilter extends FileFilter implements java.io.FileFilter {
* @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];
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 {
@ -60,18 +61,18 @@ public class SimpleFileFilter extends FileFilter implements java.io.FileFilter {
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;
}
@Override
public String getDescription() {
return description;
}
}

View File

@ -1,5 +1,7 @@
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
@ -16,13 +18,13 @@ public enum LogLevel {
* 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 logging user actions (adding and modifying components, running
* simulations etc). A user action should be logged as soon as possible on this
@ -30,13 +32,13 @@ public enum LogLevel {
* 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 mid-results, outcomes of methods and other debugging
* information. The data logged should be of value when analyzing error
@ -44,7 +46,7 @@ public enum LogLevel {
* 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
@ -103,7 +105,7 @@ public enum LogLevel {
if (value == null) {
return defaultLevel;
}
value = value.toUpperCase().trim();
value = value.toUpperCase(Locale.ENGLISH).trim();
// Find the correct level
LogLevel level = defaultLevel;

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
/**
@ -98,7 +99,7 @@ public class Manufacturer {
"WECO", "WECO FEUERWERKS", "SF", "SACHSEN", "SACHSEN FEUERWERK",
"SACHSEN FEUERWERKS"));
// Check that no duplicates have appeared
for (Manufacturer m1 : manufacturers) {
for (Manufacturer m2 : manufacturers) {
@ -114,8 +115,8 @@ public class Manufacturer {
}
}
private final String displayName;
private final String simpleName;
private final Set<String> allNames;
@ -240,10 +241,10 @@ public class Manufacturer {
}
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();
}
}

View File

@ -1,5 +1,7 @@
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;
@ -53,7 +55,7 @@ public abstract class GenericModifier<T> extends AbstractSimulationModifier {
}
try {
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) {
@ -64,7 +66,7 @@ public abstract class GenericModifier<T> extends AbstractSimulationModifier {
}
@Override
public double getCurrentSIValue(Simulation simulation) throws OptimizationException {
T modifiable = getModifiedObject(simulation);
@ -97,7 +99,7 @@ public abstract class GenericModifier<T> extends AbstractSimulationModifier {
protected abstract T getModifiedObject(Simulation simulation) throws OptimizationException;
@Override
public String toString() {
return "GenericModifier[modifiedClass=" + modifiedClass.getCanonicalName() + ", methodName=" + methodName + ", multiplier=" + multiplier + "]";

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
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;
@ -41,7 +42,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
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);
@ -51,7 +52,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
* 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");
@ -81,7 +82,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
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");
@ -100,7 +101,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
}
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";
@ -116,8 +117,8 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
}
@Override
public Collection<SimulationModifier> getModifiers(OpenRocketDocument document) {
List<SimulationModifier> modifiers = new ArrayList<SimulationModifier>();
@ -151,7 +152,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
}
}
// Add override modifiers if mass/CG is overridden
if (c.isMassOverridden()) {
SimulationModifier mod = new GenericComponentModifier(
@ -173,7 +174,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
modifiers.add(mod);
}
// Conditional motor mount parameters
if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c;
@ -199,7 +200,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
}
}
// Inner component positioning
if (c instanceof InternalComponent) {
RocketComponent parent = c.getParent();
@ -213,7 +214,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
modifiers.add(mod);
}
// Custom min/max for fin set position
if (c instanceof FinSet) {
RocketComponent parent = c.getParent();
@ -227,7 +228,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
modifiers.add(mod);
}
// Custom min/max for launch lug position
if (c instanceof LaunchLug) {
RocketComponent parent = c.getParent();
@ -241,7 +242,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
modifiers.add(mod);
}
// Recovery device deployment altitude and delay
if (c instanceof RecoveryDevice) {
RecoveryDevice device = (RecoveryDevice) c;
@ -266,15 +267,15 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
}
}
// 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());
@ -303,7 +304,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
* 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;

View File

@ -1,6 +1,7 @@
package net.sf.openrocket.simulation;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import net.sf.openrocket.l10n.Translator;
@ -29,12 +30,12 @@ public class FlightDataType implements Comparable<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);
//// Vertical position and motion
//// Altitude
public static final FlightDataType TYPE_ALTITUDE = newType(trans.get("FlightDataType.TYPE_ALTITUDE"), UnitGroup.UNITS_DISTANCE, 10);
@ -43,14 +44,14 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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);
//// Lateral position and motion
//// Position upwind
public static final FlightDataType TYPE_POSITION_X = newType(trans.get("FlightDataType.TYPE_POSITION_X"), UnitGroup.UNITS_DISTANCE, 30);
@ -79,7 +80,7 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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);
@ -94,14 +95,14 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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);
//// Thrust and drag
//// Thrust
public static final FlightDataType TYPE_THRUST_FORCE = newType(trans.get("FlightDataType.TYPE_THRUST_FORCE"), UnitGroup.UNITS_FORCE, 70);
@ -112,7 +113,7 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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);
@ -121,7 +122,7 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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);
@ -146,21 +147,21 @@ public class FlightDataType implements Comparable<FlightDataType> {
//// 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);
//// 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);
@ -178,7 +179,7 @@ public class FlightDataType implements Comparable<FlightDataType> {
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.
@ -188,7 +189,7 @@ public class FlightDataType implements Comparable<FlightDataType> {
* @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;
}
@ -201,7 +202,7 @@ public class FlightDataType implements Comparable<FlightDataType> {
*/
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);
return type;
}
@ -220,12 +221,12 @@ public class FlightDataType implements Comparable<FlightDataType> {
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;
}

View File

@ -27,6 +27,16 @@ public class AbstractSimulationListener implements SimulationListener, Simulatio
//// 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
@ -58,8 +68,8 @@ public class AbstractSimulationListener implements SimulationListener, Simulatio
}
//// SimulationEventListener ////
@Override
@ -83,7 +93,7 @@ public class AbstractSimulationListener implements SimulationListener, Simulatio
}
//// SimulationComputationListener ////
@Override

View File

@ -7,6 +7,25 @@ import net.sf.openrocket.simulation.exception.SimulationException;
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.
*

View File

@ -1,6 +1,7 @@
package net.sf.openrocket.startup;
import java.awt.GraphicsEnvironment;
import java.util.Locale;
import javax.swing.JOptionPane;
@ -59,8 +60,8 @@ public class VersionHelper {
*/
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)");
@ -79,7 +80,7 @@ public class VersionHelper {
}
/////////// Helper methods //////////
/**
@ -97,7 +98,7 @@ public class VersionHelper {
}
System.err.println();
if (!GraphicsEnvironment.isHeadless()) {
JOptionPane.showMessageDialog(null, message, "Error starting OpenRocket",

View File

@ -1,5 +1,7 @@
package net.sf.openrocket.util;
import java.util.Locale;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
@ -13,7 +15,7 @@ import net.sf.openrocket.startup.Application;
*/
public enum GeodeticComputationStrategy {
/**
* Perform computations using a flat Earth approximation. addCoordinate computes the
* location using a direct meters-per-degree scaling and getCoriolisAcceleration always
@ -131,7 +133,7 @@ public enum GeodeticComputationStrategy {
}
};
private static final Translator trans = Application.getTranslator();
private static final double PRECISION_LIMIT = 0.5e-13;
@ -141,14 +143,14 @@ public enum GeodeticComputationStrategy {
* 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 trans.get(name().toLowerCase() + ".desc");
return trans.get(name().toLowerCase(Locale.ENGLISH) + ".desc");
}
@Override
@ -169,9 +171,9 @@ public enum GeodeticComputationStrategy {
public abstract Coordinate getCoriolisAcceleration(WorldCoordinate location, Coordinate velocity);
private static Coordinate computeCoriolisAcceleration(WorldCoordinate latlon, Coordinate velocity) {
double sinlat = Math.sin(latlon.getLatitudeRad());
@ -189,14 +191,14 @@ public enum GeodeticComputationStrategy {
// 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)
);
return coriolis;
}
// ******************************************************************** //
// The Vincenty Direct Solution.
// Code from GeoConstants.java, Ian Cameron Smith, GPL
@ -226,8 +228,8 @@ public enum GeodeticComputationStrategy {
* 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);
@ -264,7 +266,7 @@ public enum GeodeticComputationStrategy {
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;
@ -285,5 +287,5 @@ public enum GeodeticComputationStrategy {
return ret;
}
}

View File

@ -14,12 +14,13 @@ import java.net.URL;
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 {
private static final URL MOCK_URL;
static {
try {
@ -88,7 +89,7 @@ public class HttpURLConnectionMock extends HttpURLConnection {
}
@Override
public void connect() {
if (!connected) {
@ -99,17 +100,17 @@ public class HttpURLConnectionMock extends HttpURLConnection {
connected = true;
}
}
@Override
public void disconnect() {
}
@Override
public boolean usingProxy() {
return false;
}
@ -117,69 +118,69 @@ public class HttpURLConnectionMock extends HttpURLConnection {
public boolean getInstanceFollowRedirects() {
return this.instanceFollowRedirects;
}
@Override
public void setInstanceFollowRedirects(boolean followRedirects) {
assertFalse(connected);
this.instanceFollowRedirects = followRedirects;
}
@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 int getResponseCode() throws IOException {
connect();
return this.responseCode;
}
public void setResponseCode(int code) {
this.responseCode = code;
}
@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);
this.requestProperties.put(key.toLowerCase(), value);
this.requestProperties.put(key.toLowerCase(Locale.ENGLISH), value);
}
@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 void setConnectTimeout(int timeout) {
assertFalse(connected);
this.connectTimeout = timeout;
}
@Override
public String getContentEncoding() {
connect();
@ -189,9 +190,9 @@ public class HttpURLConnectionMock extends HttpURLConnection {
public void setContentEncoding(String encoding) {
this.contentEncoding = encoding;
}
@Override
public int getContentLength() {
connect();
@ -199,7 +200,7 @@ public class HttpURLConnectionMock extends HttpURLConnection {
return 0;
return content.length;
}
public void setContent(byte[] content) {
this.content = content;
}
@ -211,8 +212,8 @@ public class HttpURLConnectionMock extends HttpURLConnection {
fail("UTF-8");
}
}
@Override
public String getContentType() {
connect();
@ -222,35 +223,35 @@ public class HttpURLConnectionMock extends HttpURLConnection {
public void setContentType(String type) {
this.contentType = type;
}
@Override
public boolean getDoInput() {
return this.doInput;
}
@Override
public void setDoInput(boolean doinput) {
assertFalse(connected);
this.doInput = doinput;
}
@Override
public boolean getDoOutput() {
return this.doOutput;
}
@Override
public void setDoOutput(boolean dooutput) {
assertFalse(connected);
this.doOutput = dooutput;
}
@Override
public InputStream getInputStream() throws IOException {
assertTrue(doInput);
@ -261,8 +262,8 @@ public class HttpURLConnectionMock extends HttpURLConnection {
inputStream = new ByteArrayInputStream(content);
return inputStream;
}
@Override
public OutputStream getOutputStream() throws IOException {
assertTrue(doOutput);
@ -283,29 +284,26 @@ public class HttpURLConnectionMock extends HttpURLConnection {
return null;
}
}
@Override
public void setUseCaches(boolean usecaches) {
assertFalse(connected);
this.useCaches = usecaches;
}
@Override
public boolean getUseCaches() {
return this.useCaches;
}
private void assertNull(Object o) {
try {
org.junit.Assert.assertNull(o);
@ -314,7 +312,7 @@ public class HttpURLConnectionMock extends HttpURLConnection {
throw e;
}
}
private void assertNotNull(Object o) {
try {
org.junit.Assert.assertNotNull(o);
@ -323,7 +321,7 @@ public class HttpURLConnectionMock extends HttpURLConnection {
throw e;
}
}
private void assertTrue(boolean o) {
try {
org.junit.Assert.assertTrue(o);
@ -332,7 +330,7 @@ public class HttpURLConnectionMock extends HttpURLConnection {
throw e;
}
}
private void assertFalse(boolean o) {
try {
org.junit.Assert.assertFalse(o);
@ -341,209 +339,196 @@ public class HttpURLConnectionMock extends HttpURLConnection {
throw e;
}
}
private void fail(String msg) {
failed = true;
org.junit.Assert.fail(msg);
}
@Override
public InputStream getErrorStream() {
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 String getHeaderFieldKey(int n) {
throw new UnsupportedOperationException();
}
@Override
public Permission getPermission() 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 setFixedLengthStreamingMode(int contentLength) {
throw new UnsupportedOperationException();
}
@Override
public boolean getAllowUserInteraction() {
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();
}
@Override
public long getDate() {
throw new UnsupportedOperationException();
}
@Override
public boolean getDefaultUseCaches() {
throw new UnsupportedOperationException();
}
@Override
public long getExpiration() {
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 Map<String, List<String>> getHeaderFields() {
throw new UnsupportedOperationException();
}
@Override
public long getIfModifiedSince() {
throw new UnsupportedOperationException();
}
@Override
public long getLastModified() {
throw new UnsupportedOperationException();
}
@Override
public int getReadTimeout() {
throw new UnsupportedOperationException();
}
@Override
public Map<String, List<String>> getRequestProperties() {
throw new UnsupportedOperationException();
}
@Override
public URL getURL() {
throw new UnsupportedOperationException();
}
@Override
public void setAllowUserInteraction(boolean allowuserinteraction) {
throw new UnsupportedOperationException();
}
@Override
public void setDefaultUseCaches(boolean defaultusecaches) {
throw new UnsupportedOperationException();
}
@Override
public void setIfModifiedSince(long ifmodifiedsince) {
throw new UnsupportedOperationException();
}
@Override
public void setReadTimeout(int timeout) {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
throw new UnsupportedOperationException();
}