public class U extends Object
Class and methods primarily for defining, calculating and converting between units of basic and compounded quantities.
Some additional functionality exists for doing absolute conversion between scales, as well as units such as months and years. Those do however have limited functionality. This code should not be used to implement calendar systems.
Modifier and Type | Field | Description |
---|---|---|
static U |
BARREL |
|
static U |
CC |
|
static U |
CM |
|
static U |
CUP |
|
static U |
DAY |
|
static U |
DEGREE |
|
static U |
DM |
|
static U |
FLOZ |
|
static U |
FOOT |
|
static U |
G |
|
static U |
GALLON |
|
static U |
H |
|
static U |
INCH |
|
static U |
KELVIN |
|
static U |
KG |
|
static U |
KM |
|
static U |
L |
|
static U |
LIGHTYEAR |
|
static U |
M |
|
static U |
MILE |
|
static U |
MIN |
|
static U |
ML |
|
static U |
MM |
|
static U |
MONTH |
|
static U |
MS |
|
static U |
N |
|
static U |
NONE |
|
static U |
OUNCE |
|
static U |
PINT |
|
static U |
POUND |
|
static U |
RADIAN |
|
static U |
S |
|
static U |
SC |
|
static U |
SCM |
|
static U |
TABLESPOON |
|
static U |
TEASPOON |
|
static U |
TON |
|
static U |
TON_UK |
|
static U |
TON_US |
|
static U |
WEEK |
|
static U |
YARD |
|
static U |
YEAR |
Constructor | Description |
---|---|
U(U u,
double compoundLength,
String shortName,
String longName) |
Defines a new Unit based on another.
|
U(String shortName,
String longName,
Quantity quantity) |
Creates a new Unit from scratch.
|
Modifier and Type | Method | Description |
---|---|---|
U |
dimDiff(U b) |
Calculates and the Unit that is the dimensional difference between this Unit and another.
|
static U |
dimDiff(U a,
U b) |
Calculates and the Unit that is the dimensional difference between Unit A and Unit B.
|
U |
div(U a) |
Divide this unit with another unit.
|
boolean |
equals(Object obj) |
|
static U |
getBestUnit(UV uv,
double target) |
Calculates and returns the most suitable unit to display a given UV in.
|
String |
getDerivedName() |
Returns the derived name for this unit.
|
U |
inverse() |
Calculate the inverse of this unit.
|
boolean |
isSameQuantity(U b) |
Checks whether or not this unit and unit b has the same total quantity.
|
U |
mul(U a) |
Multiply this Unit with another Unit.
|
U |
pow(double p) |
Perform repeated multiplication of this unit with itself.
|
U |
reduce() |
Checks the unit for multiple instances of the same quantity and combines them.
|
String |
toString() |
public static final U NONE
public static final U M
public static final U MM
public static final U CM
public static final U DM
public static final U KM
public static final U INCH
public static final U FOOT
public static final U YARD
public static final U MILE
public static final U LIGHTYEAR
public static final U L
public static final U ML
public static final U TEASPOON
public static final U TABLESPOON
public static final U FLOZ
public static final U CUP
public static final U PINT
public static final U GALLON
public static final U BARREL
public static final U G
public static final U KG
public static final U TON
public static final U OUNCE
public static final U POUND
public static final U TON_UK
public static final U TON_US
public static final U S
public static final U MS
public static final U MIN
public static final U H
public static final U DAY
public static final U WEEK
public static final U YEAR
public static final U MONTH
public static final U RADIAN
public static final U DEGREE
public static final U KELVIN
public static final U N
public static final U CC
public static final U SC
public static final U SCM
public U(String shortName, String longName, Quantity quantity)
U(U, double, String, String)
instead.}shortName
- the short name or abbreviation for this unit. For the SI-unit meter this would be "m".longName
- the long name for this unit. For the SI-unit meter this would be "meter".quantity
- the quantity that this unit will represent.public U(U u, double compoundLength, String shortName, String longName)
u
- the Unit this unit will have the same quantity as.compoundLength
- the length of this unit compared to the other Unit. For the SI-unit millimeter this would be 0.001 if the other Unit was meter.shortName
- the short name or abbreviation for this unit. For the SI-unit meter this would be "m".longName
- the long name for this unit. For the SI-unit meter this would be "meter".public U mul(U a)
a
- the Unit to multiply with.public U div(U a)
a
- the unit to divide with.public U pow(double p)
p
- The exponent. 0: result is NONE. 1: Result is itself. >1: Power. <0: Result is inverted and given power.public U inverse()
public U reduce()
public U dimDiff(U b)
b
- the target Unit.public static U dimDiff(U a, U b)
a
- the unit that can be multiplied with returned value to get B.b
- the other unit.public boolean isSameQuantity(U b)
b
- the unit to check against.public static U getBestUnit(UV uv, double target)
uv
- the source unit vector you want the best unit fortarget
- the target value of the numeric part.public String getDerivedName()
Copyright © 2018. All rights reserved.