PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/sigmah/src/test/java/org/sigmah/client/mock/JreCoordinateEditor.java

http://sigma-h.googlecode.com/
Java | 61 lines | 43 code | 11 blank | 7 comment | 2 complexity | 730e4a001a1988ad0c53fd28197496b4 MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.client.mock;
 7
 8import org.sigmah.shared.map.AbstractCoordinateEditor;
 9
10import java.text.NumberFormat;
11
12/**
13 * @author Alex Bertram (akbertram@gmail.com)
14 */
15public class JreCoordinateEditor extends AbstractCoordinateEditor {
16
17    public JreCoordinateEditor(String negHemiChars, String posHemiChars) {
18        this.negHemiChars = negHemiChars;
19        this.posHemiChars = posHemiChars;
20        this.decimalSeperators = ".,";
21        this.invalidMinutesMessage = "invalid minutes";
22        this.invalidSecondsMessage = "invalid seconds";
23        this.noHemisphereMessage = "no hemisphere specified";
24        this.tooManyNumbersErrorMessage = "too many numbers";
25        this.noNumberErrorMessage ="no numbers";
26    }
27   
28    @Override
29    protected Double parseDouble(String s) {
30        return Double.parseDouble(s);
31    }
32
33    @Override
34    protected String formatDDd(double value) {
35        NumberFormat fmt =  NumberFormat.getInstance();
36        fmt.setMinimumFractionDigits(6);
37        fmt.setMaximumFractionDigits(6);
38        fmt.setMinimumIntegerDigits(0);
39
40        if(value > 0) {
41            return "+" + fmt.format(value);
42        } else {
43            return fmt.format(value);
44        }
45    }
46
47    @Override
48    protected String formatShortFrac(double value) {
49        NumberFormat fmt =  NumberFormat.getInstance();
50        fmt.setMinimumFractionDigits(2);
51        fmt.setMaximumFractionDigits(2);
52        fmt.setMinimumIntegerDigits(0);
53
54        return fmt.format(value);
55    }
56
57    @Override
58    protected String formatInt(double value) {
59        return NumberFormat.getIntegerInstance().format(value);
60    }
61}