Revision: 5368
http://sourceforge.net/p/jump-pilot/code/5368
Author: edso
Date: 2017-03-12 13:11:34 +0000 (Sun, 12 Mar 2017)
Log Message:
-----------
fix regression "#455 UI problem with decimal parameters and Locale" rendering
MultiInputDialog based plugins using decimal values unusable for locales
formatting decimal number w/ comma instead of dot
https://sourceforge.net/p/jump-pilot/bugs/455/
update ChangeLog
Modified Paths:
--------------
core/trunk/ChangeLog
core/trunk/src/com/vividsolutions/jump/util/StringUtil.java
Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog 2017-03-12 11:59:02 UTC (rev 5367)
+++ core/trunk/ChangeLog 2017-03-12 13:11:34 UTC (rev 5368)
@@ -3,10 +3,20 @@
# 2. make sure that lines break at 80 chars for constricted display situations
#<-------------------------------- 80 chars
---------------------------------->#
+2017-03-12 ede
+ * fix regression "#455 UI problem with decimal parameters and Locale"
+ rendering MultiInputDialog based plugins using decimal values unusable for
+ locales formatting decimal number w/ comma instead of dot
+ https://sourceforge.net/p/jump-pilot/bugs/455/
+
2017-03-11 Giuseppe Aruta
* Added CadTools extension to OpenJUMP Plus. A set of cad-like tools
and plugins mainly deriving from Kosmo 3.0 source code
+2017-03-06 ede
+ * initial java9 support, still compiled w/ java8
+ workbench comes up, PLUS extensions throw some errors during startup still
+
2017-03-04 mmichaud <[email protected]>
* Fix a bug in PostGIS writer happening in the evolution merging process
Modified: core/trunk/src/com/vividsolutions/jump/util/StringUtil.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/util/StringUtil.java 2017-03-12
11:59:02 UTC (rev 5367)
+++ core/trunk/src/com/vividsolutions/jump/util/StringUtil.java 2017-03-12
13:11:34 UTC (rev 5368)
@@ -33,6 +33,8 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -374,26 +376,23 @@
return buf.toString();
}
+ // set up a locale independent decimal formatter, using dot separator and
no grouping
+ static DecimalFormat allDecimals;
+ static {
+ DecimalFormatSymbols symbols = new DecimalFormatSymbols();
+ symbols.setDecimalSeparator('.');
+ allDecimals = new DecimalFormat("#0.0###########", symbols);
+ allDecimals.setGroupingUsed(false);
+ }
/**
- * format Doubles to String representation, cutting zeroes from the
decimal end
- * eg. 1234.000 -> "1234", 1234.5600 -> "1234.56"
+ * format Doubles to a String representation, cutting zeroes from the
decimal end
+ * the minimum number of decimals is one, hinting the decimal nature of
this number
+ * the maximimum number of decimal is hardcoded 12 and will be rounded
+ * eg. 1234.000 -> "1234.0", 1234.5600 -> "1234.56"
* @param d
* @return string
*/
public static String toString(double d) {
- if (d == (long) d)
- return String.format("%d", (long) d);
- else {
- // detect number of decimal digits (until there are only zeroes)
- int i = 1;
- for (; i <= 12; i++) {
- double factor = (double) Math.pow(10, i);
- double temp = ((long) (d * factor)) / factor;
- if (temp == d)
- return String.format("%." + i + "f", d);
- }
- // eventually we simply return the double
- return Double.toString(d);
- }
+ return allDecimals.format(d);
}
}
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel