Package org.openjdk.jmc.common.unit
Class ScaleFactor
- java.lang.Object
-
- org.openjdk.jmc.common.unit.ScaleFactor
-
- All Implemented Interfaces:
Comparable<ScaleFactor>
,IScalarAffineTransform
- Direct Known Subclasses:
BinaryScaleFactor
,DecimalScaleFactor
,ImpreciseScaleFactor
,LongScaleFactor
public abstract class ScaleFactor extends Object implements IScalarAffineTransform, Comparable<ScaleFactor>
A linear transform, that is, a scale factor.Note: This class has a natural ordering that is inconsistent with
equals
. (This is because in a certain subclass,ImpreciseScaleFactor
, different instances may express the same scale factor with different precision.)
-
-
Constructor Summary
Constructors Constructor Description ScaleFactor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(ScaleFactor other)
IScalarAffineTransform
concat(IScalarAffineTransform innerTransform)
Concatenate this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this transform on the resulting value.abstract ScaleFactor
concat(ScaleFactor innerFactor)
Concatenate (that is, multiply) this scale factor withinnerFactor
.abstract boolean
equals(Object obj)
Number
getOffset()
abstract int
hashCode()
abstract ScaleFactor
invert()
IScalarAffineTransform
invertAndConcat(IScalarAffineTransform innerTransform)
Concatenate the inverse of this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this inverse of this transform on the resulting value.ScaleFactor
invertAndConcat(ScaleFactor innerFactor)
Concatenate (that is, multiply) the inverse of this scale factor withinnerFactor
.double
targetFloor(double srcNumericalValue)
int
targetIntFloor(Number srcNumericalValue)
Number
targetNumber(long srcNumericalValue)
Number
targetNumber(Number srcNumericalValue)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openjdk.jmc.common.unit.IScalarAffineTransform
getMultiplier, isInteger, isUnity, targetFloor, targetOutOfRange, targetOutOfRange, targetValue, targetValue
-
-
-
-
Method Detail
-
concat
public final IScalarAffineTransform concat(IScalarAffineTransform innerTransform)
Description copied from interface:IScalarAffineTransform
Concatenate this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this transform on the resulting value. That is, R(v) = T(I(v)), where R(v) is the resulting transform, T(v) is this transform, and I(v) isinnerTransform
.In this snippet,
v1
andv2
should be equal, apart from numerical precision, for anyv
.IScalarAffineTransform R, T = ..., I = ...; double v = ...; R = T.concat(I); double v1 = R.targetValue(v); double v2 = T.targetValue(I.targetValue(v));
- Specified by:
concat
in interfaceIScalarAffineTransform
- Parameters:
innerTransform
- the transform that should be applied before this transform- Returns:
- the concatenated transform
-
concat
public abstract ScaleFactor concat(ScaleFactor innerFactor)
Concatenate (that is, multiply) this scale factor withinnerFactor
. This is just a special case ofconcat(IScalarAffineTransform)
.- Returns:
- the combined scale factor
- See Also:
concat(IScalarAffineTransform)
-
invertAndConcat
public final IScalarAffineTransform invertAndConcat(IScalarAffineTransform innerTransform)
Description copied from interface:IScalarAffineTransform
Concatenate the inverse of this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this inverse of this transform on the resulting value. That is, R(v) = T-1(I(v)), where R(v) is the resulting transform, T-1(v) is the inverse of this transform, and I(v) isinnerTransform
.In this snippet,
v1
andv2
should be equal, apart from numerical precision, for anyv
.IScalarAffineTransform R, T = ..., I = ...; double v = ...; R = T.invertAndConcat(I); double v1 = R.targetValue(v); double v2 = T.invert().targetValue(I.targetValue(v));
- Specified by:
invertAndConcat
in interfaceIScalarAffineTransform
- Parameters:
innerTransform
- the transform that should be applied before this transform- Returns:
- the concatenated transform
-
invertAndConcat
public ScaleFactor invertAndConcat(ScaleFactor innerFactor)
Concatenate (that is, multiply) the inverse of this scale factor withinnerFactor
. This is just a special case ofinvertAndConcat(IScalarAffineTransform)
.- Returns:
- the combined scale factor
- See Also:
invertAndConcat(IScalarAffineTransform)
-
invert
public abstract ScaleFactor invert()
- Specified by:
invert
in interfaceIScalarAffineTransform
- Returns:
- the inverse transform
-
getOffset
public final Number getOffset()
- Specified by:
getOffset
in interfaceIScalarAffineTransform
- Returns:
- the offset to be added (after the source value has been multiplied with the
multiplier
)
-
targetFloor
public double targetFloor(double srcNumericalValue)
- Specified by:
targetFloor
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- a numerical quantity value, expressed in the source unit- Returns:
- the floor of the corresponding numerical quantity value, when expressed in the target unit
-
targetIntFloor
public int targetIntFloor(Number srcNumericalValue)
- Specified by:
targetIntFloor
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- a numerical quantity value, expressed in the source unit- Returns:
- the floor of the corresponding numerical quantity value, when expressed in the target
unit, clamped to an
int
-
targetNumber
public Number targetNumber(long srcNumericalValue)
- Specified by:
targetNumber
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- an exact numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit, as a
Long
if it can exactly be represented in one, otherwise as some otherNumber
with at least the precision ofdouble
-
targetNumber
public Number targetNumber(Number srcNumericalValue)
- Specified by:
targetNumber
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- an exact or inexact numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit, as a
Long
if it can exactly be represented in one, otherwise as some otherNumber
with at least the precision ofdouble
-
compareTo
public int compareTo(ScaleFactor other)
- Specified by:
compareTo
in interfaceComparable<ScaleFactor>
-
-