Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java @ 3017:296b067e17e6
i18n and format for line labels.
flys-artifacts/trunk@4582 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 05 Jun 2012 12:35:49 +0000 |
parents | e63969c173e9 |
children | 5642a83420f2 |
comparison
equal
deleted
inserted
replaced
3016:75e83b02bb9d | 3017:296b067e17e6 |
---|---|
74 public static final int FIX_DELTA_W_KM_MIN_DIGITS = 3; | 74 public static final int FIX_DELTA_W_KM_MIN_DIGITS = 3; |
75 public static final int FIX_DELTA_W_KM_MAX_DIGITS = 3; | 75 public static final int FIX_DELTA_W_KM_MAX_DIGITS = 3; |
76 public static final int FIX_DELTA_W_DELTA_W_MIN_DIGITS = 3; | 76 public static final int FIX_DELTA_W_DELTA_W_MIN_DIGITS = 3; |
77 public static final int FIX_DELTA_W_DELTA_W_MAX_DIGITS = 3; | 77 public static final int FIX_DELTA_W_DELTA_W_MAX_DIGITS = 3; |
78 | 78 |
79 /** | |
80 * Creates a localised NumberFormatter with given range of decimal digits. | |
81 * @param m CallMeta to find the locale. | |
82 * @param min minimum number of decimal ("fraction") digits. | |
83 * @param max maximum number of decimal ("fraction") digits. | |
84 * @return A NumberFormat. Use #format(NUMBER) to get String representation | |
85 * of NUMBER. | |
86 */ | |
79 public static NumberFormat getFormatter(CallMeta m, int min, int max){ | 87 public static NumberFormat getFormatter(CallMeta m, int min, int max){ |
80 Locale locale = Resources.getLocale(m); | 88 Locale locale = Resources.getLocale(m); |
81 NumberFormat nf = NumberFormat.getInstance(locale); | 89 NumberFormat nf = NumberFormat.getInstance(locale); |
82 | 90 |
83 nf.setMaximumFractionDigits(max); | 91 nf.setMaximumFractionDigits(max); |
345 return getFormatter( | 353 return getFormatter( |
346 context, | 354 context, |
347 FIX_DELTA_W_DELTA_W_MIN_DIGITS, | 355 FIX_DELTA_W_DELTA_W_MIN_DIGITS, |
348 FIX_DELTA_W_DELTA_W_MAX_DIGITS); | 356 FIX_DELTA_W_DELTA_W_MAX_DIGITS); |
349 } | 357 } |
358 | |
359 public static NumberFormat getMeterFormat(CallContext context) { | |
360 return getFormatter( | |
361 context, | |
362 0, | |
363 2); | |
364 | |
365 } | |
350 } | 366 } |
351 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 367 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |