Fix to allow Editor table overlay to function when using non-en_US

locale.
This commit is contained in:
Dale Schultz 2016-09-12 16:56:22 -04:00
parent 5a421cf6ff
commit c03b5a03c6
3 changed files with 57 additions and 9 deletions

View File

@ -56,12 +56,13 @@ import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.swing.TableToolBar;
import com.romraider.util.JEPUtil;
import com.romraider.util.NumberUtil;
import com.romraider.util.SettingsManager;
import com.romraider.xml.RomAttributeParser;
public abstract class Table extends JPanel implements Serializable {
private static final long serialVersionUID = 6559256489995552645L;
private static final Logger LOGGER = Logger.getLogger(Table.class);
protected static final Logger LOGGER = Logger.getLogger(Table.class);
protected static int memModelEndian;
protected String name;
@ -1381,10 +1382,11 @@ public abstract class Table extends JPanel implements Serializable {
public void highlightLiveData(String liveVal) {
if (getOverlayLog()) {
double liveValue = 0.0;
try{
liveValue = Double.parseDouble(liveVal);
} catch(NumberFormatException nex) {
return;
try {
liveValue = NumberUtil.doubleValue(liveVal);
} catch (Exception ex) {
LOGGER.error("Table - live data highlight parsing error for value: " + liveVal);
return;
}
int startIdx = data.length;

View File

@ -20,10 +20,10 @@
package com.romraider.maps;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import com.romraider.Settings;
import com.romraider.util.NumberUtil;
public class Table1D extends Table {
private static final long serialVersionUID = -8747180767803835631L;
@ -257,9 +257,10 @@ public class Table1D extends Table {
public void highlightLiveData(String liveVal) {
if (getOverlayLog()) {
double liveValue = 0.0;
try{
liveValue = Double.parseDouble(liveVal);
} catch(NumberFormatException nex) {
try {
liveValue = NumberUtil.doubleValue(liveVal);
} catch (Exception ex) {
LOGGER.error("Table1D - live data highlight parsing error for value: " + liveVal);
return;
}

View File

@ -0,0 +1,45 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2016 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.util;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
/**
* This class provides Number conversion utilities based on the default Locale.
*/
public final class NumberUtil {
private static final NumberFormat numFormat = NumberFormat.getInstance(Locale.getDefault());
private NumberUtil() {
}
/**
* Returns the value of the specified number in the default locale as a double.
* @param str - string to be converted.
* @return the numeric value represented by this object after conversion
* to type double.
* @exception ParseException is thrown when parse errors are encountered.
*/
public static double doubleValue(String str) throws ParseException {
return numFormat.parse(str).doubleValue();
}
}