Package ome.units.unit
Class Unit<Q extends Quantity>
java.lang.Object
ome.units.unit.Unit<Q>
Unit of measurement.
The representation of a unit of measurement. This generic type is
specialised by the dimension type for the unit; for example Length.
A unit of measurement belongs to a measurement system with a
corresponding symbol. Additionally, a scaling factor and offset
provide the means to scale the unit to the base unit for the
measuring system, and hence perform unit conversions.
There is always one measurement system per dimension type, but
additional systems may be added, and these may or may not be
interconvertible. For example, an abstract length representation
such as pixel size would not be convertible to the SI length units
without an explicit conversion with a conversion factor.
- Since:
- 5.1.0
-
Method Summary
Modifier and TypeMethodDescriptionIncrease the scaling offset in this unit by a scalar.Increase the scaling offset in this unit by a scalar.convertValue(Number inValue, Unit<Q> inUnit) Convert a value in this unit to the specified unit.CreateBaseUnit(String inMeasurementSystem, String inSymbol) Create the "base unit" for a given measurement system.Divide the scaling conversion factor in this unit by a scalar.Divide the scaling conversion factor in this unit by a scalar.Get the conversion offset for this unit.Get the conversion scaling factor for this unit.Get the symbol for this unit.isConvertible(Unit<Q> inUnit) Check if this unit is convertible to another unit.Multiply the scaling conversion factor in this unit by a scalar.Multiply the scaling conversion factor in this unit by a scalar.prefixSymbol(String prefix) Add a prefix to the unit symbol in this unit.Change the unit symbol in this unit.
-
Method Details
-
getSymbol
Get the symbol for this unit.- Returns:
- the symbol.
-
getScaleFactor
Get the conversion scaling factor for this unit.- Returns:
- the scaling factor.
-
getOffset
Get the conversion offset for this unit.- Returns:
- the offset.
-
isConvertible
Check if this unit is convertible to another unit.- Parameters:
inUnit- the unit to which to convert.- Returns:
- true if convertible or false if not convertible.
-
convertValue
Convert a value in this unit to the specified unit.- Parameters:
inValue- the value to convert.inUnit- the unit to which to convert.- Returns:
- the converted value
- Throws:
ArithmeticException- if the conversion is not possible.
-
multiply
Multiply the scaling conversion factor in this unit by a scalar.- Parameters:
scalar- the multiplication factor.- Returns:
- a new Unit containing the result of the multiplication.
-
multiply
Multiply the scaling conversion factor in this unit by a scalar.- Parameters:
scalar- the multiplication factor.- Returns:
- a new Unit with the result of the multiplication.
-
divide
Divide the scaling conversion factor in this unit by a scalar.- Parameters:
scalar- the division factor.- Returns:
- a new Unit with the result of the division.
-
divide
Divide the scaling conversion factor in this unit by a scalar.- Parameters:
scalar- the division factor.- Returns:
- a new Unit with the result of the division.
-
add
Increase the scaling offset in this unit by a scalar.- Parameters:
scalar- the value to add.- Returns:
- a new Unit with the result of the addition.
-
add
Increase the scaling offset in this unit by a scalar.- Parameters:
scalar- the value to add.- Returns:
- a new Unit with the result of the addition.
-
setSymbol
Change the unit symbol in this unit.- Parameters:
inSymbol- the new unit symbol.- Returns:
- a new Unit with the result of the unit symbol change.
-
prefixSymbol
Add a prefix to the unit symbol in this unit.- Parameters:
prefix- the unit symbol prefix.- Returns:
- a new Unit with the result of the unit symbol prefix addition.
-
CreateBaseUnit
public static <Q extends Quantity> Unit<Q> CreateBaseUnit(String inMeasurementSystem, String inSymbol) Create the "base unit" for a given measurement system. This is the default or reference unit representing unity for the measurement system. For example, for a unit system representing length, the measurement system and symbol could be "SI.METRE" and "m", respectively.- Parameters:
inMeasurementSystem- the name of the measurement system.inSymbol- the symbol of the base unit.
-