Package elki.math.scales
Class LinearScale
- java.lang.Object
-
- elki.math.scales.LinearScale
-
public class LinearScale extends java.lang.Object
Class to handle a linear scale for an axis. The computed scales are rounded to be on decimal borders, choosing an appropriate resolution to have between 4 and 31 major tics (3 to 30 intervals). Future versions might use major/minor tics to get even nicer values.- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private double
delta
Scale delta := max - minprivate int
log10res
Scale resolution in log10.private double
max
max value of the scalestatic int
MAXTICKS
Maximum number of steps at which to decrease the resolution.private double
min
min value of the scaleprivate double
res
Scale resolutionprivate double
ZOOMFACTOR
Resulting factor.
-
Constructor Summary
Constructors Constructor Description LinearScale(double min, double max)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
formatValue(double val)
Format value according to the scales resolution (i.e. appropriate number of digits)double
getLog10Res()
Get resolution (scale interval size)double
getMax()
Get maximum value (scale, not data).double
getMin()
Get minimum value (scale, not data).double
getRelativeScaled(double val)
Covert a relative value to it's scale positiondouble
getRelativeScaled(double val, double smax, double smin)
Covert a relative value to it's scale positiondouble
getRelativeUnscaled(double val)
Covert a relative scale position to the actual valuedouble
getRelativeUnscaled(double val, double smin, double smax)
Covert a relative scale position to the actual valuedouble
getRes()
Get resolution (scale interval size)double
getScaled(double val)
Covert a value to it's scale positiondouble
getScaled(double val, double smin, double smax)
Covert a value to it's scale positiondouble
getUnscaled(double val)
Covert a scale position to the actual valuedouble
getUnscaled(double val, double smin, double smax)
Covert a scale position to the actual valuejava.lang.String
toString()
-
-
-
Field Detail
-
MAXTICKS
public static final int MAXTICKS
Maximum number of steps at which to decrease the resolution.- See Also:
- Constant Field Values
-
ZOOMFACTOR
private final double ZOOMFACTOR
Resulting factor.
-
min
private double min
min value of the scale
-
max
private double max
max value of the scale
-
res
private double res
Scale resolution
-
log10res
private int log10res
Scale resolution in log10.
-
delta
private double delta
Scale delta := max - min
-
-
Method Detail
-
getMin
public double getMin()
Get minimum value (scale, not data).- Returns:
- min
-
getMax
public double getMax()
Get maximum value (scale, not data).- Returns:
- max
-
getRes
public double getRes()
Get resolution (scale interval size)- Returns:
- scale interval size
-
getLog10Res
public double getLog10Res()
Get resolution (scale interval size)- Returns:
- scale interval size in logarithmic form
-
getScaled
public double getScaled(double val)
Covert a value to it's scale position- Parameters:
val
- data value- Returns:
- scale position in the interval [0:1]
-
getUnscaled
public double getUnscaled(double val)
Covert a scale position to the actual value- Parameters:
val
- scale position in the interval [0:1]- Returns:
- value on the original scale
-
getRelativeScaled
public double getRelativeScaled(double val)
Covert a relative value to it's scale position- Parameters:
val
- relative data value- Returns:
- relative scale position in the interval [0:1]
-
getRelativeUnscaled
public double getRelativeUnscaled(double val)
Covert a relative scale position to the actual value- Parameters:
val
- relative scale position in the interval [0:1]- Returns:
- relative value on the original scale
-
getScaled
public double getScaled(double val, double smin, double smax)
Covert a value to it's scale position- Parameters:
val
- data valuesmin
- target scale minimumsmax
- target scale maximum- Returns:
- scale position in the interval [smin:smax]
-
getUnscaled
public double getUnscaled(double val, double smin, double smax)
Covert a scale position to the actual value- Parameters:
val
- scale position in the interval [smin:smax]smin
- target scale minimumsmax
- target scale maximum- Returns:
- value on the original scale
-
getRelativeScaled
public double getRelativeScaled(double val, double smax, double smin)
Covert a relative value to it's scale position- Parameters:
val
- relative data valuesmin
- target scale minimumsmax
- target scale maximum- Returns:
- relative scale position in the interval [smin:smax]
-
getRelativeUnscaled
public double getRelativeUnscaled(double val, double smin, double smax)
Covert a relative scale position to the actual value- Parameters:
val
- relative scale position in the interval [smin:smax]smin
- target scale minimumsmax
- target scale maximum- Returns:
- relative value on the original scale
-
formatValue
public java.lang.String formatValue(double val)
Format value according to the scales resolution (i.e. appropriate number of digits)- Parameters:
val
- Value- Returns:
- formatted number
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-