visad
Class PromiscuousUnit
- java.lang.Object
-
- visad.Unit
-
- visad.PromiscuousUnit
-
- All Implemented Interfaces:
- java.io.Serializable
public final class PromiscuousUnit extends Unit
PromiscuousUnit is the VisAD class for units that are convertable with any other Unit. Instances are immutable.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Unitdivide(PromiscuousUnit that)Unitdivide(Unit that)Divide this unit by another unit.booleanequals(Unit unit)Indicates whether or not this instance is equal to a unit.java.lang.StringgetDefinition()Returns the definition of this unit.DerivedUnitgetDerivedUnit()Returns the dimensionless unit one with the identifier "1".inthashCode()Returns the hash code of this instance.booleanisConvertible(Unit unit)Indicate whether this unit is convertible with another unit.booleanisDimensionless()Indicates if this instance is dimensionless.Unitlog(double base)Returns the logarithmic unit that has this unit as its reference level.Unitmultiply(Unit that)Multiply this unit by another unit.Unitpow(double power)Raise a unit to a power.Unitpow(int power)Raise this unit to a power.Unitroot(int root)Returns the N-th root of this unit.Unitscale(double amount)Scale this unit by an amount.Unitshift(double offset)Shift this unit by an amount.double[]toThat(double[] values, Unit that)Convert values from this unit to another unit.float[]toThat(float[] values, Unit that)Convert values from this unit to another unit.double[]toThis(double[] values, Unit that)Convert values to this unit from another unit.float[]toThis(float[] values, Unit that)Convert values to this unit from another unit.-
Methods inherited from class visad.Unit
canConvert, canConvertArray, clone, convertTuple, convertTuple, convertTuple, convertTuple, copyUnitsArray, equals, getAbsoluteUnit, getIdentifier, main, sqrt, toString, toThat, toThat, toThat, toThis, toThis, toThis, transformUnits, transformUnits, transformUnits, transformUnits
-
-
-
-
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".
This implementation always returns
falsebecause the typical use of this method is to determine whether or not a function of dimensionless values (e.g. sin(), log()) may be applied to values in this unit and such functions shouldn't be applied to values in this unit. Instead, the client should ensure that the values are in a true, dimensionless unit.- Specified by:
isDimensionlessin classUnit- Returns:
- True if an only if this unit is dimensionless.
-
getDefinition
public java.lang.String getDefinition()
Returns the definition of this unit. For promiscuous units, this is the same as the identifier.- Specified by:
getDefinitionin classUnit- Returns:
- The definition of this unit. Won't be
nullbut may be empty.
-
scale
public Unit scale(double amount) throws UnitException
Description copied from class:UnitScale this unit by an amount.- Specified by:
scalein classUnit- Parameters:
amount- The amount by which to scale this unit. E.g. Unit yard = meter.scale(0.9144);- Returns:
- A unit equal to this instance scaled by the given amount.
- Throws:
UnitException- This unit cannot be scaled.
-
shift
public Unit shift(double offset) throws UnitException
Description copied from class:UnitShift this unit by an amount.- Specified by:
shiftin classUnit- Parameters:
offset- The amount by which to shift this unit. E.g. Unit celsius = kelvin.shift(273.15);- Returns:
- A unit equal to this instance with the origin shifted by the given amount.
- Throws:
UnitException- The unit subclass is unknown.
-
log
public Unit log(double base)
Description copied from class:UnitReturns the logarithmic unit that has this unit as its reference level. Not all units can be used as a reference level.
-
root
public Unit root(int root)
Description copied from class:UnitReturns the N-th root of this unit.
-
multiply
public Unit multiply(Unit that)
Description copied from class:UnitMultiply this unit by another unit.
-
divide
public Unit divide(Unit that) throws UnitException
Description copied from class:UnitDivide this unit by another unit.- Specified by:
dividein classUnit- Parameters:
that- The unit to divide into this unit.- Returns:
- The quotient of the two units. promise: Neither unit has been modified.
- Throws:
UnitException- It's meaningless to divide these units.
-
divide
public Unit divide(PromiscuousUnit that)
-
toThis
public double[] toThis(double[] values, Unit that)Description copied from class:UnitConvert values to this unit from another unit.
-
toThat
public double[] toThat(double[] values, Unit that)Description copied from class:UnitConvert values from this unit to another unit.
-
toThis
public float[] toThis(float[] values, Unit that)Description copied from class:UnitConvert values to this unit from another unit.
-
toThat
public float[] toThat(float[] values, Unit that)Description copied from class:UnitConvert values from this unit to another unit.
-
isConvertible
public boolean isConvertible(Unit unit)
Indicate whether this unit is convertible with another unit. A PromiscuousUnit is always convertible with another unit.- Specified by:
isConvertiblein classUnit- Parameters:
unit- The other unit.- Returns:
- True, always.
-
equals
public boolean equals(Unit unit)
Description copied from class:UnitIndicates whether or not this instance is equal to a unit.
-
hashCode
public int hashCode()
Returns the hash code of this instance.Object.hashCode()should be overridden wheneverObject.equals(Object)is.
-
getDerivedUnit
public DerivedUnit getDerivedUnit()
Returns the dimensionless unit one with the identifier "1".- Specified by:
getDerivedUnitin classUnit- Returns:
- The derived unit that underlies this unit.
-
-
DMelt 3.0 © DataMelt by jWork.ORG