diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.java @ 1297:887eb0cd7dfc

Bugfix: #375 Limit the number of fractions in the result of the measure controls (in the map). flys-client/trunk@2918 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 10 Oct 2011 09:31:08 +0000
parents 22dc88b17253
children 6890e1041eac
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.java	Mon Oct 10 09:06:01 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MeasureControl.java	Mon Oct 10 09:31:08 2011 +0000
@@ -1,6 +1,7 @@
 package de.intevation.flys.client.client.ui.map;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.i18n.client.NumberFormat;
 
 import com.smartgwt.client.types.SelectionType;
 import com.smartgwt.client.widgets.ImgButton;
@@ -22,6 +23,8 @@
 
 public class MeasureControl extends HLayout {
 
+    public static final String NUMBER_FORMAT_PATTERN = "#.##";
+
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
     protected FloodMap floodMap;
@@ -33,6 +36,8 @@
     protected ImgButton measurePolyButton;
     protected Label     label;
 
+    protected NumberFormat formatter;
+
 
     public MeasureControl(FloodMap floodMap, EnableDisableCmd cmd) {
         this.floodMap = floodMap;
@@ -40,6 +45,8 @@
         measureLineButton = createMeasureLineControl(cmd);
         measurePolyButton = createMeasurePolyControl(cmd);
 
+        formatter = NumberFormat.getFormat(NUMBER_FORMAT_PATTERN);
+
         label = new Label();
 
         initLayout();
@@ -144,7 +151,7 @@
 
 
     protected void updateMeasure(float value, String unit) {
-        label.setContents(String.valueOf(value) + " " + unit);
+        label.setContents(formatter.format(value) + " " + unit);
     }
 
 

http://dive4elements.wald.intevation.org