Index: /trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java (revision 10174)
+++ /trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java (revision 10175)
@@ -39,11 +39,14 @@
* @since 3406
*/
- public static final SystemOfMeasurement METRIC = new SystemOfMeasurement(1, "m", 1000, "km", 10000, "ha");
+ public static final SystemOfMeasurement METRIC = new SystemOfMeasurement(1, "m", 1000, "km", "km/h", 3.6, 10000, "ha");
/**
* Chinese system.
- * @since 3406
- */
- public static final SystemOfMeasurement CHINESE = new SystemOfMeasurement(1.0/3.0, "\u5e02\u5c3a" /* chi */, 500, "\u5e02\u91cc" /* li */);
+ * See length units,
+ * area units
+ * @since 3406
+ */
+ public static final SystemOfMeasurement CHINESE = new SystemOfMeasurement(1.0/3.0, "\u5e02\u5c3a" /* chi */, 500, "\u5e02\u91cc" /* li */,
+ "km/h", 3.6, 666.0 + 2.0/3.0, "\u4ea9" /* mu */);
/**
@@ -51,5 +54,5 @@
* @since 3406
*/
- public static final SystemOfMeasurement IMPERIAL = new SystemOfMeasurement(0.3048, "ft", 1609.344, "mi", 4046.86, "ac");
+ public static final SystemOfMeasurement IMPERIAL = new SystemOfMeasurement(0.3048, "ft", 1609.344, "mi", "mph", 2.23694, 4046.86, "ac");
/**
@@ -57,5 +60,5 @@
* @since 5549
*/
- public static final SystemOfMeasurement NAUTICAL_MILE = new SystemOfMeasurement(185.2, "kbl", 1852, "NM");
+ public static final SystemOfMeasurement NAUTICAL_MILE = new SystemOfMeasurement(185.2, "kbl", 1852, "NM", "kn", 1.94384);
/**
@@ -138,4 +141,10 @@
/** Second unit used to format text. */
public final String bName;
+ /** Speed value for the most common speed symbol, in meters per second
+ * @since 10175 */
+ public final double speedValue;
+ /** Most common speed symbol (kmh/h, mph, kn, etc.)
+ * @since 10175 */
+ public final String speedName;
/** Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}. Set to {@code -1} if not used.
* @since 5870 */
@@ -155,7 +164,10 @@
* @param bValue Second value, in meters, used to translate unit according to above formula.
* @param bName Second unit used to format text.
- */
- public SystemOfMeasurement(double aValue, String aName, double bValue, String bName) {
- this(aValue, aName, bValue, bName, -1, null);
+ * @param speedName the most common speed symbol (kmh/h, mph, kn, etc.)
+ * @param speedValue the speed value for the most common speed symbol, for 1 meter per second
+ * @since 10175
+ */
+ public SystemOfMeasurement(double aValue, String aName, double bValue, String bName, String speedName, double speedValue) {
+ this(aValue, aName, bValue, bName, speedName, speedValue, -1, null);
}
@@ -170,15 +182,20 @@
* @param bValue Second value, in meters, used to translate unit according to above formula.
* @param bName Second unit used to format text.
+ * @param speedName the most common speed symbol (kmh/h, mph, kn, etc.)
+ * @param speedValue the speed value for the most common speed symbol, for 1 meter per second
* @param areaCustomValue Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}.
* Set to {@code -1} if not used.
* @param areaCustomName Specific optional area unit. Set to {@code null} if not used.
*
- * @since 5870
- */
- public SystemOfMeasurement(double aValue, String aName, double bValue, String bName, double areaCustomValue, String areaCustomName) {
+ * @since 10175
+ */
+ public SystemOfMeasurement(double aValue, String aName, double bValue, String bName, String speedName, double speedValue,
+ double areaCustomValue, String areaCustomName) {
this.aValue = aValue;
this.aName = aName;
this.bValue = bValue;
this.bName = bName;
+ this.speedValue = speedValue;
+ this.speedName = speedName;
this.areaCustomValue = areaCustomValue;
this.areaCustomName = areaCustomName;
Index: /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java (revision 10174)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java (revision 10175)
@@ -90,4 +90,5 @@
data = d;
drawHelper = new GpxDrawHelper(data);
+ SystemOfMeasurement.addSoMChangeListener(drawHelper);
ensureTrackVisibilityLength();
setName(name);
@@ -390,3 +391,8 @@
return LayerPositionStrategy.AFTER_LAST_DATA_LAYER;
}
+
+ @Override
+ public void destroy() {
+ SystemOfMeasurement.removeSoMChangeListener(drawHelper);
+ }
}
Index: /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java (revision 10174)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java (revision 10175)
@@ -19,4 +19,6 @@
import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.SystemOfMeasurement;
+import org.openstreetmap.josm.data.SystemOfMeasurement.SoMChangeListener;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.gpx.GpxConstants;
@@ -30,5 +32,5 @@
* @since 7319
*/
-public class GpxDrawHelper {
+public class GpxDrawHelper implements SoMChangeListener {
private final GpxData data;
@@ -97,9 +99,20 @@
private void setupColors() {
hdopAlpha = Main.pref.getInteger("hdop.color.alpha", -1);
- velocityScale = ColorScale.createHSBScale(256).addTitle(tr("Velocity, km/h"));
+ velocityScale = ColorScale.createHSBScale(256);
/** Colors (without custom alpha channel, if given) for HDOP painting. **/
- hdopScale = ColorScale.createHSBScale(256).makeReversed().addTitle(tr("HDOP, m"));
+ hdopScale = ColorScale.createHSBScale(256).makeReversed();
dateScale = ColorScale.createHSBScale(256).addTitle(tr("Time"));
directionScale = ColorScale.createCyclicScale(256).setIntervalCount(4).addTitle(tr("Direction"));
+ systemOfMeasurementChanged(null, null);
+ }
+
+ @Override
+ public void systemOfMeasurementChanged(String oldSoM, String newSoM) {
+ SystemOfMeasurement som = SystemOfMeasurement.getSystemOfMeasurement();
+ velocityScale.addTitle(tr("Velocity, {0}", som.speedName));
+ hdopScale.addTitle(tr("HDOP, {0}", som.aName));
+ if (Main.isDisplayingMapView() && oldSoM != null && newSoM != null) {
+ Main.map.mapView.repaint();
+ }
}
@@ -554,8 +567,9 @@
public void drawColorBar(Graphics2D g, MapView mv) {
int w = mv.getWidth();
+ SystemOfMeasurement som = SystemOfMeasurement.getSystemOfMeasurement();
if (colored == ColorMode.HDOP) {
- hdopScale.drawColorBar(g, w-30, 50, 20, 100, 1.0);
+ hdopScale.drawColorBar(g, w-30, 50, 20, 100, som.aValue);
} else if (colored == ColorMode.VELOCITY) {
- velocityScale.drawColorBar(g, w-30, 50, 20, 100, 3.6);
+ velocityScale.drawColorBar(g, w-30, 50, 20, 100, som.speedValue);
} else if (colored == ColorMode.DIRECTION) {
directionScale.drawColorBar(g, w-30, 50, 20, 100, 180.0/Math.PI);