Commit 6ae88226 authored by Stephane Dallongeville's avatar Stephane Dallongeville
Browse files

Fixed number parsing

parent f60b919e
......@@ -4,9 +4,6 @@
package plugins.stef.roi.bloc.op;
import java.awt.Color;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
......@@ -92,9 +89,6 @@ public class FilterROI extends Plugin implements ROIBlock, PluginLibrary, Plugin
}
}
private static final DecimalFormat format = (DecimalFormat) NumberFormat.getInstance();
private static final DecimalFormatSymbols symbols = format.getDecimalFormatSymbols();
private static final char decimalSep = symbols.getDecimalSeparator();
private static final AlphanumComparator comp = new AlphanumComparator();
protected final VarROIArray roiSet = new VarROIArray("ROI(s)", null);
......@@ -170,34 +164,25 @@ public class FilterROI extends Plugin implements ROIBlock, PluginLibrary, Plugin
private static Object getTypedValue(String value)
{
final String adjValue = value.replace('.', decimalSep).replace(',', decimalSep);
try
{
return Double.valueOf(Double.parseDouble(adjValue));
return Double.valueOf(Double.parseDouble(value.replace(',', '.')));
}
catch (NumberFormatException e1)
{
try
{
return Float.valueOf(Float.parseFloat(adjValue));
return Double.valueOf(Float.parseFloat(value.replace('.', ',')));
}
catch (NumberFormatException e2)
{
try
{
return Integer.valueOf(Integer.parseInt(adjValue));
return Long.valueOf(Long.parseLong(value));
}
catch (NumberFormatException e3)
catch (NumberFormatException e4)
{
try
{
return Long.valueOf(Long.parseLong(adjValue));
}
catch (NumberFormatException e4)
{
// probably not a number then...
}
// probably not a number then...
}
}
}
......@@ -322,7 +307,7 @@ public class FilterROI extends Plugin implements ROIBlock, PluginLibrary, Plugin
}
catch (VarException e1)
{
throw e1;
throw e1;
}
catch (Exception e2)
{
......@@ -363,7 +348,7 @@ public class FilterROI extends Plugin implements ROIBlock, PluginLibrary, Plugin
}
catch (VarException e1)
{
throw e1;
throw e1;
}
catch (Exception e2)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment