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, toStringgetInfo, getPriority, setInfo, setPrioritycontextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitinitialize, registerEventHandlersgetIdentifier, logcontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationgetVersiondisposepublic double value(double inputValue,
String inputUnit,
String outputUnit)
UnitServicevalue in interface UnitServiceinputValue - 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)
UnitServicedefineUnit in interface UnitServiceunitName - 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)
UnitServicedefineUnit in interface UnitServiceunitName - 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)
UnitServiceCalibrator
that handles conversion. The Calibrator allows any kind of conversion
between units including nonlinear ones (i.e. can support log units).defineUnit in interface UnitServiceunitName - 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.