Package org.openjdk.jmc.common.unit
Class ImpreciseScaleFactor
- java.lang.Object
-
- org.openjdk.jmc.common.unit.ScaleFactor
-
- org.openjdk.jmc.common.unit.ImpreciseScaleFactor
-
- All Implemented Interfaces:
Comparable<ScaleFactor>,IScalarAffineTransform
public class ImpreciseScaleFactor extends ScaleFactor
Quick and dirtyScaleFactorimplementation. Should be replaced with more precise (rational) converters.
-
-
Constructor Summary
Constructors Constructor Description ImpreciseScaleFactor(Number factor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScaleFactorconcat(ScaleFactor innerFactor)Concatenate (that is, multiply) this scale factor withinnerFactor.booleanequals(Object other)doublegetMultiplier()inthashCode()ScaleFactorinvert()booleanisInteger()booleanisUnity()longtargetFloor(long srcNumericalValue)NumbertargetNumber(long srcNumericalValue)NumbertargetNumber(Number srcNumericalValue)booleantargetOutOfRange(double srcNumericalValue, long maxAbsValue)booleantargetOutOfRange(long srcNumericalValue, long maxAbsValue)doubletargetValue(double srcNumericalValue)longtargetValue(long srcNumericalValue)StringtoString()-
Methods inherited from class org.openjdk.jmc.common.unit.ScaleFactor
compareTo, concat, getOffset, invertAndConcat, invertAndConcat, targetFloor, targetIntFloor
-
-
-
-
Constructor Detail
-
ImpreciseScaleFactor
public ImpreciseScaleFactor(Number factor)
-
-
Method Detail
-
concat
public ScaleFactor concat(ScaleFactor innerFactor)
Description copied from class:ScaleFactorConcatenate (that is, multiply) this scale factor withinnerFactor. This is just a special case ofScaleFactor.concat(IScalarAffineTransform).- Specified by:
concatin classScaleFactor- Returns:
- the combined scale factor
- See Also:
ScaleFactor.concat(IScalarAffineTransform)
-
invert
public ScaleFactor invert()
- Specified by:
invertin interfaceIScalarAffineTransform- Specified by:
invertin classScaleFactor- Returns:
- the inverse transform
-
targetOutOfRange
public boolean targetOutOfRange(long srcNumericalValue, long maxAbsValue)
-
targetOutOfRange
public boolean targetOutOfRange(double srcNumericalValue, long maxAbsValue)
-
targetValue
public double targetValue(double srcNumericalValue)
- Parameters:
srcNumericalValue- a numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit
-
targetValue
public long targetValue(long srcNumericalValue)
- Parameters:
srcNumericalValue- a numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit,
rounded to the closest integer that can be represented by a
long
-
targetFloor
public long targetFloor(long srcNumericalValue)
- 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 a
long
-
targetNumber
public Number targetNumber(long srcNumericalValue)
- Specified by:
targetNumberin interfaceIScalarAffineTransform- Overrides:
targetNumberin classScaleFactor- 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
Longif it can exactly be represented in one, otherwise as some otherNumberwith at least the precision ofdouble
-
targetNumber
public Number targetNumber(Number srcNumericalValue)
- Specified by:
targetNumberin interfaceIScalarAffineTransform- Overrides:
targetNumberin classScaleFactor- 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
Longif it can exactly be represented in one, otherwise as some otherNumberwith at least the precision ofdouble
-
isUnity
public boolean isUnity()
- Returns:
- true iff this represents the identity transform
-
isInteger
public boolean isInteger()
- Returns:
- true iff this transform can exactly be described by an integer multiplier followed by an integer offset
-
equals
public boolean equals(Object other)
- Specified by:
equalsin classScaleFactor
-
hashCode
public int hashCode()
- Specified by:
hashCodein classScaleFactor
-
getMultiplier
public double getMultiplier()
- Returns:
- the multiplier which source values should be multiplied with (before the
offsetis added)
-
-