From a297db7cfb4074b8e60152cdfb9a8ceecd1e4c2b Mon Sep 17 00:00:00 2001 From: plaa Date: Tue, 27 Mar 2012 11:42:31 +0000 Subject: [PATCH] Change toLowerCase() to toLowerCase(Locale.ENGLISH) git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@488 180e2498-e6e9-4542-8430-84ac67f01cd8 --- core/ChangeLog | 4 + .../net/sf/openrocket/arch/SystemInfo.java | 9 +- .../communication/UpdateInfoRetriever.java | 10 +- .../file/openrocket/OpenRocketSaver.java | 5 +- .../openrocket/importt/OpenRocketLoader.java | 9 +- .../savers/ExternalComponentSaver.java | 9 +- .../file/openrocket/savers/FinSetSaver.java | 15 +- .../savers/RecoveryDeviceSaver.java | 13 +- .../savers/RocketComponentSaver.java | 21 +- .../file/openrocket/savers/RocketSaver.java | 37 +-- .../file/openrocket/savers/StageSaver.java | 3 +- .../openrocket/savers/TransitionSaver.java | 33 ++- .../configdialog/RocketComponentConfig.java | 49 +-- .../ThrustCurveMotorSelectionPanel.java | 5 +- .../sf/openrocket/gui/print/PaperSize.java | 4 +- .../gui/scalefigure/ScaleSelector.java | 74 ++--- .../sf/openrocket/gui/util/FileHelper.java | 5 +- .../openrocket/gui/util/SimpleFileFilter.java | 21 +- .../net/sf/openrocket/logging/LogLevel.java | 14 +- .../net/sf/openrocket/motor/Manufacturer.java | 13 +- .../modifiers/GenericModifier.java | 8 +- .../DefaultSimulationModifierService.java | 33 ++- .../openrocket/simulation/FlightDataType.java | 39 +-- .../listeners/AbstractSimulationListener.java | 16 +- .../listeners/SimulationListener.java | 19 ++ .../sf/openrocket/startup/VersionHelper.java | 9 +- .../util/GeodeticComputationStrategy.java | 32 +- .../communication/HttpURLConnectionMock.java | 279 +++++++++--------- 28 files changed, 417 insertions(+), 371 deletions(-) diff --git a/core/ChangeLog b/core/ChangeLog index ab5e9e15..9eb10c65 100644 --- a/core/ChangeLog +++ b/core/ChangeLog @@ -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 diff --git a/core/src/net/sf/openrocket/arch/SystemInfo.java b/core/src/net/sf/openrocket/arch/SystemInfo.java index 7b526f2c..316f313c 100644 --- a/core/src/net/sf/openrocket/arch/SystemInfo.java +++ b/core/src/net/sf/openrocket/arch/SystemInfo.java @@ -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. diff --git a/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java b/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java index 3122f085..017f6add 100644 --- a/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java +++ b/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java @@ -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> updates = new ArrayList>(); @@ -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 { diff --git a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java index 5b863158..b3b5999b 100644 --- a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java @@ -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(""); @@ -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("_", ""); } } diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java index 313fa981..eee1dae6 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java @@ -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 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; } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/ExternalComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/ExternalComponentSaver.java index 2f1b2a4e..5415832a 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/ExternalComponentSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/ExternalComponentSaver.java @@ -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 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("" + ext.getFinish().name().toLowerCase() + ""); + elements.add("" + ext.getFinish().name().toLowerCase(Locale.ENGLISH) + ""); // Material elements.add(materialParam(ext.getMaterial())); } - + } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/FinSetSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/FinSetSaver.java index 8756d89f..7eaffc69 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/FinSetSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/FinSetSaver.java @@ -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 elements) { super.addParams(c, elements); - + net.sf.openrocket.rocketcomponent.FinSet fins = (net.sf.openrocket.rocketcomponent.FinSet) c; elements.add("" + fins.getFinCount() + ""); elements.add("" + (fins.getBaseRotation() * 180.0 / Math.PI) + ""); elements.add("" + fins.getThickness() + ""); - elements.add("" + fins.getCrossSection().name().toLowerCase() + elements.add("" + fins.getCrossSection().name().toLowerCase(Locale.ENGLISH) + ""); elements.add("" + (fins.getCantAngle() * 180.0 / Math.PI) + ""); // 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("" + fins.getTabHeight() + ""); elements.add("" + fins.getTabLength() + ""); elements.add("" + + fins.getTabRelativePosition().name().toLowerCase(Locale.ENGLISH) + "\">" + fins.getTabShift() + ""); - + } } - + } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java index 22dcaa9c..b4c4cc74 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java @@ -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 elements) { super.addParams(c, elements); - + RecoveryDevice dev = (RecoveryDevice) c; - + if (dev.isCDAutomatic()) elements.add("auto"); else elements.add("" + dev.getCD() + ""); - - elements.add("" + dev.getDeployEvent().name().toLowerCase() + ""); + + elements.add("" + dev.getDeployEvent().name().toLowerCase(Locale.ENGLISH) + ""); elements.add("" + dev.getDeployAltitude() + ""); elements.add("" + dev.getDeployDelay() + ""); elements.add(materialParam(dev.getMaterial())); } - + } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java index 3cd29acb..bc58ff40 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java @@ -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 elements) { elements.add("" + RocketSaver.escapeXML(c.getName()) + ""); - + // 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("" + style.name().toLowerCase() + ""); + elements.add("" + style.name().toLowerCase(Locale.ENGLISH) + ""); } } - + // 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("" + c.getPositionValue() + ""); } - + // Overrides boolean overridden = false; if (c.isMassOverridden()) { @@ -66,7 +67,7 @@ public class RocketComponentSaver { + ""); } - + // Comment if (c.getComment().length() > 0) { elements.add("" + RocketSaver.escapeXML(c.getComment()) + ""); @@ -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(" "); if (motor.getMotorType() != Motor.Type.UNKNOWN) { - elements.add(" " + motor.getMotorType().name().toLowerCase() + ""); + elements.add(" " + motor.getMotorType().name().toLowerCase(Locale.ENGLISH) + ""); } if (motor instanceof ThrustCurveMotor) { ThrustCurveMotor m = (ThrustCurveMotor) motor; @@ -144,7 +145,7 @@ public class RocketComponentSaver { } elements.add(" " - + mount.getIgnitionEvent().name().toLowerCase().replace("_", "") + + mount.getIgnitionEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "") + ""); elements.add(" " + mount.getIgnitionDelay() + ""); diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java index e8b7a345..44d5599d 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java @@ -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 getElements(net.sf.openrocket.rocketcomponent.RocketComponent c) { ArrayList list = new ArrayList(); - + list.add(""); instance.addParams(c, list); list.add(""); - + return list; } - - - + + + @Override protected void addParams(net.sf.openrocket.rocketcomponent.RocketComponent c, List elements) { super.addParams(c, elements); - + Rocket rocket = (Rocket) c; if (rocket.getDesigner().length() > 0) { - elements.add("" + elements.add("" + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getDesigner()) + ""); } if (rocket.getRevision().length() > 0) { - elements.add("" - + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getRevision()) + elements.add("" + + net.sf.openrocket.file.RocketSaver.escapeXML(rocket.getRevision()) + ""); } - - + + // Motor configurations String defId = rocket.getDefaultConfiguration().getMotorConfigurationID(); for (String id : rocket.getMotorConfigurationIDs()) { if (id == null) continue; - + String str = ""; + + ""; } elements.add(str); } // Reference diameter - elements.add("" + rocket.getReferenceType().name().toLowerCase() + elements.add("" + rocket.getReferenceType().name().toLowerCase(Locale.ENGLISH) + ""); if (rocket.getReferenceType() == ReferenceType.CUSTOM) { elements.add("" + rocket.getCustomReferenceLength() + ""); } - + } - + } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java index e0b1b58d..23f591f3 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/StageSaver.java @@ -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("" - + stage.getSeparationEvent().name().toLowerCase().replace("_", "") + + stage.getSeparationEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "") + ""); elements.add("" + stage.getSeparationDelay() + ""); } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java index d7bb1ed7..0a4169f9 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java @@ -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 getElements(net.sf.openrocket.rocketcomponent.RocketComponent c) { ArrayList list = new ArrayList(); - + list.add(""); instance.addParams(c, list); list.add(""); - + 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.name().toLowerCase() + ""); + elements.add("" + shape.name().toLowerCase(Locale.ENGLISH) + ""); if (shape.isClippable()) { elements.add("" + trans.isClipped() + ""); } if (shape.usesParameter()) { elements.add("" + trans.getShapeParameter() + ""); } - - + + if (!nosecone) { if (trans.isForeRadiusAutomatic()) elements.add("auto"); else elements.add("" + trans.getForeRadius() + ""); } - + if (trans.isAftRadiusAutomatic()) elements.add("auto"); else elements.add("" + trans.getAftRadius() + ""); - - + + if (!nosecone) { elements.add("" + trans.getForeShoulderRadius() + ""); @@ -65,7 +66,7 @@ public class TransitionSaver extends SymmetricComponentSaver { elements.add("" + trans.isForeShoulderCapped() + ""); } - + elements.add("" + trans.getAftShoulderRadius() + ""); elements.add("" + trans.getAftShoulderLength() @@ -75,5 +76,5 @@ public class TransitionSaver extends SymmetricComponentSaver { elements.add("" + trans.isAftShoulderCapped() + ""); } - + } diff --git a/core/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/core/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java index 95853b02..2a782d15 100644 --- a/core/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java +++ b/core/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java @@ -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 invalidatables = new ArrayList(); - + 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); ////The component finish affects the aerodynamic drag of the component.
@@ -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. */ diff --git a/core/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java b/core/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java index 8e6fe5d6..2600cff3 100644 --- a/core/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java +++ b/core/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java @@ -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 list = new ArrayList(); 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; } diff --git a/core/src/net/sf/openrocket/gui/print/PaperSize.java b/core/src/net/sf/openrocket/gui/print/PaperSize.java index d3d07410..1908fa28 100644 --- a/core/src/net/sf/openrocket/gui/print/PaperSize.java +++ b/core/src/net/sf/openrocket/gui/print/PaperSize.java @@ -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; diff --git a/core/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java b/core/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java index 1e966a05..d8a0b763 100644 --- a/core/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java +++ b/core/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java @@ -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[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[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; } } diff --git a/core/src/net/sf/openrocket/gui/util/FileHelper.java b/core/src/net/sf/openrocket/gui/util/FileHelper.java index 860379ed..937be152 100644 --- a/core/src/net/sf/openrocket/gui/util/FileHelper.java +++ b/core/src/net/sf/openrocket/gui/util/FileHelper.java @@ -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(".")) { diff --git a/core/src/net/sf/openrocket/gui/util/SimpleFileFilter.java b/core/src/net/sf/openrocket/gui/util/SimpleFileFilter.java index 39ded917..e895b929 100644 --- a/core/src/net/sf/openrocket/gui/util/SimpleFileFilter.java +++ b/core/src/net/sf/openrocket/gui/util/SimpleFileFilter.java @@ -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 */ 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 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(); } } diff --git a/core/src/net/sf/openrocket/optimization/rocketoptimization/modifiers/GenericModifier.java b/core/src/net/sf/openrocket/optimization/rocketoptimization/modifiers/GenericModifier.java index 07724c8f..b5e2eaee 100644 --- a/core/src/net/sf/openrocket/optimization/rocketoptimization/modifiers/GenericModifier.java +++ b/core/src/net/sf/openrocket/optimization/rocketoptimization/modifiers/GenericModifier.java @@ -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 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 extends AbstractSimulationModifier { } - + @Override public double getCurrentSIValue(Simulation simulation) throws OptimizationException { T modifiable = getModifiedObject(simulation); @@ -97,7 +99,7 @@ public abstract class GenericModifier extends AbstractSimulationModifier { protected abstract T getModifiedObject(Simulation simulation) throws OptimizationException; - + @Override public String toString() { return "GenericModifier[modifiedClass=" + modifiedClass.getCanonicalName() + ", methodName=" + methodName + ", multiplier=" + multiplier + "]"; diff --git a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java index 565330aa..cf77e3c5 100644 --- a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java +++ b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java @@ -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, List> definitions = new HashMap, List>(); 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 componentClass, String methodName, String autoMethod) { + Class componentClass, String methodName, String autoMethod) { String modifierDescriptionKey = modifierNameKey + ".desc"; @@ -116,8 +117,8 @@ public class DefaultSimulationModifierService implements SimulationModifierServi } - - + + @Override public Collection getModifiers(OpenRocketDocument document) { List modifiers = new ArrayList(); @@ -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 componentClass, String componentId, String methodName */ - + private static class ModifierDefinition { private final String modifierNameKey; private final String modifierDescriptionKey; diff --git a/core/src/net/sf/openrocket/simulation/FlightDataType.java b/core/src/net/sf/openrocket/simulation/FlightDataType.java index 26862420..0e8b41a4 100644 --- a/core/src/net/sf/openrocket/simulation/FlightDataType.java +++ b/core/src/net/sf/openrocket/simulation/FlightDataType.java @@ -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 { /** List of existing types. MUST BE DEFINED BEFORE ANY TYPES!! */ private static final Map EXISTING_TYPES = new HashMap(); - - + + //// 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 { //// 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 { //// 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 { //// 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 { //// 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 { //// 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 { //// 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 { 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 { * @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 { */ 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 { 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; } diff --git a/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java b/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java index ebb2ad94..a3a3b192 100644 --- a/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java +++ b/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java @@ -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 diff --git a/core/src/net/sf/openrocket/simulation/listeners/SimulationListener.java b/core/src/net/sf/openrocket/simulation/listeners/SimulationListener.java index 98b28aad..d5663ccb 100644 --- a/core/src/net/sf/openrocket/simulation/listeners/SimulationListener.java +++ b/core/src/net/sf/openrocket/simulation/listeners/SimulationListener.java @@ -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. * diff --git a/core/src/net/sf/openrocket/startup/VersionHelper.java b/core/src/net/sf/openrocket/startup/VersionHelper.java index 097f1dc4..0b3d9182 100644 --- a/core/src/net/sf/openrocket/startup/VersionHelper.java +++ b/core/src/net/sf/openrocket/startup/VersionHelper.java @@ -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", diff --git a/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java b/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java index f8a37a09..0721e893 100644 --- a/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java +++ b/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java @@ -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; } - + } diff --git a/core/test/net/sf/openrocket/communication/HttpURLConnectionMock.java b/core/test/net/sf/openrocket/communication/HttpURLConnectionMock.java index ab5c48ab..57f5d520 100644 --- a/core/test/net/sf/openrocket/communication/HttpURLConnectionMock.java +++ b/core/test/net/sf/openrocket/communication/HttpURLConnectionMock.java @@ -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> 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> 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(); } - + -- 2.30.2