Changeset 10175 in josm for trunk/src/org
- Timestamp:
- 2016-05-10T17:56:23+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java
r8846 r10175 39 39 * @since 3406 40 40 */ 41 public static final SystemOfMeasurement METRIC = new SystemOfMeasurement(1, "m", 1000, "km", 10000, "ha");41 public static final SystemOfMeasurement METRIC = new SystemOfMeasurement(1, "m", 1000, "km", "km/h", 3.6, 10000, "ha"); 42 42 43 43 /** 44 44 * Chinese system. 45 * @since 3406 46 */ 47 public static final SystemOfMeasurement CHINESE = new SystemOfMeasurement(1.0/3.0, "\u5e02\u5c3a" /* chi */, 500, "\u5e02\u91cc" /* li */); 45 * See <a href="https://en.wikipedia.org/wiki/Chinese_units_of_measurement#Chinese_length_units_effective_in_1930">length units</a>, 46 * <a href="https://en.wikipedia.org/wiki/Chinese_units_of_measurement#Chinese_area_units_effective_in_1930">area units</a> 47 * @since 3406 48 */ 49 public static final SystemOfMeasurement CHINESE = new SystemOfMeasurement(1.0/3.0, "\u5e02\u5c3a" /* chi */, 500, "\u5e02\u91cc" /* li */, 50 "km/h", 3.6, 666.0 + 2.0/3.0, "\u4ea9" /* mu */); 48 51 49 52 /** … … 51 54 * @since 3406 52 55 */ 53 public static final SystemOfMeasurement IMPERIAL = new SystemOfMeasurement(0.3048, "ft", 1609.344, "mi", 4046.86, "ac");56 public static final SystemOfMeasurement IMPERIAL = new SystemOfMeasurement(0.3048, "ft", 1609.344, "mi", "mph", 2.23694, 4046.86, "ac"); 54 57 55 58 /** … … 57 60 * @since 5549 58 61 */ 59 public static final SystemOfMeasurement NAUTICAL_MILE = new SystemOfMeasurement(185.2, "kbl", 1852, "NM" );62 public static final SystemOfMeasurement NAUTICAL_MILE = new SystemOfMeasurement(185.2, "kbl", 1852, "NM", "kn", 1.94384); 60 63 61 64 /** … … 138 141 /** Second unit used to format text. */ 139 142 public final String bName; 143 /** Speed value for the most common speed symbol, in meters per second 144 * @since 10175 */ 145 public final double speedValue; 146 /** Most common speed symbol (kmh/h, mph, kn, etc.) 147 * @since 10175 */ 148 public final String speedName; 140 149 /** Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}. Set to {@code -1} if not used. 141 150 * @since 5870 */ … … 155 164 * @param bValue Second value, in meters, used to translate unit according to above formula. 156 165 * @param bName Second unit used to format text. 157 */ 158 public SystemOfMeasurement(double aValue, String aName, double bValue, String bName) { 159 this(aValue, aName, bValue, bName, -1, null); 166 * @param speedName the most common speed symbol (kmh/h, mph, kn, etc.) 167 * @param speedValue the speed value for the most common speed symbol, for 1 meter per second 168 * @since 10175 169 */ 170 public SystemOfMeasurement(double aValue, String aName, double bValue, String bName, String speedName, double speedValue) { 171 this(aValue, aName, bValue, bName, speedName, speedValue, -1, null); 160 172 } 161 173 … … 170 182 * @param bValue Second value, in meters, used to translate unit according to above formula. 171 183 * @param bName Second unit used to format text. 184 * @param speedName the most common speed symbol (kmh/h, mph, kn, etc.) 185 * @param speedValue the speed value for the most common speed symbol, for 1 meter per second 172 186 * @param areaCustomValue Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}. 173 187 * Set to {@code -1} if not used. 174 188 * @param areaCustomName Specific optional area unit. Set to {@code null} if not used. 175 189 * 176 * @since 5870 177 */ 178 public SystemOfMeasurement(double aValue, String aName, double bValue, String bName, double areaCustomValue, String areaCustomName) { 190 * @since 10175 191 */ 192 public SystemOfMeasurement(double aValue, String aName, double bValue, String bName, String speedName, double speedValue, 193 double areaCustomValue, String areaCustomName) { 179 194 this.aValue = aValue; 180 195 this.aName = aName; 181 196 this.bValue = bValue; 182 197 this.bName = bName; 198 this.speedValue = speedValue; 199 this.speedName = speedName; 183 200 this.areaCustomValue = areaCustomValue; 184 201 this.areaCustomName = areaCustomName; -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r10059 r10175 90 90 data = d; 91 91 drawHelper = new GpxDrawHelper(data); 92 SystemOfMeasurement.addSoMChangeListener(drawHelper); 92 93 ensureTrackVisibilityLength(); 93 94 setName(name); … … 390 391 return LayerPositionStrategy.AFTER_LAST_DATA_LAYER; 391 392 } 393 394 @Override 395 public void destroy() { 396 SystemOfMeasurement.removeSoMChangeListener(drawHelper); 397 } 392 398 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r9796 r10175 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.SystemOfMeasurement; 22 import org.openstreetmap.josm.data.SystemOfMeasurement.SoMChangeListener; 21 23 import org.openstreetmap.josm.data.coor.LatLon; 22 24 import org.openstreetmap.josm.data.gpx.GpxConstants; … … 30 32 * @since 7319 31 33 */ 32 public class GpxDrawHelper {34 public class GpxDrawHelper implements SoMChangeListener { 33 35 private final GpxData data; 34 36 … … 97 99 private void setupColors() { 98 100 hdopAlpha = Main.pref.getInteger("hdop.color.alpha", -1); 99 velocityScale = ColorScale.createHSBScale(256) .addTitle(tr("Velocity, km/h"));101 velocityScale = ColorScale.createHSBScale(256); 100 102 /** Colors (without custom alpha channel, if given) for HDOP painting. **/ 101 hdopScale = ColorScale.createHSBScale(256).makeReversed() .addTitle(tr("HDOP, m"));103 hdopScale = ColorScale.createHSBScale(256).makeReversed(); 102 104 dateScale = ColorScale.createHSBScale(256).addTitle(tr("Time")); 103 105 directionScale = ColorScale.createCyclicScale(256).setIntervalCount(4).addTitle(tr("Direction")); 106 systemOfMeasurementChanged(null, null); 107 } 108 109 @Override 110 public void systemOfMeasurementChanged(String oldSoM, String newSoM) { 111 SystemOfMeasurement som = SystemOfMeasurement.getSystemOfMeasurement(); 112 velocityScale.addTitle(tr("Velocity, {0}", som.speedName)); 113 hdopScale.addTitle(tr("HDOP, {0}", som.aName)); 114 if (Main.isDisplayingMapView() && oldSoM != null && newSoM != null) { 115 Main.map.mapView.repaint(); 116 } 104 117 } 105 118 … … 554 567 public void drawColorBar(Graphics2D g, MapView mv) { 555 568 int w = mv.getWidth(); 569 SystemOfMeasurement som = SystemOfMeasurement.getSystemOfMeasurement(); 556 570 if (colored == ColorMode.HDOP) { 557 hdopScale.drawColorBar(g, w-30, 50, 20, 100, 1.0);571 hdopScale.drawColorBar(g, w-30, 50, 20, 100, som.aValue); 558 572 } else if (colored == ColorMode.VELOCITY) { 559 velocityScale.drawColorBar(g, w-30, 50, 20, 100, 3.6);573 velocityScale.drawColorBar(g, w-30, 50, 20, 100, som.speedValue); 560 574 } else if (colored == ColorMode.DIRECTION) { 561 575 directionScale.drawColorBar(g, w-30, 50, 20, 100, 180.0/Math.PI);
Note:
See TracChangeset
for help on using the changeset viewer.