|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object visad.Unit visad.BaseUnit
public final class BaseUnit
A class that represents the base units of a system of units. Instances are immutable.
Field Summary |
---|
Fields inherited from class visad.Unit |
---|
hashCode |
Method Summary | |
---|---|
static BaseUnit |
addBaseUnit(String quantityName,
String unitName)
Create a new base unit from the name of a quantity and the name of a unit. |
static BaseUnit |
addBaseUnit(String quantityName,
String unitName,
String abbreviation)
Create a new base unit from from the name of a quantity, the name of a unit, and the unit's abbreviation. |
static BaseUnit |
addBaseUnit(String quantityName,
String unitName,
String abbreviation,
boolean isDimless)
Create a new base unit from from the name of a quantity, the name of a unit, the unit's abbreviation, and whether or not the unit is dimensionless. |
Unit |
divide(Unit that)
Divide this unit by another unit. |
protected Unit |
divideInto(Unit that)
Divide this unit into another unit. |
boolean |
equals(Unit unit)
Indicates whether or not this instance equals a unit. |
String |
getDefinition()
Returns the definition of this unit. |
DerivedUnit |
getDerivedUnit()
Returns the derived unit that underlies this unit. |
int |
hashCode()
Returns the hash code of this instance. |
boolean |
isConvertible(Unit unit)
Indicate whether this unit is convertible with another unit. |
boolean |
isDimensionless()
Indicates if this instance is dimensionless. |
Unit |
log(double base)
Returns the logarithmic unit that has this unit as its reference level. |
static void |
main(String[] args)
Test this class. |
Unit |
multiply(Unit that)
Multiply this unit by another unit. |
Unit |
pow(double power)
Raise a unit to a power. |
Unit |
pow(int power)
Raise a base unit to a power. |
protected Unit |
protectedClone(String identifier)
Clones this unit, changing the identifier. |
String |
quantityName()
Return the name of the quantity associated with this unit. |
static BaseUnit |
quantityNameToUnit(String quantityName)
Find the base unit for the given quantity. |
Unit |
root(int root)
Returns the N-th root of this unit. |
Unit |
scale(double amount)
Scale this unit by an amount. |
Unit |
shift(double offset)
Shift this unit by an amount. |
double[] |
toThat(double[] values,
Unit that)
Convert values from this unit to another unit. |
double[] |
toThat(double[] values,
Unit that,
boolean copy)
Convert values from this unit to another unit. |
float[] |
toThat(float[] values,
Unit that)
Convert values from this unit to another unit. |
float[] |
toThat(float[] values,
Unit that,
boolean copy)
Convert values from this unit to another unit. |
double[] |
toThis(double[] values,
Unit that)
Convert values to this unit from another unit. |
double[] |
toThis(double[] values,
Unit that,
boolean copy)
Convert values to this unit from another unit. |
float[] |
toThis(float[] values,
Unit that)
Convert values to this unit from another unit. |
float[] |
toThis(float[] values,
Unit that,
boolean copy)
Convert values to this unit from another unit. |
String |
unitName()
Return the name of this unit. |
static BaseUnit |
unitNameToUnit(String unitName)
Find the base unit with the given name. |
String |
unitSymbol()
Return the symbol of this unit. |
Methods inherited from class visad.Unit |
---|
adjustCheckAndCache, canConvert, canConvertArray, clone, convertTuple, convertTuple, convertTuple, convertTuple, copyUnitsArray, equals, getAbsoluteUnit, getIdentifier, sqrt, toString, toThat, toThis, transformUnits, transformUnits, transformUnits, transformUnits |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public boolean isDimensionless()
Indicates if this instance is dimensionless. A unit is dimensionless if it is a measure of a dimensionless quantity like angle or concentration. Examples of dimensionless base units include radian, degree, and steradian.
isDimensionless
in class Unit
public Unit scale(double amount) throws UnitException
Unit
scale
in class Unit
amount
- The amount by which to scale this unit. E.g. Unit yard =
meter.scale(0.9144);
UnitException
- This unit cannot be scaled.public Unit shift(double offset) throws UnitException
Unit
shift
in class Unit
offset
- The amount by which to shift this unit. E.g. Unit celsius =
kelvin.shift(273.15);
UnitException
- The unit subclass is unknown.public Unit log(double base)
Unit
log
in class Unit
base
- The logarithmic base: one of 2
, Math.E
, or
10
.
public Unit pow(int power)
pow
in class Unit
power
- The power to raise this unit by.
power
.public Unit pow(double power) throws IllegalArgumentException
pow
in class Unit
power
- The power to raise this unit by. The value must be integral or
reciprocal integral.
power
.
IllegalArgumentException
- power
has a non-integral or non-reciprocal
integral value.public Unit root(int root) throws IllegalArgumentException
root
in class Unit
root
- The root to take (e.g. 2 means square root). May not be zero.
root
-th root of this
unit.
IllegalArgumentException
- The root value is zero or the resulting unit would have a
non-integral unit dimension.public String unitName()
public String unitSymbol()
public String quantityName()
public static BaseUnit addBaseUnit(String quantityName, String unitName) throws UnitException
quantityName
- The name of the associated quantity (e.g. "Length").unitName
- The name for the unit (e.g. "meter").
UnitException
- Name, abbreviation, or quantity name is
null
or attempt to redefine the base unit associated with
quantityName
.public static BaseUnit addBaseUnit(String quantityName, String unitName, String abbreviation) throws UnitException
quantityName
- The name of the associated quantity (e.g. "Length").unitName
- The name for the unit (e.g. "meter").abbreviation
- The abbreviation for the unit (e.g. "m").
UnitException
- Name, abbreviation, or quantity name is
null
or attempt to redefine the base unit associated with
quantityName
.public static BaseUnit addBaseUnit(String quantityName, String unitName, String abbreviation, boolean isDimless) throws UnitException
quantityName
- The name of the associated quantity (e.g. "Length").unitName
- The name for the unit (e.g. "meter").abbreviation
- The abbreviation for the unit (e.g. "m").isDimless
- Whether or not the unit is dimensionless.
UnitException
- Name, abbreviation, or quantity name is
null
or attempt to redefine the base unit associated with
quantityName
.public static BaseUnit unitNameToUnit(String unitName)
unitName
- The name of the unit (e.g. "meter").
null
if no such units exists.public static BaseUnit quantityNameToUnit(String quantityName)
quantityName
- The name of the quantity (e.g. "Length").
null
if no such unit exists.public static void main(String[] args) throws UnitException
args
- Arguments (ignored).
UnitException
- A problem occurred.public double[] toThis(double[] values, Unit that) throws UnitException
toThis
in class Unit
values
- The values to be converted.that
- The unit of values
.
UnitException
- The units are not convertible.public float[] toThis(float[] values, Unit that) throws UnitException
toThis
in class Unit
values
- The values to be converted.that
- The unit of values
.
UnitException
- The units are not convertible.public double[] toThis(double[] values, Unit that, boolean copy) throws UnitException
toThis
in class Unit
values
- The values to be converted.that
- The unit of values
.copy
- if false and that
equals this, return
values
, else return a new array
UnitException
- The units are not convertible.public float[] toThis(float[] values, Unit that, boolean copy) throws UnitException
toThis
in class Unit
values
- The values to be converted.that
- The unit of values
.copy
- if false and that
equals this, return
values
, else return a new array
UnitException
- The units are not convertible.public double[] toThat(double[] values, Unit that) throws UnitException
toThat
in class Unit
values
- The values to be converted in units of this unit.that
- The unit to which to convert the values.
UnitException
- The units are not convertible.public float[] toThat(float[] values, Unit that) throws UnitException
toThat
in class Unit
values
- The values to be converted in units of this unit.that
- The unit to which to convert the values.
UnitException
- The units are not convertible.public double[] toThat(double[] values, Unit that, boolean copy) throws UnitException
toThat
in class Unit
values
- The values to be converted in units of this unit.that
- The unit to which to convert the values.copy
- if false and that
equals this, return
values
, else return a new array
UnitException
- The units are not convertible.public float[] toThat(float[] values, Unit that, boolean copy) throws UnitException
toThat
in class Unit
values
- The values to be converted in units of this unit.that
- The unit to which to convert the values.copy
- if false and that
equals this, return
values
, else return a new array
UnitException
- The units are not convertible.public String getDefinition()
getDefinition
in class Unit
null
but may be empty.protected Unit protectedClone(String identifier) throws UnitException
protectedClone
in class Unit
identifier
- The name or abbreviation for the cloned unit. May be
null
or empty.
UnitException
- Base units may not be cloned. Always thrown.public boolean equals(Unit unit)
equals
in class Unit
unit
- A unit.
true
if and only if this instance is equal to the
unit.public int hashCode()
Object.hashCode()
should
be overridden whenever Object.equals(Object)
is.
hashCode
in class Unit
public Unit multiply(Unit that) throws UnitException
multiply
in class Unit
that
- The unit with which to multiply this unit.
UnitException
- Meaningless operation.public Unit divide(Unit that) throws UnitException
divide
in class Unit
that
- The unit to divide into this unit.
UnitException
- Meaningless operation.protected Unit divideInto(Unit that) throws UnitException
divideInto
in class Unit
that
- The unit to divided this unit.
UnitException
- Meaningless operation.public boolean isConvertible(Unit unit)
toThis(...)
/ and
toThat(...)
methods will not throw a UnitException. Unit A
is convertible with unit B if and only if unit B is convertible with unit
A; hence, calling-order is irrelevant.
isConvertible
in class Unit
unit
- The other unit.
public DerivedUnit getDerivedUnit()
Unit
getDerivedUnit
in class Unit
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |