[#2178] Add south/west unit group for latitude/longitude
This commit is contained in:
parent
cae9c8957d
commit
485d0b5210
@ -356,6 +356,8 @@ pref.dlg.lbl.Momentofinertia = Moment of inertia:
|
||||
pref.dlg.lbl.Pressure = Pressure:
|
||||
pref.dlg.lbl.Stability = Stability:
|
||||
pref.dlg.lbl.FlightTime = Flight time:
|
||||
pref.dlg.lbl.Latitude = Latitude:
|
||||
pref.dlg.lbl.Longitude = Longitude:
|
||||
pref.dlg.lbl.effect1 = The effects will take place the next time you open a window.
|
||||
pref.dlg.lbl.Checkingupdates = Checking for updates\u2026
|
||||
pref.dlg.PrefChoiseSelector1 = Always ask
|
||||
|
@ -69,7 +69,11 @@ public abstract class Unit {
|
||||
public boolean hasSpace() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public double getMultiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return unit;
|
||||
|
@ -16,8 +16,11 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Chars;
|
||||
import net.sf.openrocket.util.StringUtils;
|
||||
|
||||
|
||||
@ -29,14 +32,14 @@ import net.sf.openrocket.util.StringUtils;
|
||||
*/
|
||||
|
||||
public class UnitGroup {
|
||||
|
||||
|
||||
public static final UnitGroup UNITS_NONE;
|
||||
|
||||
|
||||
public static final UnitGroup UNITS_MOTOR_DIMENSIONS;
|
||||
public static final UnitGroup UNITS_LENGTH;
|
||||
public static final UnitGroup UNITS_ALL_LENGTHS;
|
||||
public static final UnitGroup UNITS_DISTANCE;
|
||||
|
||||
|
||||
public static final UnitGroup UNITS_AREA;
|
||||
public static final UnitGroup UNITS_STABILITY;
|
||||
/**
|
||||
@ -46,6 +49,8 @@ public class UnitGroup {
|
||||
public static final UnitGroup UNITS_STABILITY_CALIBERS;
|
||||
public static final UnitGroup UNITS_VELOCITY;
|
||||
public static final UnitGroup UNITS_WINDSPEED;
|
||||
public static final UnitGroup UNITS_LATITUDE;
|
||||
public static final UnitGroup UNITS_LONGITUDE;
|
||||
public static final UnitGroup UNITS_ACCELERATION;
|
||||
public static final UnitGroup UNITS_MASS;
|
||||
public static final UnitGroup UNITS_INERTIA;
|
||||
@ -55,13 +60,13 @@ public class UnitGroup {
|
||||
public static final UnitGroup UNITS_DENSITY_LINE;
|
||||
public static final UnitGroup UNITS_FORCE;
|
||||
public static final UnitGroup UNITS_IMPULSE;
|
||||
|
||||
|
||||
/** Time in the order of less than a second (time step etc). */
|
||||
public static final UnitGroup UNITS_TIME_STEP;
|
||||
|
||||
|
||||
/** Time in the order of seconds (motor delay etc). */
|
||||
public static final UnitGroup UNITS_SHORT_TIME;
|
||||
|
||||
|
||||
/** Time in the order of the flight time of a rocket. */
|
||||
public static final UnitGroup UNITS_FLIGHT_TIME;
|
||||
public static final UnitGroup UNITS_ROLL;
|
||||
@ -69,21 +74,23 @@ public class UnitGroup {
|
||||
public static final UnitGroup UNITS_PRESSURE;
|
||||
public static final UnitGroup UNITS_RELATIVE;
|
||||
public static final UnitGroup UNITS_ROUGHNESS;
|
||||
|
||||
|
||||
public static final UnitGroup UNITS_COEFFICIENT;
|
||||
public static final UnitGroup UNITS_FREQUENCY;
|
||||
|
||||
|
||||
public static final UnitGroup UNITS_ENERGY;
|
||||
public static final UnitGroup UNITS_POWER;
|
||||
public static final UnitGroup UNITS_MOMENTUM;
|
||||
public static final UnitGroup UNITS_VOLTAGE;
|
||||
public static final UnitGroup UNITS_CURRENT;
|
||||
|
||||
|
||||
|
||||
|
||||
public static final Map<String, UnitGroup> UNITS; // keys such as "LENGTH", "VELOCITY"
|
||||
public static final Map<String, UnitGroup> SIUNITS; // keys such a "m", "m/s"
|
||||
|
||||
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
|
||||
/*
|
||||
* Note: Units may not use HTML tags.
|
||||
*
|
||||
@ -93,32 +100,32 @@ public class UnitGroup {
|
||||
static {
|
||||
UNITS_NONE = new UnitGroup();
|
||||
UNITS_NONE.addUnit(Unit.NOUNIT);
|
||||
|
||||
|
||||
UNITS_ENERGY = new UnitGroup();
|
||||
UNITS_ENERGY.addUnit(new GeneralUnit(1, "J"));
|
||||
UNITS_ENERGY.addUnit(new GeneralUnit(1e-7, "erg"));
|
||||
UNITS_ENERGY.addUnit(new GeneralUnit(1.055, "BTU"));
|
||||
UNITS_ENERGY.addUnit(new GeneralUnit(4.184, "cal"));
|
||||
UNITS_ENERGY.addUnit(new GeneralUnit(1.3558179483314, "ft" + DOT + "lbf"));
|
||||
|
||||
|
||||
UNITS_POWER = new UnitGroup();
|
||||
UNITS_POWER.addUnit(new GeneralUnit(1e-3, "mW"));
|
||||
UNITS_POWER.addUnit(new GeneralUnit(1, "W"));
|
||||
UNITS_POWER.addUnit(new GeneralUnit(1e3, "kW"));
|
||||
UNITS_POWER.addUnit(new GeneralUnit(1e-7, "ergs"));
|
||||
UNITS_POWER.addUnit(new GeneralUnit(745.699872, "hp"));
|
||||
|
||||
|
||||
UNITS_MOMENTUM = new UnitGroup();
|
||||
UNITS_MOMENTUM.addUnit(new GeneralUnit(1, "kg" + DOT + "m/s"));
|
||||
|
||||
|
||||
UNITS_VOLTAGE = new UnitGroup();
|
||||
UNITS_VOLTAGE.addUnit(new GeneralUnit(1e-3, "mV"));
|
||||
UNITS_VOLTAGE.addUnit(new GeneralUnit(1, "V"));
|
||||
|
||||
|
||||
UNITS_CURRENT = new UnitGroup();
|
||||
UNITS_CURRENT.addUnit(new GeneralUnit(1e-3, "mA"));
|
||||
UNITS_CURRENT.addUnit(new GeneralUnit(1, "A"));
|
||||
|
||||
|
||||
UNITS_LENGTH = new UnitGroup();
|
||||
UNITS_LENGTH.addUnit(new GeneralUnit(0.001, "mm"));
|
||||
UNITS_LENGTH.addUnit(new GeneralUnit(0.01, "cm"));
|
||||
@ -126,13 +133,13 @@ public class UnitGroup {
|
||||
UNITS_LENGTH.addUnit(new InchUnit(0.0254, "in", 0.1));
|
||||
UNITS_LENGTH.addUnit(new FractionalUnit(0.0254, "in/64", "in", 64, 1d / 16d, 0.5d / 64d));
|
||||
UNITS_LENGTH.addUnit(new GeneralUnit(0.3048, "ft"));
|
||||
|
||||
|
||||
UNITS_MOTOR_DIMENSIONS = new UnitGroup();
|
||||
UNITS_MOTOR_DIMENSIONS.addUnit(new GeneralUnit(0.001, "mm"));
|
||||
UNITS_MOTOR_DIMENSIONS.addUnit(new GeneralUnit(0.01, "cm"));
|
||||
UNITS_MOTOR_DIMENSIONS.addUnit(new GeneralUnit(1, "m"));
|
||||
UNITS_MOTOR_DIMENSIONS.addUnit(new GeneralUnit(0.0254, "in"));
|
||||
|
||||
|
||||
UNITS_DISTANCE = new UnitGroup();
|
||||
UNITS_DISTANCE.addUnit(new GeneralUnit(1, "m"));
|
||||
UNITS_DISTANCE.addUnit(new GeneralUnit(1000, "km"));
|
||||
@ -140,7 +147,7 @@ public class UnitGroup {
|
||||
UNITS_DISTANCE.addUnit(new GeneralUnit(0.9144, "yd"));
|
||||
UNITS_DISTANCE.addUnit(new GeneralUnit(1609.344, "mi"));
|
||||
UNITS_DISTANCE.addUnit(new GeneralUnit(1852, "nmi"));
|
||||
|
||||
|
||||
UNITS_ALL_LENGTHS = new UnitGroup();
|
||||
UNITS_ALL_LENGTHS.addUnit(new GeneralUnit(0.001, "mm"));
|
||||
UNITS_ALL_LENGTHS.addUnit(new GeneralUnit(0.01, "cm"));
|
||||
@ -152,15 +159,15 @@ public class UnitGroup {
|
||||
UNITS_ALL_LENGTHS.addUnit(new GeneralUnit(0.9144, "yd"));
|
||||
UNITS_ALL_LENGTHS.addUnit(new GeneralUnit(1609.344, "mi"));
|
||||
UNITS_ALL_LENGTHS.addUnit(new GeneralUnit(1852, "nmi"));
|
||||
|
||||
|
||||
UNITS_AREA = new UnitGroup();
|
||||
UNITS_AREA.addUnit(new GeneralUnit(pow2(0.001), "mm" + SQUARED));
|
||||
UNITS_AREA.addUnit(new GeneralUnit(pow2(0.01), "cm" + SQUARED));
|
||||
UNITS_AREA.addUnit(new GeneralUnit(1, "m" + SQUARED));
|
||||
UNITS_AREA.addUnit(new GeneralUnit(pow2(0.0254), "in" + SQUARED));
|
||||
UNITS_AREA.addUnit(new GeneralUnit(pow2(0.3048), "ft" + SQUARED));
|
||||
|
||||
|
||||
|
||||
|
||||
UNITS_STABILITY = new UnitGroup();
|
||||
UNITS_STABILITY.addUnit(new GeneralUnit(0.001, "mm"));
|
||||
UNITS_STABILITY.addUnit(new GeneralUnit(0.01, "cm"));
|
||||
@ -168,7 +175,7 @@ public class UnitGroup {
|
||||
UNITS_STABILITY.addUnit(new GeneralUnit(0.0254, "in"));
|
||||
UNITS_STABILITY.addUnit(new CaliberUnit((Rocket) null));
|
||||
UNITS_STABILITY.addUnit(new PercentageOfLengthUnit((Rocket) null));
|
||||
|
||||
|
||||
UNITS_STABILITY_CALIBERS = new UnitGroup();
|
||||
UNITS_STABILITY_CALIBERS.addUnit(new GeneralUnit(1, "cal"));
|
||||
|
||||
@ -178,25 +185,33 @@ public class UnitGroup {
|
||||
UNITS_VELOCITY.addUnit(new GeneralUnit(0.3048, "ft/s"));
|
||||
UNITS_VELOCITY.addUnit(new GeneralUnit(0.44704, "mph"));
|
||||
UNITS_VELOCITY.addUnit(new GeneralUnit(0.51444445, "kt"));
|
||||
|
||||
|
||||
UNITS_WINDSPEED = new UnitGroup();
|
||||
UNITS_WINDSPEED.addUnit(new GeneralUnit(1, "m/s"));
|
||||
UNITS_WINDSPEED.addUnit(new GeneralUnit(1 / 3.6, "km/h"));
|
||||
UNITS_WINDSPEED.addUnit(new GeneralUnit(0.3048, "ft/s"));
|
||||
UNITS_WINDSPEED.addUnit(new GeneralUnit(0.44704, "mph"));
|
||||
UNITS_WINDSPEED.addUnit(new GeneralUnit(0.51444445, "kt"));
|
||||
|
||||
|
||||
UNITS_LATITUDE = new UnitGroup();
|
||||
UNITS_LATITUDE.addUnit(new GeneralUnit(1, DEGREE + " " + trans.get("CompassRose.lbl.north")));
|
||||
UNITS_LATITUDE.addUnit(new GeneralUnit(-1, DEGREE + " " + trans.get("CompassRose.lbl.south")));
|
||||
|
||||
UNITS_LONGITUDE = new UnitGroup();
|
||||
UNITS_LONGITUDE.addUnit(new GeneralUnit(1, DEGREE + " " + trans.get("CompassRose.lbl.east")));
|
||||
UNITS_LONGITUDE.addUnit(new GeneralUnit(-1, DEGREE + " " + trans.get("CompassRose.lbl.west")));
|
||||
|
||||
UNITS_ACCELERATION = new UnitGroup();
|
||||
UNITS_ACCELERATION.addUnit(new GeneralUnit(1, "m/s" + SQUARED));
|
||||
UNITS_ACCELERATION.addUnit(new GeneralUnit(0.3048, "ft/s" + SQUARED));
|
||||
UNITS_ACCELERATION.addUnit(new GeneralUnit(9.80665, "G"));
|
||||
|
||||
|
||||
UNITS_MASS = new UnitGroup();
|
||||
UNITS_MASS.addUnit(new GeneralUnit(0.001, "g"));
|
||||
UNITS_MASS.addUnit(new GeneralUnit(1, "kg"));
|
||||
UNITS_MASS.addUnit(new GeneralUnit(0.0283495231, "oz"));
|
||||
UNITS_MASS.addUnit(new GeneralUnit(0.45359237, "lb"));
|
||||
|
||||
|
||||
UNITS_INERTIA = new UnitGroup();
|
||||
UNITS_INERTIA.addUnit(new GeneralUnit(0.0001, "kg" + DOT + "cm" + SQUARED));
|
||||
UNITS_INERTIA.addUnit(new GeneralUnit(1, "kg" + DOT + "m" + SQUARED));
|
||||
@ -204,19 +219,19 @@ public class UnitGroup {
|
||||
UNITS_INERTIA.addUnit(new GeneralUnit(0.000292639653, "lb" + DOT + "in" + SQUARED));
|
||||
UNITS_INERTIA.addUnit(new GeneralUnit(0.0421401101, "lb" + DOT + "ft" + SQUARED));
|
||||
UNITS_INERTIA.addUnit(new GeneralUnit(1.35581795, "lbf" + DOT + "ft" + DOT + "s" + SQUARED));
|
||||
|
||||
|
||||
UNITS_ANGLE = new UnitGroup();
|
||||
UNITS_ANGLE.addUnit(new DegreeUnit());
|
||||
UNITS_ANGLE.addUnit(new FixedPrecisionUnit("rad", 0.01));
|
||||
UNITS_ANGLE.addUnit(new GeneralUnit(1.0 / 3437.74677078, "arcmin"));
|
||||
|
||||
|
||||
UNITS_DENSITY_BULK = new UnitGroup();
|
||||
UNITS_DENSITY_BULK.addUnit(new GeneralUnit(1000, "g/cm" + CUBED));
|
||||
UNITS_DENSITY_BULK.addUnit(new GeneralUnit(1000, "kg/dm" + CUBED));
|
||||
UNITS_DENSITY_BULK.addUnit(new GeneralUnit(1, "kg/m" + CUBED));
|
||||
UNITS_DENSITY_BULK.addUnit(new GeneralUnit(1729.99404, "oz/in" + CUBED));
|
||||
UNITS_DENSITY_BULK.addUnit(new GeneralUnit(16.0184634, "lb/ft" + CUBED));
|
||||
|
||||
|
||||
UNITS_DENSITY_SURFACE = new UnitGroup();
|
||||
UNITS_DENSITY_SURFACE.addUnit(new GeneralUnit(10, "g/cm" + SQUARED));
|
||||
UNITS_DENSITY_SURFACE.addUnit(new GeneralUnit(0.001, "g/m" + SQUARED));
|
||||
@ -224,43 +239,43 @@ public class UnitGroup {
|
||||
UNITS_DENSITY_SURFACE.addUnit(new GeneralUnit(43.9418487, "oz/in" + SQUARED));
|
||||
UNITS_DENSITY_SURFACE.addUnit(new GeneralUnit(0.305151727, "oz/ft" + SQUARED));
|
||||
UNITS_DENSITY_SURFACE.addUnit(new GeneralUnit(4.88242764, "lb/ft" + SQUARED));
|
||||
|
||||
|
||||
UNITS_DENSITY_LINE = new UnitGroup();
|
||||
UNITS_DENSITY_LINE.addUnit(new GeneralUnit(0.001, "g/m"));
|
||||
UNITS_DENSITY_LINE.addUnit(new GeneralUnit(1, "kg/m"));
|
||||
UNITS_DENSITY_LINE.addUnit(new GeneralUnit(0.0930102465, "oz/ft"));
|
||||
|
||||
|
||||
UNITS_FORCE = new UnitGroup();
|
||||
UNITS_FORCE.addUnit(new GeneralUnit(1, "N"));
|
||||
UNITS_FORCE.addUnit(new GeneralUnit(4.44822162, "lbf"));
|
||||
UNITS_FORCE.addUnit(new GeneralUnit(9.80665, "kgf"));
|
||||
|
||||
|
||||
UNITS_IMPULSE = new UnitGroup();
|
||||
UNITS_IMPULSE.addUnit(new GeneralUnit(1, "Ns"));
|
||||
UNITS_IMPULSE.addUnit(new GeneralUnit(4.44822162, "lbf" + DOT + "s"));
|
||||
|
||||
|
||||
UNITS_TIME_STEP = new UnitGroup();
|
||||
UNITS_TIME_STEP.addUnit(new FixedPrecisionUnit("ms", 1, 0.001));
|
||||
UNITS_TIME_STEP.addUnit(new FixedPrecisionUnit("s", 0.01));
|
||||
|
||||
|
||||
UNITS_SHORT_TIME = new UnitGroup();
|
||||
UNITS_SHORT_TIME.addUnit(new GeneralUnit(1, "s"));
|
||||
|
||||
|
||||
UNITS_FLIGHT_TIME = new UnitGroup();
|
||||
UNITS_FLIGHT_TIME.addUnit(new GeneralUnit(1, "s"));
|
||||
UNITS_FLIGHT_TIME.addUnit(new GeneralUnit(60, "min"));
|
||||
|
||||
|
||||
UNITS_ROLL = new UnitGroup();
|
||||
UNITS_ROLL.addUnit(new GeneralUnit(1, "rad/s"));
|
||||
UNITS_ROLL.addUnit(new GeneralUnit(Math.PI / 180, DEGREE + "/s"));
|
||||
UNITS_ROLL.addUnit(new GeneralUnit(2 * Math.PI, "r/s"));
|
||||
UNITS_ROLL.addUnit(new GeneralUnit(2 * Math.PI / 60, "rpm"));
|
||||
|
||||
|
||||
UNITS_TEMPERATURE = new UnitGroup();
|
||||
UNITS_TEMPERATURE.addUnit(new FixedPrecisionUnit("K", 0.01));
|
||||
UNITS_TEMPERATURE.addUnit(new TemperatureUnit(1, 273.15, 0.01, DEGREE + "C"));
|
||||
UNITS_TEMPERATURE.addUnit(new TemperatureUnit(5.0 / 9.0, 459.67, 0.01, DEGREE + "F"));
|
||||
|
||||
|
||||
UNITS_PRESSURE = new UnitGroup();
|
||||
UNITS_PRESSURE.addUnit(new FixedPrecisionUnit("mbar", 0.01, 1.0e2));
|
||||
UNITS_PRESSURE.addUnit(new FixedPrecisionUnit("bar", 0.001, 1.0e5));
|
||||
@ -269,23 +284,23 @@ public class UnitGroup {
|
||||
UNITS_PRESSURE.addUnit(new FixedPrecisionUnit("inHg", 0.01, 3386.389));
|
||||
UNITS_PRESSURE.addUnit(new FixedPrecisionUnit("psi", 0.01, 6894.75729));
|
||||
UNITS_PRESSURE.addUnit(new GeneralUnit(1, "Pa"));
|
||||
|
||||
|
||||
UNITS_RELATIVE = new UnitGroup();
|
||||
UNITS_RELATIVE.addUnit(new FixedPrecisionUnit("" + ZWSP, 0.01, 1.0));
|
||||
UNITS_RELATIVE.addUnit(new GeneralUnit(0.01, "%"));
|
||||
UNITS_RELATIVE.addUnit(new FixedPrecisionUnit("" + PERMILLE, 1, 0.001));
|
||||
|
||||
|
||||
|
||||
|
||||
UNITS_ROUGHNESS = new UnitGroup();
|
||||
UNITS_ROUGHNESS.addUnit(new GeneralUnit(0.000001, MICRO + "m"));
|
||||
UNITS_ROUGHNESS.addUnit(new GeneralUnit(0.0000254, "mil"));
|
||||
UNITS_ROUGHNESS.addUnit(new GeneralUnit(1, "m"));
|
||||
|
||||
|
||||
|
||||
|
||||
UNITS_COEFFICIENT = new UnitGroup();
|
||||
UNITS_COEFFICIENT.addUnit(new FixedPrecisionUnit("" + ZWSP, 0.001)); // zero-width space
|
||||
|
||||
|
||||
|
||||
|
||||
// This is not used by OpenRocket, and not extensively tested:
|
||||
UNITS_FREQUENCY = new UnitGroup();
|
||||
UNITS_FREQUENCY.addUnit(new FrequencyUnit(.001, "mHz"));
|
||||
@ -293,7 +308,7 @@ public class UnitGroup {
|
||||
UNITS_FREQUENCY.addUnit(new FrequencyUnit(1000, "kHz"));
|
||||
|
||||
resetDefaultUnits();
|
||||
|
||||
|
||||
HashMap<String, UnitGroup> map = new HashMap<String, UnitGroup>();
|
||||
map.put("NONE", UNITS_NONE);
|
||||
map.put("LENGTH", UNITS_LENGTH);
|
||||
@ -328,9 +343,11 @@ public class UnitGroup {
|
||||
map.put("MOMENTUM", UNITS_MOMENTUM);
|
||||
map.put("FREQUENCY", UNITS_FREQUENCY);
|
||||
map.put("WINDSPEED", UNITS_WINDSPEED);
|
||||
|
||||
map.put("LATITUDE", UNITS_LATITUDE);
|
||||
map.put("LONGITUDE", UNITS_LONGITUDE);
|
||||
|
||||
UNITS = Collections.unmodifiableMap(map);
|
||||
|
||||
|
||||
HashMap<String, UnitGroup> simap = new HashMap<String, UnitGroup>();
|
||||
simap.put("m", UNITS_ALL_LENGTHS);
|
||||
simap.put("m^2", UNITS_AREA);
|
||||
@ -350,10 +367,10 @@ public class UnitGroup {
|
||||
simap.put("kg m/s", UNITS_MOMENTUM);
|
||||
simap.put("Hz", UNITS_FREQUENCY);
|
||||
simap.put("K", UNITS_TEMPERATURE);
|
||||
|
||||
|
||||
SIUNITS = Collections.unmodifiableMap(simap);
|
||||
}
|
||||
|
||||
|
||||
public static void setDefaultMetricUnits() {
|
||||
UNITS_LENGTH.setDefaultUnit("cm");
|
||||
UNITS_MOTOR_DIMENSIONS.setDefaultUnit("mm");
|
||||
@ -375,11 +392,13 @@ public class UnitGroup {
|
||||
UNITS_ROLL.setDefaultUnit("r/s");
|
||||
UNITS_TEMPERATURE.setDefaultUnit(DEGREE + "C");
|
||||
UNITS_WINDSPEED.setDefaultUnit("m/s");
|
||||
UNITS_LATITUDE.setDefaultUnit(DEGREE + " " + trans.get("CompassRose.lbl.north"));
|
||||
UNITS_LONGITUDE.setDefaultUnit(DEGREE + " " + trans.get("CompassRose.lbl.east"));
|
||||
UNITS_PRESSURE.setDefaultUnit("mbar");
|
||||
UNITS_RELATIVE.setDefaultUnit("%");
|
||||
UNITS_ROUGHNESS.setDefaultUnit(MICRO + "m");
|
||||
}
|
||||
|
||||
|
||||
public static void setDefaultImperialUnits() {
|
||||
UNITS_LENGTH.setDefaultUnit("in");
|
||||
UNITS_MOTOR_DIMENSIONS.setDefaultUnit("in");
|
||||
@ -401,6 +420,8 @@ public class UnitGroup {
|
||||
UNITS_ROLL.setDefaultUnit("r/s");
|
||||
UNITS_TEMPERATURE.setDefaultUnit(DEGREE + "F");
|
||||
UNITS_WINDSPEED.setDefaultUnit("mph");
|
||||
UNITS_LATITUDE.setDefaultUnit(DEGREE + " " + trans.get("CompassRose.lbl.north"));
|
||||
UNITS_LONGITUDE.setDefaultUnit(DEGREE + " " + trans.get("CompassRose.lbl.east"));
|
||||
UNITS_PRESSURE.setDefaultUnit("mbar");
|
||||
UNITS_RELATIVE.setDefaultUnit("%");
|
||||
UNITS_ROUGHNESS.setDefaultUnit("mil");
|
||||
@ -422,6 +443,8 @@ public class UnitGroup {
|
||||
UNITS_STABILITY_CALIBERS.setDefaultUnit(0);
|
||||
UNITS_VELOCITY.setDefaultUnit(0);
|
||||
UNITS_WINDSPEED.setDefaultUnit(0);
|
||||
UNITS_LATITUDE.setDefaultUnit(0);
|
||||
UNITS_LONGITUDE.setDefaultUnit(0);
|
||||
UNITS_ACCELERATION.setDefaultUnit(0);
|
||||
UNITS_MASS.setDefaultUnit(0);
|
||||
UNITS_INERTIA.setDefaultUnit(1);
|
||||
@ -442,66 +465,66 @@ public class UnitGroup {
|
||||
UNITS_COEFFICIENT.setDefaultUnit(0);
|
||||
UNITS_FREQUENCY.setDefaultUnit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a UnitGroup for stability units based on the rocket.
|
||||
*
|
||||
* @param rocket the rocket from which to calculate the caliber
|
||||
* @return the unit group
|
||||
*
|
||||
* @param rocket the rocket from which to calculate the caliber
|
||||
* @return the unit group
|
||||
*/
|
||||
public static UnitGroup stabilityUnits(Rocket rocket) {
|
||||
return new StabilityUnitGroup(rocket);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a UnitGroup for stability units based on the rocket configuration.
|
||||
*
|
||||
* @param config the rocket configuration from which to calculate the caliber
|
||||
* @return the unit group
|
||||
*
|
||||
* @param config the rocket configuration from which to calculate the caliber
|
||||
* @return the unit group
|
||||
*/
|
||||
public static UnitGroup stabilityUnits(FlightConfiguration config) {
|
||||
return new StabilityUnitGroup(config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a UnitGroup for stability units based on a constant caliber.
|
||||
*
|
||||
* @param reference the constant reference length
|
||||
* @return the unit group
|
||||
*
|
||||
* @param reference the constant reference length
|
||||
* @return the unit group
|
||||
*/
|
||||
public static UnitGroup stabilityUnits(double reference) {
|
||||
return new StabilityUnitGroup(reference);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
protected ArrayList<Unit> units = new ArrayList<Unit>();
|
||||
protected int defaultUnit = 0;
|
||||
|
||||
|
||||
public int getUnitCount() {
|
||||
return units.size();
|
||||
}
|
||||
|
||||
|
||||
public Unit getDefaultUnit() {
|
||||
return units.get(defaultUnit);
|
||||
}
|
||||
|
||||
|
||||
public int getDefaultUnitIndex() {
|
||||
return defaultUnit;
|
||||
}
|
||||
|
||||
|
||||
public void setDefaultUnit(int n) {
|
||||
if (n < 0 || n >= units.size()) {
|
||||
throw new IllegalArgumentException("index out of range: " + n);
|
||||
}
|
||||
defaultUnit = n;
|
||||
}
|
||||
|
||||
|
||||
public Unit getSIUnit() {
|
||||
for (Unit u : units) {
|
||||
if (u.multiplier == 1) {
|
||||
@ -510,14 +533,14 @@ public class UnitGroup {
|
||||
}
|
||||
return UNITS_NONE.getDefaultUnit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find a unit by approximate unit name. Only letters and (ordinary) numbers are
|
||||
* considered in the matching. This method is mainly means for testing, allowing
|
||||
* a simple means to obtain a particular unit.
|
||||
*
|
||||
* @param str the unit name.
|
||||
* @return the corresponding unit, or <code>null</code> if not found.
|
||||
*
|
||||
* @param str the unit name.
|
||||
* @return the corresponding unit, or <code>null</code> if not found.
|
||||
*/
|
||||
public Unit findApproximate(String str) {
|
||||
str = str.replaceAll("\\W", "").trim();
|
||||
@ -528,13 +551,13 @@ public class UnitGroup {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the default unit based on the unit name. Throws an exception if a
|
||||
* unit with the provided name is not available.
|
||||
*
|
||||
* @param name the unit name.
|
||||
* @throws IllegalArgumentException if the corresponding unit is not found in the group.
|
||||
*
|
||||
* @param name the unit name.
|
||||
* @throws IllegalArgumentException if the corresponding unit is not found in the group.
|
||||
*/
|
||||
public void setDefaultUnit(String name) throws IllegalArgumentException {
|
||||
for (int i = 0; i < units.size(); i++) {
|
||||
@ -545,7 +568,7 @@ public class UnitGroup {
|
||||
}
|
||||
throw new IllegalArgumentException("name=" + name);
|
||||
}
|
||||
|
||||
|
||||
public Unit getUnit(String name) throws IllegalArgumentException {
|
||||
for (int i = 0; i < units.size(); i++) {
|
||||
if (units.get(i).getUnit().equals(name)) {
|
||||
@ -554,31 +577,31 @@ public class UnitGroup {
|
||||
}
|
||||
throw new IllegalArgumentException("name=" + name);
|
||||
}
|
||||
|
||||
|
||||
public Unit getUnit(int n) {
|
||||
return units.get(n);
|
||||
}
|
||||
|
||||
|
||||
public int getUnitIndex(Unit u) {
|
||||
return units.indexOf(u);
|
||||
}
|
||||
|
||||
|
||||
public void addUnit(Unit u) {
|
||||
units.add(u);
|
||||
}
|
||||
|
||||
|
||||
public boolean contains(Unit u) {
|
||||
return units.contains(u);
|
||||
}
|
||||
|
||||
|
||||
public Unit[] getUnits() {
|
||||
return units.toArray(new Unit[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value in SI units from the default unit of this group.
|
||||
* It is the same as calling <code>getDefaultUnit().fromUnit(value)</code>
|
||||
*
|
||||
*
|
||||
* @param value the default unit value to convert
|
||||
* @return the value in SI units.
|
||||
* @see Unit#fromUnit(double)
|
||||
@ -586,51 +609,48 @@ public class UnitGroup {
|
||||
public double fromUnit(double value) {
|
||||
return this.getDefaultUnit().fromUnit(value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value formatted by the default unit of this group.
|
||||
* It is the same as calling <code>getDefaultUnit().toString(value)</code>.
|
||||
*
|
||||
* @param value the SI value to format.
|
||||
* @return the formatted string.
|
||||
* @see Unit#toString(double)
|
||||
*
|
||||
* @param value the SI value to format.
|
||||
* @return the formatted string.
|
||||
* @see Unit#toString(double)
|
||||
*/
|
||||
public String toString(double value) {
|
||||
return this.getDefaultUnit().toString(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the value formatted by the default unit of this group including the unit.
|
||||
* It is the same as calling <code>getDefaultUnit().toStringUnit(value)</code>.
|
||||
*
|
||||
* @param value the SI value to format.
|
||||
* @return the formatted string.
|
||||
* @see Unit#toStringUnit(double)
|
||||
*
|
||||
* @param value the SI value to format.
|
||||
* @return the formatted string.
|
||||
* @see Unit#toStringUnit(double)
|
||||
*/
|
||||
public String toStringUnit(double value) {
|
||||
return this.getDefaultUnit().toStringUnit(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new Value object with the specified value and the default unit of this group.
|
||||
*
|
||||
* @param value the value to set.
|
||||
* @return a new Value object.
|
||||
*
|
||||
* @param value the value to set.
|
||||
* @return a new Value object.
|
||||
*/
|
||||
public Value toValue(double value) {
|
||||
return this.getDefaultUnit().toValue(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName() + ":" + this.getSIUnit().toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
UnitGroup u = (UnitGroup) o;
|
||||
@ -638,43 +658,43 @@ public class UnitGroup {
|
||||
if (size != u.units.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!units.get(i).equals(u.units.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static final Pattern STRING_PATTERN = Pattern.compile("^\\s*([0-9.,-]+)(.*?)$");
|
||||
|
||||
|
||||
/**
|
||||
* Converts a string into an SI value. If the string has one of the units in this
|
||||
* group appended to it, that unit will be used in conversion. Otherwise the default
|
||||
* unit will be used. If an unknown unit is specified or the value does not parse
|
||||
* with <code>Double.parseDouble</code> then a <code>NumberFormatException</code>
|
||||
* with <code>Double.parseDouble</code> then a <code>NumberFormatException</code>
|
||||
* is thrown.
|
||||
* <p>
|
||||
* This method is applicable only for simple units without e.g. powers.
|
||||
*
|
||||
*
|
||||
* @param str the string to parse.
|
||||
* @return the SI value.
|
||||
* @return the SI value.
|
||||
* @throws NumberFormatException if the string cannot be parsed.
|
||||
*/
|
||||
public double fromString(String str) {
|
||||
Matcher matcher = STRING_PATTERN.matcher(str);
|
||||
|
||||
|
||||
if (!matcher.matches()) {
|
||||
throw new NumberFormatException("string did not match required pattern");
|
||||
}
|
||||
|
||||
double value = StringUtils.convertToDouble(matcher.group(1));
|
||||
String unit = matcher.group(2).trim();
|
||||
|
||||
|
||||
if (unit.equals("")) {
|
||||
value = this.getDefaultUnit().fromUnit(value);
|
||||
} else {
|
||||
@ -690,14 +710,14 @@ public class UnitGroup {
|
||||
throw new NumberFormatException("unknown unit " + unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 0;
|
||||
@ -706,21 +726,21 @@ public class UnitGroup {
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A private class that switches the CaliberUnit to a rocket-specific CaliberUnit.
|
||||
* All other methods are passed through to UNITS_STABILITY.
|
||||
*/
|
||||
private static class StabilityUnitGroup extends UnitGroup {
|
||||
|
||||
|
||||
public StabilityUnitGroup(double ref) { this(new CaliberUnit(ref), new PercentageOfLengthUnit(ref)); }
|
||||
|
||||
|
||||
public StabilityUnitGroup(Rocket rocket) {
|
||||
this(new CaliberUnit(rocket), new PercentageOfLengthUnit(rocket));
|
||||
}
|
||||
|
||||
|
||||
public StabilityUnitGroup(FlightConfiguration config) { this(new CaliberUnit(config), new PercentageOfLengthUnit(config)); }
|
||||
|
||||
|
||||
private StabilityUnitGroup(CaliberUnit caliberUnit, PercentageOfLengthUnit percentageOfLengthUnit) {
|
||||
this.units.addAll(UnitGroup.UNITS_STABILITY.units);
|
||||
this.defaultUnit = UnitGroup.UNITS_STABILITY.defaultUnit;
|
||||
@ -733,8 +753,8 @@ public class UnitGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setDefaultUnit(int n) {
|
||||
super.setDefaultUnit(n);
|
||||
|
@ -291,18 +291,17 @@ public class LaunchPreferencesPanel extends PreferencesPanel {
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label);
|
||||
|
||||
m = new DoubleModel(preferences, "LaunchLatitude",
|
||||
UnitGroup.UNITS_NONE, -90, 90);
|
||||
m = new DoubleModel(preferences, "LaunchLatitude", UnitGroup.UNITS_LATITUDE, -90, 90);
|
||||
|
||||
spin = new JSpinner(m.getSpinnerModel());
|
||||
spin.setEditor(new SpinnerEditor(spin));
|
||||
spin.setToolTipText(tip);
|
||||
sub.add(spin, "growx");
|
||||
|
||||
label = new JLabel(Chars.DEGREE + " " + trans.get("CompassRose.lbl.north"));
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel(-90, 90));
|
||||
unit = new UnitSelector(m);
|
||||
unit.setToolTipText(tip);
|
||||
sub.add(unit, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel());
|
||||
slider.setToolTipText(tip);
|
||||
sub.add(slider, "w 75lp, wrap");
|
||||
|
||||
@ -312,18 +311,17 @@ public class LaunchPreferencesPanel extends PreferencesPanel {
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label);
|
||||
|
||||
m = new DoubleModel(preferences, "LaunchLongitude",
|
||||
UnitGroup.UNITS_NONE, -180, 180);
|
||||
m = new DoubleModel(preferences, "LaunchLongitude", UnitGroup.UNITS_LONGITUDE, -180, 180);
|
||||
|
||||
spin = new JSpinner(m.getSpinnerModel());
|
||||
spin.setEditor(new SpinnerEditor(spin));
|
||||
spin.setToolTipText(tip);
|
||||
sub.add(spin, "growx");
|
||||
|
||||
label = new JLabel(Chars.DEGREE + " " + trans.get("CompassRose.lbl.east"));
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel(-180, 180));
|
||||
unit = new UnitSelector(m);
|
||||
unit.setToolTipText(tip);
|
||||
sub.add(unit, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel());
|
||||
slider.setToolTipText(tip);
|
||||
sub.add(slider, "w 75lp, wrap");
|
||||
|
||||
|
@ -8,6 +8,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.gui.components.StyledLabel;
|
||||
@ -20,120 +21,56 @@ public class UnitsPreferencesPanel extends PreferencesPanel {
|
||||
public UnitsPreferencesPanel(JDialog parent) {
|
||||
super(parent, new MigLayout("", "[][]40lp[][]"));
|
||||
JComboBox<?> combo;
|
||||
|
||||
// Create left and right panels
|
||||
JPanel leftPanel = new JPanel(new MigLayout("", "[][]"));
|
||||
JPanel rightPanel = new JPanel(new MigLayout("", "[][]"));
|
||||
|
||||
//// Select your preferred units:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Selectprefunits")), "span, wrap paragraph");
|
||||
|
||||
|
||||
//// Rocket dimensions:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Rocketdimensions")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_LENGTH));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Line density:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Linedensity")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_LINE));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Motor dimensions:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Motordimensions")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_MOTOR_DIMENSIONS));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Surface density:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Surfacedensity")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_SURFACE));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Distance:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Distance")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_DISTANCE));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Bulk density::
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Bulkdensity")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_BULK));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Velocity:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Velocity")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_VELOCITY));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Surface roughness:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Surfaceroughness")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_ROUGHNESS));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Acceleration:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Acceleration")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_ACCELERATION));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Area:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Area")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_AREA));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Mass:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Mass")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_MASS));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Angle:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Angle")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_ANGLE));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Force:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Force")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_FORCE));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Roll rate:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Rollrate")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_ROLL));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Total impulse:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Totalimpulse")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_IMPULSE));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Temperature:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Temperature")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_TEMPERATURE));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
//// Moment of inertia:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Momentofinertia")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_INERTIA));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Pressure:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Pressure")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_PRESSURE));
|
||||
this.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Stability:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Stability")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_STABILITY));
|
||||
this.add(combo, "sizegroup boxes");
|
||||
|
||||
//// Windspeed:
|
||||
this.add(new JLabel(trans.get("pref.dlg.lbl.Windspeed")));
|
||||
combo = new JComboBox<Object>(new DefaultUnitSelector(UnitGroup.UNITS_WINDSPEED));
|
||||
this.add(combo, "sizegroup boxes, wrap para");
|
||||
|
||||
|
||||
|
||||
|
||||
// Add widgets to the left panel
|
||||
String[] leftLabels = {
|
||||
"Rocketdimensions", "Motordimensions", "Distance", "Velocity",
|
||||
"Acceleration", "Mass", "Force", "Totalimpulse",
|
||||
"Momentofinertia", "Stability", "Linedensity"
|
||||
};
|
||||
UnitGroup[] leftUnitGroups = {
|
||||
UnitGroup.UNITS_LENGTH, UnitGroup.UNITS_MOTOR_DIMENSIONS, UnitGroup.UNITS_DISTANCE,
|
||||
UnitGroup.UNITS_VELOCITY, UnitGroup.UNITS_ACCELERATION, UnitGroup.UNITS_MASS,
|
||||
UnitGroup.UNITS_FORCE, UnitGroup.UNITS_IMPULSE, UnitGroup.UNITS_INERTIA,
|
||||
UnitGroup.UNITS_STABILITY, UnitGroup.UNITS_DENSITY_LINE
|
||||
};
|
||||
|
||||
for (int i = 0; i < leftLabels.length; i++) {
|
||||
leftPanel.add(new JLabel(trans.get("pref.dlg.lbl." + leftLabels[i])));
|
||||
combo = new JComboBox<>(new DefaultUnitSelector(leftUnitGroups[i]));
|
||||
leftPanel.add(combo, "sizegroup boxes, wrap");
|
||||
}
|
||||
|
||||
// Add widgets to the right panel
|
||||
String[] rightLabels = {
|
||||
"Surfacedensity", "Bulkdensity", "Surfaceroughness",
|
||||
"Area", "Angle", "Rollrate", "Temperature",
|
||||
"Pressure", "Windspeed", "Latitude", "Longitude"
|
||||
};
|
||||
UnitGroup[] rightUnitGroups = {
|
||||
UnitGroup.UNITS_DENSITY_SURFACE, UnitGroup.UNITS_DENSITY_BULK,
|
||||
UnitGroup.UNITS_ROUGHNESS, UnitGroup.UNITS_AREA, UnitGroup.UNITS_ANGLE,
|
||||
UnitGroup.UNITS_ROLL, UnitGroup.UNITS_TEMPERATURE, UnitGroup.UNITS_PRESSURE,
|
||||
UnitGroup.UNITS_WINDSPEED, UnitGroup.UNITS_LATITUDE, UnitGroup.UNITS_LONGITUDE
|
||||
};
|
||||
|
||||
for (int i = 0; i < rightLabels.length; i++) {
|
||||
rightPanel.add(new JLabel(trans.get("pref.dlg.lbl." + rightLabels[i])));
|
||||
combo = new JComboBox<>(new DefaultUnitSelector(rightUnitGroups[i]));
|
||||
rightPanel.add(combo, "sizegroup boxes, wrap");
|
||||
}
|
||||
|
||||
// Add left and right panels to the UnitsPreferencesPanel
|
||||
this.add(leftPanel);
|
||||
this.add(rightPanel, "wrap para");
|
||||
|
||||
|
||||
//// Default metric button
|
||||
|
@ -273,17 +273,17 @@ public class SimulationConditionsPanel extends JPanel {
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label);
|
||||
|
||||
m = new DoubleModel(conditions, "LaunchLatitude", UnitGroup.UNITS_NONE, -90, 90);
|
||||
m = new DoubleModel(conditions, "LaunchLatitude", UnitGroup.UNITS_LATITUDE, -90, 90);
|
||||
|
||||
spin = new JSpinner(m.getSpinnerModel());
|
||||
spin.setEditor(new SpinnerEditor(spin));
|
||||
spin.setToolTipText(tip);
|
||||
sub.add(spin, "w 65lp!");
|
||||
|
||||
label = new JLabel(Chars.DEGREE + " N");
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel(-90, 90));
|
||||
|
||||
unit = new UnitSelector(m);
|
||||
unit.setToolTipText(tip);
|
||||
sub.add(unit, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel());
|
||||
slider.setToolTipText(tip);
|
||||
sub.add(slider, "w 75lp, wrap");
|
||||
|
||||
@ -294,17 +294,17 @@ public class SimulationConditionsPanel extends JPanel {
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label);
|
||||
|
||||
m = new DoubleModel(conditions, "LaunchLongitude", UnitGroup.UNITS_NONE, -180, 180);
|
||||
m = new DoubleModel(conditions, "LaunchLongitude", UnitGroup.UNITS_LONGITUDE, -180, 180);
|
||||
|
||||
spin = new JSpinner(m.getSpinnerModel());
|
||||
spin.setEditor(new SpinnerEditor(spin));
|
||||
spin.setToolTipText(tip);
|
||||
sub.add(spin, "w 65lp!");
|
||||
|
||||
label = new JLabel(Chars.DEGREE + " E");
|
||||
label.setToolTipText(tip);
|
||||
sub.add(label, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel(-180, 180));
|
||||
|
||||
unit = new UnitSelector(m);
|
||||
unit.setToolTipText(tip);
|
||||
sub.add(unit, "growx");
|
||||
slider = new BasicSlider(m.getSliderModel());
|
||||
slider.setToolTipText(tip);
|
||||
sub.add(slider, "w 75lp, wrap");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user