Package org.openstreetmap.josm.data
Class SystemOfMeasurement
java.lang.Object
org.openstreetmap.josm.data.SystemOfMeasurement
A system of units used to express length and area measurements.
This class also manages one globally set system of measurement stored in the ProjectionPreference
- Since:
- 3406 (creation), 6992 (extraction in this package)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface to notify listeners of the change of the system of measurement. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Map<String,SystemOfMeasurement> Known systems of measurement.final StringFirst unit used to format text.final StringSpecific optional area unit.final doubleSpecific optional area value, in squared meters, betweenaValue*aValueandbValue*bValue.final doubleFirst value, in meters, used to translate unit according to above formula.final StringSecond unit used to format text.final doubleSecond value, in meters, used to translate unit according to above formula.static final SystemOfMeasurementChinese system.static final SystemOfMeasurementImperial system (British Commonwealth and former British Empire).static final SystemOfMeasurementMetric system (international standard).private final StringTranslatable name of this system of measurement.static final SystemOfMeasurementNautical mile system (navigation, polar exploration).static final StringPropertyPreferences entry for system of measurement.private static final CopyOnWriteArrayList<SystemOfMeasurement.SoMChangeListener>final StringMost common speed symbol (kmh/h, mph, kn, etc.)final doubleSpeed value for the most common speed symbol, in meters per second -
Constructor Summary
ConstructorsConstructorDescriptionSystemOfMeasurement(String name, double aValue, String aName, double bValue, String bName, String speedName, double speedValue) System of measurement.SystemOfMeasurement(String name, double aValue, String aName, double bValue, String bName, String speedName, double speedValue, double areaCustomValue, String areaCustomName) System of measurement. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a SoM change listener.protected static voidfireSoMChanged(String oldSoM, String newSoM) private static StringformatText(double v, String unit, NumberFormat format) getAreaText(double area) Returns the text describing the given area in this system of measurement.getAreaText(double area, NumberFormat format, double threshold) Returns the text describing the given area in this system of measurement.static SystemOfMeasurementReturns the default system of measurement for the current country.getDistText(double dist) Returns the text describing the given distance in this system of measurement.getDistText(double dist, NumberFormat format, double threshold) Returns the text describing the given distance in this system of measurement.getName()Returns the translatable name of this system of measurement.static SystemOfMeasurementReturns the current global system of measurement.static voidRemoves a global SoM change listener.static voidSets the current global system of measurement.toString()Returns the localized name of this system of measurement
-
Field Details
-
METRIC
Metric system (international standard).- Since:
- 3406
-
CHINESE
Chinese system. See length units, area units- Since:
- 3406
-
IMPERIAL
Imperial system (British Commonwealth and former British Empire).- Since:
- 3406
-
NAUTICAL_MILE
Nautical mile system (navigation, polar exploration).- Since:
- 5549
-
ALL_SYSTEMS
Known systems of measurement.- Since:
- 3406
-
PROP_SYSTEM_OF_MEASUREMENT
Preferences entry for system of measurement.- Since:
- 12674 (moved from ProjectionPreference)
-
somChangeListeners
-
name
Translatable name of this system of measurement. -
aValue
First value, in meters, used to translate unit according to above formula. -
bValue
Second value, in meters, used to translate unit according to above formula. -
aName
First unit used to format text. -
bName
Second unit used to format text. -
speedValue
Speed value for the most common speed symbol, in meters per second- Since:
- 10175
-
speedName
Most common speed symbol (kmh/h, mph, kn, etc.)- Since:
- 10175
-
areaCustomValue
Specific optional area value, in squared meters, betweenaValue*aValueandbValue*bValue. Set to-1if not used.- Since:
- 5870
-
areaCustomName
Specific optional area unit. Set tonullif not used.- Since:
- 5870
-
-
Constructor Details
-
SystemOfMeasurement
public SystemOfMeasurement(String name, double aValue, String aName, double bValue, String bName, String speedName, double speedValue) System of measurement. Currently covers only length (and area) units. If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as x_a == x_m / aValue- Parameters:
name- Translatable name of this system of measurementaValue- First value, in meters, used to translate unit according to above formula.aName- First unit used to format text.bValue- Second value, in meters, used to translate unit according to above formula.bName- Second unit used to format text.speedName- the most common speed symbol (kmh/h, mph, kn, etc.)speedValue- the speed value for the most common speed symbol, for 1 meter per second- Since:
- 15395
-
SystemOfMeasurement
public SystemOfMeasurement(String name, double aValue, String aName, double bValue, String bName, String speedName, double speedValue, double areaCustomValue, String areaCustomName) System of measurement. Currently covers only length (and area) units. If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as x_a == x_m / aValue- Parameters:
name- Translatable name of this system of measurementaValue- First value, in meters, used to translate unit according to above formula.aName- First unit used to format text.bValue- Second value, in meters, used to translate unit according to above formula.bName- Second unit used to format text.speedName- the most common speed symbol (kmh/h, mph, kn, etc.)speedValue- the speed value for the most common speed symbol, for 1 meter per secondareaCustomValue- Specific optional area value, in squared meters, betweenaValue*aValueandbValue*bValue. Set to-1if not used.areaCustomName- Specific optional area unit. Set tonullif not used.- Since:
- 15395
-
-
Method Details
-
removeSoMChangeListener
Removes a global SoM change listener.- Parameters:
listener- the listener. Ignored if null or already absent- Since:
- 8554
-
addSoMChangeListener
Adds a SoM change listener.- Parameters:
listener- the listener. Ignored if null or already registered.- Since:
- 8554
-
fireSoMChanged
-
getSystemOfMeasurement
Returns the current global system of measurement.- Returns:
- The current system of measurement (metric system by default).
- Since:
- 8554
-
setSystemOfMeasurement
Sets the current global system of measurement.- Parameters:
som- The system of measurement to set. Must be defined inALL_SYSTEMS.- Throws:
IllegalArgumentException- ifsomis not known- Since:
- 16985 (signature)
-
getDistText
Returns the text describing the given distance in this system of measurement.- Parameters:
dist- The distance in metres- Returns:
- The text describing the given distance in this system of measurement.
-
getDistText
Returns the text describing the given distance in this system of measurement.- Parameters:
dist- The distance in metresformat- ANumberFormatto format the area valuethreshold- Values lower than thisthresholdare displayed as"< [threshold]"- Returns:
- The text describing the given distance in this system of measurement.
- Since:
- 6422
-
getAreaText
Returns the text describing the given area in this system of measurement.- Parameters:
area- The area in square metres- Returns:
- The text describing the given area in this system of measurement.
- Since:
- 5560
-
getAreaText
Returns the text describing the given area in this system of measurement.- Parameters:
area- The area in square metresformat- ANumberFormatto format the area valuethreshold- Values lower than thisthresholdare displayed as"< [threshold]"- Returns:
- The text describing the given area in this system of measurement.
- Since:
- 6422
-
getName
Returns the translatable name of this system of measurement.- Returns:
- the translatable name of this system of measurement
- Since:
- 15395
-
toString
Returns the localized name of this system of measurement -
getDefault
Returns the default system of measurement for the current country.- Returns:
- the default system of measurement for the current country
- Since:
- 15395
-
formatText
-