Package org.ka2ddo.yaac.osm
Class Length
java.lang.Object
org.ka2ddo.yaac.osm.Length
- All Implemented Interfaces:
QuantityUnitMeasure<DistanceUnit>
This class defines a compound object containing a length, width, or height value and the unit of length.
- Author:
- Andrew Pavlin, KA2DDO
-
Constructor Summary
ConstructorDescriptionLength
(float length) Create a Length with the specified magnitude in meters.Length
(float length, DistanceUnit unit) Create a Length with the specified magnitude.Decode a Length value from the specified String representation. -
Method Summary
Modifier and TypeMethodDescriptionfloat
Get the magnitude of this length in its unit.float
getMagnitude
(DistanceUnit otherUnit) Get this length in the specified units.float
Get the length in the application-default units (meters).getUnit()
Get the unit in which the length magnitude is measured.toString()
Returns a string representation of the object.
-
Constructor Details
-
Length
Decode a Length value from the specified String representation.- Parameters:
value
- a String representation of a length- Throws:
IllegalArgumentException
- if the string cannot be successfully parsed
-
Length
Create a Length with the specified magnitude.- Parameters:
length
- float length value in the specified unitsunit
- DistanceUnit of the length value
-
Length
public Length(float length) Create a Length with the specified magnitude in meters.- Parameters:
length
- float length value in meters
-
-
Method Details
-
getMagnitude
public float getMagnitude()Get the magnitude of this length in its unit.- Specified by:
getMagnitude
in interfaceQuantityUnitMeasure<DistanceUnit>
- Returns:
- float length value
-
getMagnitude
Get this length in the specified units.- Specified by:
getMagnitude
in interfaceQuantityUnitMeasure<DistanceUnit>
- Parameters:
otherUnit
- DistanceUnit for scaling the length- Returns:
- float length value in the specified units
-
getMagnitudeInDefaultUnit
public float getMagnitudeInDefaultUnit()Get the length in the application-default units (meters).- Specified by:
getMagnitudeInDefaultUnit
in interfaceQuantityUnitMeasure<DistanceUnit>
- Returns:
- float length value in meters
-
getUnit
Get the unit in which the length magnitude is measured.- Specified by:
getUnit
in interfaceQuantityUnitMeasure<DistanceUnit>
- Returns:
- DistanceUnit of length
-
toString
Returns a string representation of the object.
-