Changeset 7135 in josm


Ignore:
Timestamp:
2014-05-17T04:49:16+02:00 (10 years ago)
Author:
simon04
Message:

Display numbers in map status line according to locale/language

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r7005 r7135  
    2727import java.awt.event.MouseMotionListener;
    2828import java.lang.reflect.InvocationTargetException;
     29import java.text.DecimalFormat;
    2930import java.util.ArrayList;
    3031import java.util.Collection;
     
    8586 */
    8687public class MapStatus extends JPanel implements Helpful, Destroyable, PreferenceChangedListener {
     88
     89    private static final DecimalFormat ONE_DECIMAL_PLACE = new DecimalFormat("0.0");
    8790
    8891    /**
     
    723726       
    724727        private final JSeparator separator = new JSeparator();
    725        
     728
    726729        private final JMenuItem doNotHide = new JCheckBoxMenuItem(new AbstractAction(tr("Do not hide status bar")) {
    727730            @Override
     
    743746                add(item);
    744747            }
    745            
     748
    746749            add(separator);
    747750            add(doNotHide);
    748            
     751
    749752            addPopupMenuListener(new PopupMenuListener() {
    750753                @Override
     
    947950
    948951    public void setAngle(double a) {
    949         angleText.setText(a < 0 ? "--" : Math.round(a*10)/10.0 + " \u00B0");
     952        angleText.setText(a < 0 ? "--" : ONE_DECIMAL_PLACE.format(a) + " \u00B0");
    950953    }
    951954
    952955    public void setHeading(double h) {
    953         headingText.setText(h < 0 ? "--" : Math.round(h*10)/10.0 + " \u00B0");
     956        headingText.setText(h < 0 ? "--" : ONE_DECIMAL_PLACE.format(h) + " \u00B0");
    954957    }
    955958
     
    960963    public void setDist(double dist) {
    961964        distValue = dist;
    962         distText.setText(dist < 0 ? "--" : NavigatableComponent.getDistText(dist));
     965        distText.setText(dist < 0 ? "--" : NavigatableComponent.getDistText(dist, ONE_DECIMAL_PLACE, 0.01));
    963966    }
    964967
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r7082 r7135  
    1010import java.awt.geom.Point2D;
    1111import java.nio.charset.StandardCharsets;
     12import java.text.NumberFormat;
    1213import java.util.ArrayList;
    1314import java.util.Collection;
     
    195196
    196197    /**
     198     * Returns the text describing the given distance in the current system of measurement.
     199     * @param dist The distance in metres
     200     * @param format A {@link NumberFormat} to format the area value
     201     * @param threshold Values lower than this {@code threshold} are displayed as {@code "< [threshold]"}
     202     * @return the text describing the given distance in the current system of measurement.
     203     * @since 7135
     204     */
     205    public static String getDistText(final double dist, final NumberFormat format, final double threshold) {
     206        return getSystemOfMeasurement().getDistText(dist, format, threshold);
     207    }
     208
     209    /**
    197210     * Returns the text describing the given area in the current system of measurement.
    198211     * @param area The distance in square metres.
     
    202215    public static String getAreaText(double area) {
    203216        return getSystemOfMeasurement().getAreaText(area);
     217    }
     218
     219    /**
     220     * Returns the text describing the given area in the current system of measurement.
     221     * @param area The area in square metres
     222     * @param format A {@link NumberFormat} to format the area value
     223     * @param threshold Values lower than this {@code threshold} are displayed as {@code "< [threshold]"}
     224     * @return the text describing the given area in the current system of measurement.
     225     * @since 7135
     226     */
     227    public static String getAreaText(final double area, final NumberFormat format, final double threshold) {
     228        return getSystemOfMeasurement().getAreaText(area, format, threshold);
    204229    }
    205230
Note: See TracChangeset for help on using the changeset viewer.