Package org.ka2ddo.util
Enum Class DistanceUnit
- All Implemented Interfaces:
Serializable
,Comparable<DistanceUnit>
,Constable
,UnitEnum<DistanceUnit>
,UnitEnumHasShortUnit<DistanceUnit>
This enumeration declares units (with conversion factors) for measuring distances.
- Author:
- Andrew Pavlin, KA2DDO
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionDistances in centimeters.Distances in degrees of latitude upon the Earth.Distances in feet.Distances in inches.Distances in kilometers,Distances in meters.Distances in statute miles.Distances in millimeters.Distances in nautical miles.Distances (heights) in building floors or stories. -
Field Summary
Modifier and TypeFieldDescriptionstatic final float
Convenience constant for degrees latitude to meters when both units are fixed in equation.static final float
Convenience constant for meters to degrees latitude when both units are fixed in equation.static final float
Convenience constant for meters to feet when both units are fixed in equation.static final float
Convenience constant for meters to statute miles when both units are fixed in equation.static final float
Convenience constant for nautical miles to meters when both units are fixed in equation.static final float
Convenience constant for nautical miles to statute miles. -
Method Summary
Modifier and TypeMethodDescriptionfinal float
from
(DistanceUnit other) Get the multiplicative conversion factor to convert a distance from the specified units to this unit.Get short standard abbreviations for this DistanceUnit.int
getDepth()
Get depth index for this unit instance's hierarchy of different-sized units.float
getOffset
(DistanceUnit other) Get the additive offset to convert a value from the specified unit to this unit.final DistanceUnit
Get the shorter DistanceUnit associated with this DistanceUnit.Get the descriptive String for a DistanceUnit when used for velocity as DistanceUnit per hour.static DistanceUnit[]
Get an array of all DistanceUnits that can do speeds.final DistanceUnit
Get the extremely short DistanceUnit associated with this DistanceUnit.static DistanceUnit
getUnitForName
(String name) Convert a string representing the abbreviations for a DistanceUnit into the enum instance for that unit.static DistanceUnit
lookupSpeedUnit
(String speedUnit) Find the DistanceUnit whose speed has the specified unit name.static DistanceUnit
Returns the enum constant of this class with the specified name.static DistanceUnit[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
MM
Distances in millimeters. -
CM
Distances in centimeters. -
INCH
Distances in inches. -
METER
Distances in meters. -
FEET
Distances in feet. -
KM
Distances in kilometers, -
MI
Distances in statute miles. -
NM
Distances in nautical miles. -
DEG_LAT
Distances in degrees of latitude upon the Earth. -
STORIES
Distances (heights) in building floors or stories.
-
-
Field Details
-
CONV_DEGLAT_TO_METERS
public static final float CONV_DEGLAT_TO_METERSConvenience constant for degrees latitude to meters when both units are fixed in equation. -
CONV_METERS_TO_DEGLAT
public static final float CONV_METERS_TO_DEGLATConvenience constant for meters to degrees latitude when both units are fixed in equation. -
CONV_NM_TO_METERS
public static final float CONV_NM_TO_METERSConvenience constant for nautical miles to meters when both units are fixed in equation. -
CONV_METERS_TO_MI
public static final float CONV_METERS_TO_MIConvenience constant for meters to statute miles when both units are fixed in equation. -
CONV_METERS_TO_FT
public static final float CONV_METERS_TO_FTConvenience constant for meters to feet when both units are fixed in equation. -
CONV_NM_TO_MI
public static final float CONV_NM_TO_MIConvenience constant for nautical miles to statute miles.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
from
Get the multiplicative conversion factor to convert a distance from the specified units to this unit.- Specified by:
from
in interfaceUnitEnum<DistanceUnit>
- Parameters:
other
- another DistanceUnit representing the existing units of a distance value- Returns:
- the conversion factor to change a distance value into this unit
-
getOffset
Get the additive offset to convert a value from the specified unit to this unit.- Specified by:
getOffset
in interfaceUnitEnum<DistanceUnit>
- Parameters:
other
- another DistanceUnit representing the existing units of a value- Returns:
- the offset (after multiplying by the from() factor) to add to get the value in this unit
-
getShortUnit
Get the shorter DistanceUnit associated with this DistanceUnit.- Specified by:
getShortUnit
in interfaceUnitEnumHasShortUnit<DistanceUnit>
- Returns:
- shorter DistanceUnit in same system of measurement
-
getTinyUnit
Get the extremely short DistanceUnit associated with this DistanceUnit.- Returns:
- much shorter DistanceUnit in same system of measurement, or null if no such unit
-
lookupSpeedUnit
Find the DistanceUnit whose speed has the specified unit name.- Parameters:
speedUnit
- String of speed unit, such as "mph", "kph", etc.- Returns:
- DistanceUnit for this speed string, or null if no match
-
getSpeedString
Get the descriptive String for a DistanceUnit when used for velocity as DistanceUnit per hour.- Returns:
- speed unit String
-
getAbbreviation
Get short standard abbreviations for this DistanceUnit.- Returns:
- abbreviations string
-
getUnitForName
Convert a string representing the abbreviations for a DistanceUnit into the enum instance for that unit.- Parameters:
name
- String to be translated into a DistanceUnit- Returns:
- corresponding DistanceUnit, or null if no match found
-
getSpeedUnits
Get an array of all DistanceUnits that can do speeds.- Returns:
- array of DistanceUnits
-
getDepth
public int getDepth()Get depth index for this unit instance's hierarchy of different-sized units.- Specified by:
getDepth
in interfaceUnitEnumHasShortUnit<DistanceUnit>
- Returns:
- zero-based index of how many times you can get a shorter unit before you reach the smallest unit
-