public class SystemOfMeasurement extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.String,SystemOfMeasurement> |
ALL_SYSTEMS
Known systems of measurement.
|
java.lang.String |
aName
First unit used to format text.
|
java.lang.String |
areaCustomName
Specific optional area unit.
|
double |
areaCustomValue
Specific optional area value, in squared meters, between
aValue*aValue and bValue*bValue . |
double |
aValue
First value, in meters, used to translate unit according to above formula.
|
java.lang.String |
bName
Second unit used to format text.
|
double |
bValue
Second value, in meters, used to translate unit according to above formula.
|
static SystemOfMeasurement |
CHINESE
Chinese system.
|
static SystemOfMeasurement |
IMPERIAL
Imperial system (British Commonwealth and former British Empire).
|
static SystemOfMeasurement |
METRIC
Metric system (international standard).
|
static SystemOfMeasurement |
NAUTICAL_MILE
Nautical mile system (navigation, polar exploration).
|
Constructor and Description |
---|
SystemOfMeasurement(double aValue,
java.lang.String aName,
double bValue,
java.lang.String bName)
System of measurement.
|
SystemOfMeasurement(double aValue,
java.lang.String aName,
double bValue,
java.lang.String bName,
double areaCustomValue,
java.lang.String areaCustomName)
System of measurement.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
formatText(double v,
java.lang.String unit,
java.text.NumberFormat format) |
java.lang.String |
getAreaText(double area)
Returns the text describing the given area in this system of measurement.
|
java.lang.String |
getAreaText(double area,
java.text.NumberFormat format,
double threshold)
Returns the text describing the given area in this system of measurement.
|
java.lang.String |
getDistText(double dist)
Returns the text describing the given distance in this system of measurement.
|
java.lang.String |
getDistText(double dist,
java.text.NumberFormat format,
double threshold)
Returns the text describing the given distance in this system of measurement.
|
public static final SystemOfMeasurement METRIC
public static final SystemOfMeasurement CHINESE
public static final SystemOfMeasurement IMPERIAL
public static final SystemOfMeasurement NAUTICAL_MILE
public static final java.util.Map<java.lang.String,SystemOfMeasurement> ALL_SYSTEMS
public final double aValue
public final double bValue
public final java.lang.String aName
public final java.lang.String bName
public final double areaCustomValue
aValue*aValue
and bValue*bValue
. Set to -1
if not used.public final java.lang.String areaCustomName
null
if not used.public SystemOfMeasurement(double aValue, java.lang.String aName, double bValue, java.lang.String bName)
aValue
- 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.public SystemOfMeasurement(double aValue, java.lang.String aName, double bValue, java.lang.String bName, double areaCustomValue, java.lang.String areaCustomName)
aValue
- 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.areaCustomValue
- Specific optional area value, in squared meters, between aValue*aValue
and bValue*bValue
.
Set to -1
if not used.areaCustomName
- Specific optional area unit. Set to null
if not used.public java.lang.String getDistText(double dist)
dist
- The distance in metrespublic java.lang.String getDistText(double dist, java.text.NumberFormat format, double threshold)
dist
- The distance in metresformat
- A NumberFormat
to format the area valuethreshold
- Values lower than this threshold
are displayed as "< [threshold]"
public java.lang.String getAreaText(double area)
area
- The area in square metrespublic java.lang.String getAreaText(double area, java.text.NumberFormat format, double threshold)
area
- The area in square metresformat
- A NumberFormat
to format the area valuethreshold
- Values lower than this threshold
are displayed as "< [threshold]"
private static java.lang.String formatText(double v, java.lang.String unit, java.text.NumberFormat format)