Class AbstractKernelDensityPlotter
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.layer.Pixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>
-
- uk.ac.starlink.ttools.plot2.layer.AbstractKernelDensityPlotter
-
- All Implemented Interfaces:
Plotter<AbstractKernelDensityPlotter.KDenseStyle>
- Direct Known Subclasses:
FixedKernelDensityPlotter,KnnKernelDensityPlotter
public abstract class AbstractKernelDensityPlotter extends Pixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>
Abstract superclass for a plotter that plots something that looks like a kernel density estimate. In fact, for reasons of efficiency and implementation, it's a histogram with pixel-sized bins, but it looks pretty much the same.Concrete subclasses have to arrange for the details of exactly how kernels are instantiated from a given kernel shape.
- Since:
- 17 Feb 2015
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractKernelDensityPlotter.KDenseStyleStyle subclass for kernel density plots.static interfaceAbstractKernelDensityPlotter.KernelFigureEncapsulates the details of smoothing kernel construction.-
Nested classes/interfaces inherited from class uk.ac.starlink.ttools.plot2.layer.Pixel1dPlotter
Pixel1dPlotter.BinArray, Pixel1dPlotter.Pixel1dPlan
-
-
Field Summary
Fields Modifier and Type Field Description static ReportKey<double[]>BINS_KEYReport key for plotted bin height in data coordinates.static ConfigKey<Normalisation>NORMALISE_KEYConfig key for normalisation.static ConfigKey<java.lang.Integer>THICK_KEYConfig key for line thickness (only effective if fill==false).-
Fields inherited from class uk.ac.starlink.ttools.plot2.layer.Pixel1dPlotter
KERNEL_KEY, SMOOTHSIZER_KEY, SMOOTHWIDTH_KEY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractKernelDensityPlotter(FloatingCoord xCoord, boolean hasWeight, PerUnitConfigKey<Unit> unitKey, java.lang.String name, javax.swing.Icon icon)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract AbstractKernelDensityPlotter.KernelFigurecreateKernelFigure(ConfigMap config)Constructs an object for plot-time kernel construction based on a particular config map.AbstractKernelDensityPlotter.KDenseStylecreateStyle(ConfigMap config)Creates a style that can be used when creating a plot layer.protected voidextendPixel1dCoordinateRanges(Range[] ranges, boolean[] logFlags, AbstractKernelDensityPlotter.KDenseStyle style, DataSpec dataSpec, DataStore dataStore)Performs any required range extension.protected CombinergetCombiner(AbstractKernelDensityPlotter.KDenseStyle style)Returns the bin aggregation mode implied by a given style.protected abstract ConfigKey<?>[]getKernelConfigKeys()Returns a list of keys that specify how the smoothing kernel will be configured.protected LayerOptgetLayerOpt(AbstractKernelDensityPlotter.KDenseStyle style)Returns the LayerOpt suitable for a given style for this plotter.protected ReportMapgetPixel1dReport(Pixel1dPlotter.Pixel1dPlan plan, AbstractKernelDensityPlotter.KDenseStyle style, boolean xLog)Returns information associated with the plot.protected intgetPixelPadding(AbstractKernelDensityPlotter.KDenseStyle style, PlanarSurface surf)Returns the padding required at both ends of the array of pixel bins for calculations.ConfigKey<?>[]getStyleKeys()Returns the configuration keys used to configure style for this plotter.protected voidpaintBins(PlanarSurface surface, Pixel1dPlotter.BinArray binArray, AbstractKernelDensityPlotter.KDenseStyle style, java.awt.Graphics2D g)Draws the graphical representation of a given array of counts per horizontal pixel.-
Methods inherited from class uk.ac.starlink.ttools.plot2.layer.Pixel1dPlotter
createKernel, createLayer, getCombinerKey, getCoordGroup, getDataBins, getEffectiveExtent, getPixelWidth, getPlotterIcon, getPlotterName, getWeightCoordIndex, getWeightingDescription, hasReports, readBins
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.ac.starlink.ttools.plot2.Plotter
getPlotterDescription
-
-
-
-
Field Detail
-
BINS_KEY
public static final ReportKey<double[]> BINS_KEY
Report key for plotted bin height in data coordinates.
-
THICK_KEY
public static final ConfigKey<java.lang.Integer> THICK_KEY
Config key for line thickness (only effective if fill==false).
-
NORMALISE_KEY
public static final ConfigKey<Normalisation> NORMALISE_KEY
Config key for normalisation.
-
-
Constructor Detail
-
AbstractKernelDensityPlotter
protected AbstractKernelDensityPlotter(FloatingCoord xCoord, boolean hasWeight, PerUnitConfigKey<Unit> unitKey, java.lang.String name, javax.swing.Icon icon)
Constructor.- Parameters:
xCoord- X axis coordinatehasWeight- true to permit histogram weightingunitKey- config key to select X axis physical units, or null if no unit selection requiredname- plotter nameicon- plotter icon
-
-
Method Detail
-
getKernelConfigKeys
protected abstract ConfigKey<?>[] getKernelConfigKeys()
Returns a list of keys that specify how the smoothing kernel will be configured.- Returns:
- list of implementation-specific kernel config keys
-
createKernelFigure
protected abstract AbstractKernelDensityPlotter.KernelFigure createKernelFigure(ConfigMap config) throws ConfigException
Constructs an object for plot-time kernel construction based on a particular config map.- Parameters:
config- config map with kernel config keys in it- Throws:
ConfigException- See Also:
getKernelConfigKeys()
-
getStyleKeys
public ConfigKey<?>[] getStyleKeys()
Description copied from interface:PlotterReturns the configuration keys used to configure style for this plotter. The keys in the return value are used in the map supplied to thePlotter.createStyle(uk.ac.starlink.ttools.plot2.config.ConfigMap)method.- Returns:
- keys used when creating a style for this plotter.
-
createStyle
public AbstractKernelDensityPlotter.KDenseStyle createStyle(ConfigMap config) throws ConfigException
Description copied from interface:PlotterCreates a style that can be used when creating a plot layer. The keys that are significant in the supplied config map are those returned byPlotter.getStyleKeys(). The return value can be used as input toPlotter.createLayer(uk.ac.starlink.ttools.plot2.DataGeom, uk.ac.starlink.ttools.plot2.data.DataSpec, S).- Parameters:
config- map of style configuration items- Returns:
- plotter-specific plot style
- Throws:
ConfigException
-
getLayerOpt
protected LayerOpt getLayerOpt(AbstractKernelDensityPlotter.KDenseStyle style)
Description copied from class:Pixel1dPlotterReturns the LayerOpt suitable for a given style for this plotter.- Specified by:
getLayerOptin classPixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>- Parameters:
style- plot style- Returns:
- layer option flags
-
getPixelPadding
protected int getPixelPadding(AbstractKernelDensityPlotter.KDenseStyle style, PlanarSurface surf)
Description copied from class:Pixel1dPlotterReturns the padding required at both ends of the array of pixel bins for calculations.- Specified by:
getPixelPaddingin classPixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>- Parameters:
style- plotting stylesurf- plotting surface- Returns:
- padding in pixels required in bin array
-
getCombiner
protected Combiner getCombiner(AbstractKernelDensityPlotter.KDenseStyle style)
Description copied from class:Pixel1dPlotterReturns the bin aggregation mode implied by a given style.- Specified by:
getCombinerin classPixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>- Parameters:
style- plotting style- Returns:
- pixel bin aggregation mode
-
paintBins
protected void paintBins(PlanarSurface surface, Pixel1dPlotter.BinArray binArray, AbstractKernelDensityPlotter.KDenseStyle style, java.awt.Graphics2D g)
Description copied from class:Pixel1dPlotterDraws the graphical representation of a given array of counts per horizontal pixel.- Specified by:
paintBinsin classPixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>- Parameters:
surface- plotting surfacebinArray- counts per X axis pixelstyle- plotting styleg- graphics context
-
extendPixel1dCoordinateRanges
protected void extendPixel1dCoordinateRanges(Range[] ranges, boolean[] logFlags, AbstractKernelDensityPlotter.KDenseStyle style, DataSpec dataSpec, DataStore dataStore)
Description copied from class:Pixel1dPlotterPerforms any required range extension. May be a no-op.- Specified by:
extendPixel1dCoordinateRangesin classPixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>- Parameters:
ranges- array of data space dimension ranges to updatelogFlags- array of linear/log flags corresponding to rangesstyle- plotting styledataSpec- data specificationdataStore- data storage object- See Also:
PlotLayer.extendCoordinateRanges(uk.ac.starlink.ttools.plot.Range[], boolean[], uk.ac.starlink.ttools.plot2.data.DataStore)
-
getPixel1dReport
protected ReportMap getPixel1dReport(Pixel1dPlotter.Pixel1dPlan plan, AbstractKernelDensityPlotter.KDenseStyle style, boolean xLog)
Description copied from class:Pixel1dPlotterReturns information associated with the plot.- Specified by:
getPixel1dReportin classPixel1dPlotter<AbstractKernelDensityPlotter.KDenseStyle>- Parameters:
plan- plotting planstyle- plot stylexLog- true iff X axis is logarithmic- Returns:
- report info, may be null
- See Also:
Drawing.getReport(java.lang.Object)
-
-