diff options
author | Keith Packard <keithp@keithp.com> | 2015-05-19 10:09:22 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-05-19 10:09:22 -0700 |
commit | 3e5e9333420ede74d998556c1bbd5888e8ff75ae (patch) | |
tree | dbd6e450c8352e7a1005a28f5016d95769b962d0 /altosui/AltosConfigPyroUI.java | |
parent | 3fbf0a29a1b8a67b90ef965ee3e2e972c0ec33a1 (diff) |
altoslib: Expose locale and non-locale floating point parsing functions
UI bits use locale-specific floating point formats, so parsing those
needs to use the locale. Network-based data, like .kml bits need to
use non-locale-specific parsing code, so now we've got both APIs
available, and each used as appropriate.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosConfigPyroUI.java')
-rw-r--r-- | altosui/AltosConfigPyroUI.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index 61208dfe..69b31ff5 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -17,6 +17,7 @@ package altosui; +import java.text.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; @@ -87,9 +88,9 @@ public class AltosConfigPyroUI if (units != null) { try { - double v = units.parse(value.getText(), !imperial_units); + double v = units.parse_locale(value.getText(), !imperial_units); set(enabled(), v); - } catch (NumberFormatException ne) { + } catch (ParseException pe) { set(enabled(), 0.0); } } @@ -129,9 +130,9 @@ public class AltosConfigPyroUI AltosUnits units = AltosPyro.pyro_to_units(flag); try { if (units != null) - return units.parse(value.getText()); - return Double.parseDouble(value.getText()); - } catch (NumberFormatException e) { + return units.parse_locale(value.getText()); + return AltosParse.parse_double_locale(value.getText()); + } catch (ParseException e) { throw new AltosConfigDataException("\"%s\": %s\n", value.getText(), e.getMessage()); } } @@ -298,8 +299,8 @@ public class AltosConfigPyroUI String v = pyro_firing_time_value.getSelectedItem().toString(); try { - return Double.parseDouble(v); - } catch (NumberFormatException e) { + return AltosParse.parse_double_locale(v); + } catch (ParseException e) { throw new AltosConfigDataException("Invalid pyro firing time \"%s\"", v); } } |