|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.units.LinearUnitConverter
public class LinearUnitConverter
A linear unit converter is a converter implementation were all units can be converted to another unit using a multiplication factor and/or an offset. The formula used in this converter is:
value(ref) = value(specific) * factor + offset
Field Summary | |
---|---|
private double |
factor
|
private double |
offset
|
Constructor Summary | |
---|---|
LinearUnitConverter(double factor,
double offset)
Create a new unit converter. |
|
LinearUnitConverter(double factor,
double offset,
double referenceFactor,
double referenceOffset)
Create a unit converter that converts between two units that are both related to a third "common" unit by given factors and offsets. |
|
LinearUnitConverter(Unit unit)
Create a new unit converter that converts to/from a given unit. |
|
LinearUnitConverter(Unit specific,
Unit reference)
Create a new unit converter that converts to/from given specific and reference unit. |
Method Summary | |
---|---|
double |
convertToReferenceUnit(double specific)
value(ref) = value(specific) * factor + offset |
double |
convertToSpecificUnit(double ref)
value(specific) = (value(ref) - offset) / factor |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final double factor
private final double offset
Constructor Detail |
---|
public LinearUnitConverter(double factor, double offset)
factor
- The factor to use when converting valuesoffset
- The offset to use when converting valuespublic LinearUnitConverter(double factor, double offset, double referenceFactor, double referenceOffset)
value(ref) * factor(ref) + offset(ref) ==
value(specific) * factor(specfic) + offset(specific)
which is equivalent to :
factor = factor(specific) / factor(ref) offset = (offset(specific) - offset(ref)) / factor(ref)
factor
- The factor of the specific unitoffset
- The offset of the specific unitreferenceFactor
- The factor of the reference unitreferenceOffset
- The offset of the specific unitpublic LinearUnitConverter(Unit unit)
Quantity.getReferenceUnit()
for the given specific
unit's quantity.
unit
- The specific unitpublic LinearUnitConverter(Unit specific, Unit reference)
specific
- The specific unitreference
- The reference unitMethod Detail |
---|
public double convertToReferenceUnit(double specific)
convertToReferenceUnit
in interface UnitConverter
specific
- The value to convert
public double convertToSpecificUnit(double ref)
convertToSpecificUnit
in interface UnitConverter
ref
- The reference value
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |