Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1296:c087137a8584 | 1297:887eb0cd7dfc |
---|---|
1 package de.intevation.flys.client.client.ui.map; | 1 package de.intevation.flys.client.client.ui.map; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 import com.google.gwt.i18n.client.NumberFormat; | |
4 | 5 |
5 import com.smartgwt.client.types.SelectionType; | 6 import com.smartgwt.client.types.SelectionType; |
6 import com.smartgwt.client.widgets.ImgButton; | 7 import com.smartgwt.client.widgets.ImgButton; |
7 import com.smartgwt.client.widgets.Label; | 8 import com.smartgwt.client.widgets.Label; |
8 import com.smartgwt.client.widgets.events.ClickEvent; | 9 import com.smartgwt.client.widgets.events.ClickEvent; |
20 import de.intevation.flys.client.client.utils.EnableDisableCmd; | 21 import de.intevation.flys.client.client.utils.EnableDisableCmd; |
21 | 22 |
22 | 23 |
23 public class MeasureControl extends HLayout { | 24 public class MeasureControl extends HLayout { |
24 | 25 |
26 public static final String NUMBER_FORMAT_PATTERN = "#.##"; | |
27 | |
25 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | 28 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
26 | 29 |
27 protected FloodMap floodMap; | 30 protected FloodMap floodMap; |
28 | 31 |
29 protected Measure measureLine; | 32 protected Measure measureLine; |
31 | 34 |
32 protected ImgButton measureLineButton; | 35 protected ImgButton measureLineButton; |
33 protected ImgButton measurePolyButton; | 36 protected ImgButton measurePolyButton; |
34 protected Label label; | 37 protected Label label; |
35 | 38 |
39 protected NumberFormat formatter; | |
40 | |
36 | 41 |
37 public MeasureControl(FloodMap floodMap, EnableDisableCmd cmd) { | 42 public MeasureControl(FloodMap floodMap, EnableDisableCmd cmd) { |
38 this.floodMap = floodMap; | 43 this.floodMap = floodMap; |
39 | 44 |
40 measureLineButton = createMeasureLineControl(cmd); | 45 measureLineButton = createMeasureLineControl(cmd); |
41 measurePolyButton = createMeasurePolyControl(cmd); | 46 measurePolyButton = createMeasurePolyControl(cmd); |
47 | |
48 formatter = NumberFormat.getFormat(NUMBER_FORMAT_PATTERN); | |
42 | 49 |
43 label = new Label(); | 50 label = new Label(); |
44 | 51 |
45 initLayout(); | 52 initLayout(); |
46 } | 53 } |
142 label.setContents(""); | 149 label.setContents(""); |
143 } | 150 } |
144 | 151 |
145 | 152 |
146 protected void updateMeasure(float value, String unit) { | 153 protected void updateMeasure(float value, String unit) { |
147 label.setContents(String.valueOf(value) + " " + unit); | 154 label.setContents(formatter.format(value) + " " + unit); |
148 } | 155 } |
149 | 156 |
150 | 157 |
151 public void activate(boolean activate) { | 158 public void activate(boolean activate) { |
152 if (!activate) { | 159 if (!activate) { |