## visad
Class OffsetUnit

    java.lang.Object
      visad.Unit
          visad.OffsetUnit

All Implemented Interfaces:
  Serializable

public final class OffsetUnit
extends Unit
implements Serializable

A class that represents a scaled unit with an offset.

See Also:
  Serialized Form

Field Summary
`(package private) double` `offset` The offset for this unit (e.g.
`(package private) ScaledUnit` `scaledUnit` The associated (unoffset) scaled unit.

Fields inherited from class visad.Unit
`hashCode, hashCodeSet`

Constructor Summary
`OffsetUnit(double offset)` Construct an offset, dimensionless unit.
`OffsetUnit(double offset, BaseUnit that)` Construct an offset unit from a base unit.
`OffsetUnit(double offset, BaseUnit that, String identifier)` Construct an offset unit from a base unit and an identifier.
`OffsetUnit(double offset, DerivedUnit that)` Construct an offset unit from a derived unit.
`OffsetUnit(double offset, DerivedUnit that, String identifier)` Construct an offset unit from a derived unit and an identifier.
`OffsetUnit(double offset, OffsetUnit that)` Construct an offset unit from an offset unit.
`OffsetUnit(double offset, OffsetUnit that, String identifier)` Construct an offset unit from an offset unit and an identifier..
`OffsetUnit(double offset, ScaledUnit that)` Construct an offset unit from a scaled unit.
`OffsetUnit(double offset, ScaledUnit that, String identifier)` Construct an offset unit from a scaled unit and an identifier.
`OffsetUnit(double offset, String identifier)` Construct an offset, dimensionless unit with an identifier.

Method Summary
`Unit` `divide(Unit that)` Divide an offset unit by another unit.
`protected Unit` `divideInto(Unit that)` Divide an offset unit into another unit.
`boolean` `equals(Unit unit)` Indicates if this instance equals a unit.
`Unit` `getAbsoluteUnit()` Gets the absolute unit of this unit.
`String` `getDefinition()` Return the definition of 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.
`protected boolean` `isTime()` Indicates if this instance is a unit of time.
`static void` `main(String[] args)` Test this class.
`Unit` `multiply(Unit that)` Multiply an offset unit by another unit.
`Unit` `pow(double power)` Raises an offset unit to a power.
`Unit` `pow(int power)` Raises an offset unit to a power.
`protected Unit` `protectedClone(String identifier)` Clones this unit, changing the identifier.
`Unit` `root(int root)` Returns the N-th root of this unit.
`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.

Methods inherited from class visad.Unit
`adjustCheckAndCache, canConvert, canConvertArray, clone, convertTuple, convertTuple, convertTuple, convertTuple, copyUnitsArray, equals, getIdentifier, scale, scale, shift, sqrt, toString, toThat, toThis, transformUnits, transformUnits, transformUnits, transformUnits`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### scaledUnit

    final ScaledUnit scaledUnit

  The associated (unoffset) scaled unit.

### offset

    final double offset

  The offset for this unit (e.g. 273.15 for the celsius unit when the kelvin unit is associated scaled unit).

Constructor Detail

### OffsetUnit

    public OffsetUnit(double offset)

  Construct an offset, dimensionless unit. The identifier will be empty.

Parameters:
  `offset` - The amount of offset.

### OffsetUnit

    public OffsetUnit(double offset,
                      String identifier)

  Construct an offset, dimensionless unit with an identifier.

Parameters:
  `offset` - The amount of offset.
  `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.

### OffsetUnit

    public OffsetUnit(double offset,
                      BaseUnit that)

  Construct an offset unit from a base unit. The identifier will be that of the base unit if the offset is zero; otherwise, the identifier will be `null`.

Parameters:
  `offset` - The amount of offset.
  `that` - The base unit.

### OffsetUnit

    public OffsetUnit(double offset,
                      BaseUnit that,
                      String identifier)

  Construct an offset unit from a base unit and an identifier.

Parameters:
  `offset` - The amount of offset.
  `that` - The base unit.
  `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.

### OffsetUnit

    public OffsetUnit(double offset,
                      DerivedUnit that)

  Construct an offset unit from a derived unit. The identifier will be that of the derived unit if the offset is 0; otherwise; the identifier will be `null`.

Parameters:
  `offset` - The amount of offset.
  `that` - The derived unit.

### OffsetUnit

    public OffsetUnit(double offset,
                      DerivedUnit that,
                      String identifier)

  Construct an offset unit from a derived unit and an identifier.

Parameters:
  `offset` - The amount of offset.
  `that` - The derived unit.
  `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.

### OffsetUnit

    public OffsetUnit(double offset,
                      ScaledUnit that)

  Construct an offset unit from a scaled unit. The identifier will be that of the scaled unit if the offset is 0; otherwise; the identifier will be `null`.

Parameters:
  `offset` - The amount of offset.
  `that` - The scaled unit.

### OffsetUnit

    public OffsetUnit(double offset,
                      ScaledUnit that,
                      String identifier)

  Construct an offset unit from a scaled unit and an identifier.

Parameters:
  `offset` - The amount of offset.
  `that` - The scaled unit.
  `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.

### OffsetUnit

    public OffsetUnit(double offset,
                      OffsetUnit that)

  Construct an offset unit from an offset unit. The identifier will be that of the offset unit if the offset is 0; otherwise; the identifier will be `null`.

Parameters:
  `offset` - The amount of offset.
  `that` - The given unit.

### OffsetUnit

    public OffsetUnit(double offset,
                      OffsetUnit that,
                      String identifier)

  Construct an offset unit from an offset unit and an identifier..

Parameters:
  `offset` - The amount of offset.
  `that` - The given unit.
  `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.

Method Detail

### isDimensionless

    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 units include radian, degree, steradian, and "g/kg".

  Specified by:
    `isDimensionless` in class `Unit`
  Returns:
    True if an only if this unit is dimensionless.

### isTime

    protected boolean isTime()

  Indicates if this instance is a unit of time.

  Returns:
    `true` if and only if this instance is a unit of time.

### protectedClone

    protected Unit protectedClone(String identifier)

  Clones this unit, changing the identifier.

  Specified by:
    `protectedClone` in class `Unit`
  Parameters:
    `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.
  Returns:
    A unit equal to this unit but with the given identifier.

### pow

    public Unit pow(int power)

  Raises an offset unit to a power. Raising an offset unit to a power is equivalent to first stripping-off the offset amount and then raising the resulting non-offset unit to the power.

  Specified by:
    `pow` in class `Unit`
  Parameters:
    `power` - The power to raise this unit by.
  Returns:
    A corresponding unit.

### root

    public Unit root(int root)
              throws IllegalArgumentException

  Returns the N-th root of this unit. Taking the root of an offset unit is equivalent to first stripping-off the offset amount and then taking the root of the resulting non-offset unit.

  Specified by:
    `root` in class `Unit`
  Parameters:
    `root` - The root to take (e.g. 2 means square root). May not be zero.
  Returns:
    The unit corresponding to the `root`-th root of this unit.
  Throws:
    `IllegalArgumentException` - The root value is zero or the resulting unit would have a non-integral unit dimension.

### pow

    public Unit pow(double power)

  Raises an offset unit to a power. Raising an offset unit to a power is equivalent to first stripping-off the offset amount and then raising the resulting non-offset unit to the power.

  Specified by:
    `pow` in class `Unit`
  Parameters:
    `power` - The power to raise this unit by.
  Returns:
    A corresponding unit.

### getDefinition

    public String getDefinition()

  Return the definition of this unit.

  Specified by:
    `getDefinition` in class `Unit`
  Returns:
    The definition of this unit (e.g. "K @ 273.15" for degree celsius).

### multiply

    public Unit multiply(Unit that)
                  throws UnitException

  Multiply an offset unit by another unit.

  Specified by:
    `multiply` in class `Unit`
  Parameters:
    `that` - The unit with which to multiply this unit.
  Returns:
    A unit equal to this instance multiplied by the given unit.
  Throws:
    `UnitException` - Can't multiply units.

### divide

    public Unit divide(Unit that)
                throws UnitException

  Divide an offset unit by another unit.

  Specified by:
    `divide` in class `Unit`
  Parameters:
    `that` - The unit to divide into this unit.
  Returns:
    A unit equal to this instance divided by the given unit.
  Throws:
    `UnitException` - Can't divide units.

### divideInto

    protected Unit divideInto(Unit that)
                       throws UnitException

  Divide an offset unit into another unit.

  Specified by:
    `divideInto` in class `Unit`
  Parameters:
    `that` - The unit to be divide by this unit.
  Returns:
    The quotient of the two units.
  Throws:
    `UnitException` - Meaningless operation.

### toThis

    public double[] toThis(double[] values,
                           Unit that)
                    throws UnitException

  Convert values to this unit from another unit.

  Specified by:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public float[] toThis(float[] values,
                          Unit that)
                   throws UnitException

  Convert values to this unit from another unit.

  Specified by:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public double[] toThis(double[] values,
                           Unit that,
                           boolean copy)
                    throws UnitException

  Convert values to this unit from another unit.

  Overrides:
    `toThis` in class `Unit`
  Parameters:
    `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
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public float[] toThis(float[] values,
                          Unit that,
                          boolean copy)
                   throws UnitException

  Convert values to this unit from another unit.

  Overrides:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false, convert values in place.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public double[] toThat(double[] values,
                           Unit that)
                    throws UnitException

  Convert values from this unit to another unit.

  Specified by:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public float[] toThat(float[] values,
                          Unit that)
                   throws UnitException

  Convert values from this unit to another unit.

  Specified by:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public double[] toThat(double[] values,
                           Unit that,
                           boolean copy)
                    throws UnitException

  Convert values from this unit to another unit.

  Overrides:
    `toThat` in class `Unit`
  Parameters:
    `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 a `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public float[] toThat(float[] values,
                          Unit that,
                          boolean copy)
                   throws UnitException

  Convert values from this unit to another unit.

  Overrides:
    `toThat` in class `Unit`
  Parameters:
    `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 a `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### getAbsoluteUnit

    public Unit getAbsoluteUnit()

  Gets the absolute unit of this unit. An interval in the underlying physical quantity has the same numeric value in an absolute unit of a unit as in the unit itself -- but an absolute unit is always referenced to the physical origin of the underlying physical quantity. For example, the absolute unit corresponding to degrees celsius is degrees kelvin -- and calling this method on a degrees celsius unit obtains a degrees kelvin unit.

  Overrides:
    `getAbsoluteUnit` in class `Unit`
  Returns:
    The absolute unit corresponding to this unit.

### isConvertible

    public boolean isConvertible(Unit unit)

  Indicate whether this unit is convertible with another unit. If one unit is convertible with another, then the `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.

  Specified by:
    `isConvertible` in class `Unit`
  Parameters:
    `unit` - The other unit.
  Returns:
    True if and only if this unit is convertible with the other unit.

### main

    public static void main(String[] args)
                     throws UnitException

  Test this class.

  Parameters:
    `args` - Arguments (ignored).
  Throws:
    `UnitException` - A problem occurred.

### equals

    public boolean equals(Unit unit)

  Indicates if this instance equals a unit.

  Specified by:
    `equals` in class `Unit`
  Parameters:
    `unit` - The unit.
  Returns:
    `true` if and only if this instance equals the unit.

### hashCode

    public int hashCode()

  Returns the hash code of this instance. `Object.hashCode()` should be overridden whenever `Object.equals(Object)` is.

  Specified by:
    `hashCode` in class `Unit`
  Returns:
    The hash code of this instance (includes the values).