Class pmr.molecule.Unit
All Packages Class Hierarchy This Package Previous Next Index
Class pmr.molecule.Unit
java.lang.Object
|
+----pmr.molecule.Unit
- public class Unit
- extends Object
-
Unit(String, String, UnitDimension)
- this constructor should be used for SI units only
-
Unit(String, String, UnitDimension, double, double)
- make unit including conversion factors
to get to SI: siVal = (val - addToSI) * multiplyToSI;
to get from SI: val = siVal / multiplyToSI + addToSI;
This constructor should be used for NON SI units
-
addSynonym(String)
- add a synonym (might be an abbreviation) for a Unit.
-
convertFromOtherUnit(double, Unit)
-
-
convertFromSI(double)
-
-
convertFromTo(double, String, String)
-
-
convertToSI(double)
-
-
getName()
-
-
getNames(String)
- get the name of all the units of a given type (e.g.
-
getSIUnit(String)
- get the SI unit for a given type
-
getType()
-
-
getUnit(String)
- gets a unit by name (e.g.
-
getUnitDimension()
-
-
getUnits()
- get an array of all the Units
-
main(String[])
-
-
toString()
-
Unit
public Unit(String nam,
String typ,
UnitDimension d) throws DuplicateUnitException
- this constructor should be used for SI units only
- Throws: DuplicateUnitException
- This Unit has already been defined
Unit
public Unit(String nam,
String typ,
UnitDimension d,
double mult,
double add) throws DuplicateUnitException
- make unit including conversion factors
to get to SI: siVal = (val - addToSI) * multiplyToSI;
to get from SI: val = siVal / multiplyToSI + addToSI;
This constructor should be used for NON SI units
- Throws: DuplicateUnitException
- This Unit has already been defined
addSynonym
public void addSynonym(String s) throws DuplicateUnitException
- add a synonym (might be an abbreviation) for a Unit. Name MUST be
unique through the whole unit space. Duplicate throws an exception
- Throws: DuplicateUnitException
- This Unit has already been defined
getUnits
public static Unit[] getUnits()
- get an array of all the Units
getUnit
public static Unit getUnit(String name)
- gets a unit by name (e.g. "Celsius");
getName
public String getName()
getType
public String getType()
getUnitDimension
public UnitDimension getUnitDimension()
getNames
public static StringList getNames(String type)
- get the name of all the units of a given type (e.g. energy)
getSIUnit
public static Unit getSIUnit(String type)
- get the SI unit for a given type
toString
public String toString()
- Overrides:
- toString in class Object
convertToSI
public double convertToSI(double val)
convertFromSI
public double convertFromSI(double val)
convertFromOtherUnit
public double convertFromOtherUnit(double val,
Unit otherUnit) throws IncompatibleUnitException
convertFromTo
public static double convertFromTo(double val,
String fromUnit,
String toUnit) throws IncompatibleUnitException
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index