public class DefaultUnitService extends AbstractService implements UnitService
Constructor and Description |
---|
DefaultUnitService() |
Modifier and Type | Method and Description |
---|---|
void |
defineUnit(String unitName,
String baseUnit,
Calibrator calibrator)
Defines a unit conversion that can be referred to via the value() method.
|
void |
defineUnit(String unitName,
String baseUnit,
double scale)
Defines a unit conversion that can be referred to via the value() method.
|
void |
defineUnit(String unitName,
String baseUnit,
double scale,
double offset)
Defines a unit conversion that can be referred to via the value() method.
|
double |
value(double inputValue,
String inputUnit,
String outputUnit)
Returns a value after conversion between two compatible types of units.
|
getContext, setContext, toString
getInfo, getPriority, setInfo, setPriority
context
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
initialize, registerEventHandlers
getIdentifier, log
context, getContext, setContext
compareTo, getPriority, setPriority
getInfo, setInfo
getLocation
getVersion
dispose
public double value(double inputValue, String inputUnit, String outputUnit)
UnitService
value
in interface UnitService
inputValue
- The double representing the number of input units.inputUnit
- The string representing the input unit.outputUnit
- The string representing the output unit.public void defineUnit(String unitName, String baseUnit, double scale)
UnitService
defineUnit
in interface UnitService
unitName
- The name of the unit being defined e.g. "fliggs".baseUnit
- The unit the defined unit is based upon e.g. "m/s^2".scale
- The ratio of defined units to base units e.g. 14.2.public void defineUnit(String unitName, String baseUnit, double scale, double offset)
UnitService
defineUnit
in interface UnitService
unitName
- The name of the unit being defined e.g. "fliggs".baseUnit
- The unit the defined unit is based upon e.g. "m/s^2".scale
- The ratio of defined units to base units e.g. 14.2.offset
- The offset of defined units to base units e.g. 3.3.public void defineUnit(String unitName, String baseUnit, Calibrator calibrator)
UnitService
Calibrator
that handles conversion. The Calibrator allows any kind of conversion
between units including nonlinear ones (i.e. can support log units).defineUnit
in interface UnitService
unitName
- The name of the unit being defined e.g. "fliggs".baseUnit
- The unit the defined unit is based upon e.g. "m/s^2".calibrator
- The Calibrator the maps between the two unit spaces.Copyright © 2014–2022 ImageJ. All rights reserved.