Class BinSizer
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.layer.BinSizer
-
@Equality public abstract class BinSizer extends java.lang.Object
Determines 1-d histogram bin widths from data bounds.- Since:
- 8 Jan 2014
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BinSizer.BinSizerSpecifier
Specifier for BinSizer values.
-
Constructor Summary
Constructors Constructor Description BinSizer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static BinSizer
createCountBinSizer(double nbin)
Returns a bin sizer instance which divides the axis range up into an approximately fixed number of equal intervals.static BinSizer
createFixedBinSizer(double binWidth)
Returns a bin sizer instance which always returns the same fixed value.static ConfigKey<BinSizer>
createSizerConfigKey(ConfigMeta meta, ReportKey<java.lang.Double> widthReportKey, int dfltNbin, boolean allowZero)
Constructs a config key for acquiring BinSizers.static java.lang.String
getConfigKeyDescription()
Returns an XML string describing in general terms how to operate the BinSizer config key.abstract double
getWidth(boolean xlog, double xlo, double xhi, Rounding rounding)
Provides a bin width value for a given axis data range.
-
-
-
Method Detail
-
getWidth
public abstract double getWidth(boolean xlog, double xlo, double xhi, Rounding rounding)
Provides a bin width value for a given axis data range.- Parameters:
xlog
- false for linear scaling, true for logarithmicxlo
- axis lower boundxhi
- axis upper boundrounding
- rounding policy hint (may be ignored) or null for no rounding- Returns:
- additive/multiplicative bin width appropriate for the given range
-
createFixedBinSizer
public static BinSizer createFixedBinSizer(double binWidth)
Returns a bin sizer instance which always returns the same fixed value. No rounding is performed.- Parameters:
binWidth
- fixed bin width- Returns:
- bin sizer
-
createCountBinSizer
public static BinSizer createCountBinSizer(double nbin)
Returns a bin sizer instance which divides the axis range up into an approximately fixed number of equal intervals. Rounding is performed on request, so that bin sizes are sensible values that give a bin count near the requested value.- Parameters:
nbin
- number of intervals to divide the axis into- Returns:
- bin sizer instance
-
createSizerConfigKey
public static ConfigKey<BinSizer> createSizerConfigKey(ConfigMeta meta, ReportKey<java.lang.Double> widthReportKey, int dfltNbin, boolean allowZero)
Constructs a config key for acquiring BinSizers.- Parameters:
meta
- key metadatawidthReportKey
- report key giving bin width in data coordinatesdfltNbin
- default bin countallowZero
- true iff zero is an allowed width- Returns:
- new config key
-
getConfigKeyDescription
public static java.lang.String getConfigKeyDescription()
Returns an XML string describing in general terms how to operate the BinSizer config key.- Returns:
- XML <p> element(s)
-
-