Package uk.ac.starlink.ttools.plot2
Class Scaling
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.Scaling
-
@Equality public abstract class Scaling extends java.lang.Object
Defines a policy for scaling values to a fixed interval.- Since:
- 22 Jan 2015
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Scaling(java.lang.String name, java.lang.String description, boolean isLogLike)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Scaling
createAsinhScaling(java.lang.String name, double delta)
Constructs an asinh-based scaling.static Scaler
createRangeScaler(Scaling scaling, Range range)
Utility method to return a scaler based on a Range object.abstract Scaler
createScaler(double lo, double hi)
Returns a scaler instance that can scale input values in a given range.java.lang.String
getDescription()
Returns a short description of this scaling.java.lang.String
getName()
Returns the name of this scaling.static Scaling[]
getStretchOptions()
Returns a list of standard options for colour map stretch.boolean
isLogLike()
Indicates whether this scaling is logarithmic.static Scaling
subrangeScaling(Scaling scaling, Subrange subrange)
Adjusts a scaling by applying a fractional subrange to the scaler inputs before scaling is applied, so that the input range is subranged, rather than the output range.java.lang.String
toString()
-
-
-
Field Detail
-
LINEAR
public static final Scaling LINEAR
Linear scaling.
-
LOG
public static final Scaling LOG
Logarithmic scaling.
-
SQRT
public static final Scaling SQRT
Square root scaling.
-
SQUARE
public static final Scaling SQUARE
Square scaling.
-
AUTO
public static final Scaling AUTO
Asinh-based scaling with default parameters.
-
-
Constructor Detail
-
Scaling
protected Scaling(java.lang.String name, java.lang.String description, boolean isLogLike)
Constructor.- Parameters:
name
- scaling namedescription
- short description of scaling ruleisLogLike
- whether the scaling is logarithmic, for instance should be displayed on a log axis
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of this scaling.- Returns:
- name
-
getDescription
public java.lang.String getDescription()
Returns a short description of this scaling.- Returns:
- short text description
-
isLogLike
public boolean isLogLike()
Indicates whether this scaling is logarithmic. If so, it should be displayed on logarithmic axis, and can't cope with negative values.- Returns:
- true for basically logarithmic, false of (perhaps distorted) linear
-
createScaler
public abstract Scaler createScaler(double lo, double hi)
Returns a scaler instance that can scale input values in a given range. The given bounds define the range of input values that will be mapped to the fixed (0..1) output range. Input values outside that range will in general result in clipping, so for the returned scalers
:s.scaleValue(x) == s.scaleValue(lo) for x<lo s.scaleValue(x) == s.scaleValue(hi) for x>hi
- Parameters:
lo
- lower bound of unclipped input data valuehi
- upper bound of unclipped input data value- Returns:
- instance
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getStretchOptions
public static final Scaling[] getStretchOptions()
Returns a list of standard options for colour map stretch.- Returns:
- standard stretch options
-
subrangeScaling
public static Scaling subrangeScaling(Scaling scaling, Subrange subrange)
Adjusts a scaling by applying a fractional subrange to the scaler inputs before scaling is applied, so that the input range is subranged, rather than the output range. For linear scaling the two things would be the same, but not in general.- Parameters:
scaling
- base scalingsubrange
- fractional subrange to apply to input values- Returns:
- subranged scaling
-
createRangeScaler
public static Scaler createRangeScaler(Scaling scaling, Range range)
Utility method to return a scaler based on a Range object.- Parameters:
scaling
- scalingrange
- value range- Returns:
- scaler
-
createAsinhScaling
public static Scaling createAsinhScaling(java.lang.String name, double delta)
Constructs an asinh-based scaling.- Parameters:
name
- scaling namedelta
- output difference for lower-end input unit difference- Returns:
- scaling
-
-