- Timestamp:
- 2012-11-03T23:59:14+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r5549 r5560 4 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 5 6 import java.awt.Color;7 6 import java.awt.Cursor; 8 7 import java.awt.Graphics; … … 133 132 } 134 133 134 /** 135 * Returns the text describing the given distance in the current system of measurement. 136 * @param dist The distance in metres. 137 * @return the text describing the given distance in the current system of measurement. 138 * @since 3406 139 */ 135 140 public static String getDistText(double dist) { 136 141 return getSystemOfMeasurement().getDistText(dist); 142 } 143 144 /** 145 * Returns the text describing the given area in the current system of measurement. 146 * @param area The distance in square metres. 147 * @return the text describing the given area in the current system of measurement. 148 * @since 5560 149 */ 150 public static String getAreaText(double area) { 151 return getSystemOfMeasurement().getAreaText(area); 137 152 } 138 153 … … 1171 1186 } 1172 1187 1188 /** 1189 * Returns the current system of measurement. 1190 * @return The current system of measurement (metric system by default). 1191 * @since 3490 1192 */ 1173 1193 public static SystemOfMeasurement getSystemOfMeasurement() { 1174 1194 SystemOfMeasurement som = SYSTEMS_OF_MEASUREMENT.get(ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get()); … … 1178 1198 } 1179 1199 1200 /** 1201 * A system of units used to express length and area measurements. 1202 * @since 3406 1203 */ 1180 1204 public static class SystemOfMeasurement { 1181 1205 public final double aValue; … … 1185 1209 1186 1210 /** 1187 * System of measurement. Currently covers only length units.1211 * System of measurement. Currently covers only length (and area) units. 1188 1212 * 1189 1213 * If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as … … 1197 1221 } 1198 1222 1223 /** 1224 * Returns the text describing the given distance in this system of measurement. 1225 * @param dist The distance in metres 1226 * @return The text describing the given distance in this system of measurement. 1227 */ 1199 1228 public String getDistText(double dist) { 1200 1229 double a = dist / aValue; … … 1207 1236 return String.format(Locale.US, "%." + (a<10 ? 2 : 1) + "f %s", a, aName); 1208 1237 } 1209 } 1210 1238 1239 /** 1240 * Returns the text describing the given area in this system of measurement. 1241 * @param area The area in square metres 1242 * @return The text describing the given area in this system of measurement. 1243 * @since 5560 1244 */ 1245 public String getAreaText(double area) { 1246 return getDistText(area)+"\u00b2"; // square 1247 } 1248 } 1249 1250 /** 1251 * Metric system (international standard). 1252 * @since 3406 1253 */ 1211 1254 public static final SystemOfMeasurement METRIC_SOM = new SystemOfMeasurement(1, "m", 1000, "km"); 1255 1256 /** 1257 * Chinese system. 1258 * @since 3406 1259 */ 1212 1260 public static final SystemOfMeasurement CHINESE_SOM = new SystemOfMeasurement(1.0/3.0, "\u5e02\u5c3a" /* chi */, 500, "\u5e02\u91cc" /* li */); 1261 1262 /** 1263 * Imperial system (British Commonwealth and former British Empire). 1264 * @since 3406 1265 */ 1213 1266 public static final SystemOfMeasurement IMPERIAL_SOM = new SystemOfMeasurement(0.3048, "ft", 1609.344, "mi"); 1267 1268 /** 1269 * Nautical mile system (navigation, polar exploration). 1270 * @since 5549 1271 */ 1214 1272 public static final SystemOfMeasurement NAUTICAL_MILE_SOM = new SystemOfMeasurement(185.2, "kbl", 1852, "NM"); 1215 1273 1274 /** 1275 * Known systems of measurement. 1276 * @since 3406 1277 */ 1216 1278 public static final Map<String, SystemOfMeasurement> SYSTEMS_OF_MEASUREMENT; 1217 1279 static {
Note:
See TracChangeset
for help on using the changeset viewer.