Package de.gsi.dataset.spi
Class AbstractHistogram
- java.lang.Object
-
- de.gsi.dataset.spi.AbstractStylable<D>
-
- de.gsi.dataset.spi.AbstractDataSet<AbstractHistogram>
-
- de.gsi.dataset.spi.AbstractHistogram
-
- All Implemented Interfaces:
DataSet,DataSetMetaData,EventSource,Histogram,java.io.Serializable
- Direct Known Subclasses:
Histogram,Histogram2
public abstract class AbstractHistogram extends AbstractDataSet<AbstractHistogram> implements Histogram
- Author:
- rstein
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractHistogram.HistogramOuterBoundsDefines how the lower and upper bound of equidistant Histograms should be treated-
Nested classes/interfaces inherited from interface de.gsi.dataset.Histogram
Histogram.Boundary
-
-
Field Summary
Fields Modifier and Type Field Description protected double[][]axisBinsprotected double[]data-
Fields inherited from class de.gsi.dataset.spi.AbstractDataSet
axisListener, dimension
-
Fields inherited from interface de.gsi.dataset.DataSetMetaData
TAG_GAIN_RANGE, TAG_OVERSHOOT, TAG_UNDERSHOOT
-
-
Constructor Summary
Constructors Constructor Description AbstractHistogram(java.lang.String name, double[] xBins)Creates a non equidistant histogram with name and range [minX, maxX]AbstractHistogram(java.lang.String name, int nBinsX, double minX, double maxX, int nBinsY, double minY, double maxY, AbstractHistogram.HistogramOuterBounds boundsType)Creates 2D histogram with name and ranges [minX, maxX] and [minY, maxY]AbstractHistogram(java.lang.String name, int nBins, double minX, double maxX, AbstractHistogram.HistogramOuterBounds boundsType)Creates histogram with name and range [minX, maxX]
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBinContent(int bin)Increment bin content by 1.voidaddBinContent(int bin, double w)Increment bin content by a weight w.protected voidfillEquidistantAxisBinning(double[] bins, double min, double max, AbstractHistogram.HistogramOuterBounds boundsType)intfindBin(double x, double y)intfindBin(double x, double y, double z)intfindBin(int dimIndex, double val)protected intfindNextLargerIndex(double[] bin, double value)doublegetBinCenter(int dimIndex, int binIndex)doublegetBinContent(int bin)Return content of bin number bin.intgetBinCount(int dimIndex)doublegetBinLimits(int dimIndex, Histogram.Boundary boundary, int binIndex)AbstractHistogram.HistogramOuterBoundsgetBoundsType()intgetDataCount()Get the number of data points in the data set.doublegetValue(int dimIndex, double... x)Returns the value along the 'dimIndex' axis of a point specified by thexcoordinate.booleanisEquiDistant()DataSetrecomputeLimits(int dimIndex)voidreset()reset histogram contentprotected static <T> voidswap(T[] arr, int i, int j)-
Methods inherited from class de.gsi.dataset.spi.AbstractDataSet
addDataLabel, addDataStyle, autoNotification, binarySearch, binarySearch, clearMetaInfo, copyAxisDescription, copyDataLabelsAndStyles, copyMetaData, equalDataLabels, equalEditConstraints, equalErrorValues, equalMetaData, equals, equals, equalValues, fireInvalidated, getAxisDescriptions, getDataLabel, getDataLabelMap, getDataStyleMap, getDimension, getEditConstraints, getErrorList, getIndex, getInfoList, getMetaInfo, getName, getStyle, getThis, getValues, getWarningList, hashCode, lock, removeDataLabel, removeStyle, setEditConstraints, setName, toString, updateEventListener
-
Methods inherited from class de.gsi.dataset.spi.AbstractStylable
getStyle, setStyle
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.gsi.dataset.DataSet
get, getAxisDescription, getAxisDescriptions, getDataLabel, getDimension, getIndex, getName, getStyle, getStyle, getValues, lock, set, set, setStyle
-
Methods inherited from interface de.gsi.dataset.DataSetMetaData
getErrorList, getInfoList, getMetaInfo, getWarningList
-
Methods inherited from interface de.gsi.dataset.event.EventSource
addListener, autoNotification, invokeListener, invokeListener, invokeListener, isAutoNotification, removeListener, updateEventListener
-
-
-
-
Constructor Detail
-
AbstractHistogram
public AbstractHistogram(java.lang.String name, double[] xBins)Creates a non equidistant histogram with name and range [minX, maxX]NOTE: since chartfx's default ErrorDataSetRenderer cannot access the bin boundaries, it is currently unable to correctly render non equidistant Histograms.
- Parameters:
name- of the data setsxBins- the bin boundary array (defines [minX, maxX] and nBins)
-
AbstractHistogram
public AbstractHistogram(java.lang.String name, int nBins, double minX, double maxX, AbstractHistogram.HistogramOuterBounds boundsType)Creates histogram with name and range [minX, maxX]- Parameters:
name- of the data setsnBins- number of binsminX- minimum of rangemaxX- maximum of rangeboundsType- how the min/max value should be interpreted
-
AbstractHistogram
public AbstractHistogram(java.lang.String name, int nBinsX, double minX, double maxX, int nBinsY, double minY, double maxY, AbstractHistogram.HistogramOuterBounds boundsType)Creates 2D histogram with name and ranges [minX, maxX] and [minY, maxY]- Parameters:
name- of the data setsnBinsX- number of horizontal binsminX- minimum of horizontal rangemaxX- maximum of horizontal rangenBinsY- number of vertical binsminY- minimum of vertical rangemaxY- maximum of vertical rangeboundsType- How the min and max value should be interpreted
-
-
Method Detail
-
fillEquidistantAxisBinning
protected void fillEquidistantAxisBinning(double[] bins, double min, double max, AbstractHistogram.HistogramOuterBounds boundsType)
-
addBinContent
public void addBinContent(int bin)
Description copied from interface:HistogramIncrement bin content by 1. More...- Specified by:
addBinContentin interfaceHistogram- Parameters:
bin- global bin ID
-
addBinContent
public void addBinContent(int bin, double w)Description copied from interface:HistogramIncrement bin content by a weight w. More...- Specified by:
addBinContentin interfaceHistogram- Parameters:
bin- global bin IDw- weight
-
findBin
public int findBin(double x, double y)
-
findBin
public int findBin(double x, double y, double z)
-
findBin
public int findBin(int dimIndex, double val)
-
findNextLargerIndex
protected int findNextLargerIndex(double[] bin, double value)
-
getBinCenter
public double getBinCenter(int dimIndex, int binIndex)- Specified by:
getBinCenterin interfaceHistogram- Parameters:
dimIndex- the dimension indexbinIndex- index- Returns:
- bin centre for axis with dimIndex
-
getBinCount
public int getBinCount(int dimIndex)
- Specified by:
getBinCountin interfaceHistogram- Parameters:
dimIndex- the dimension index- Returns:
- the number of bins for the given dimIndex (includes the under- and over-flow bin)
-
getBinContent
public double getBinContent(int bin)
Description copied from interface:HistogramReturn content of bin number bin. Convention for numbering bins For all histogram types: nbins, xlow, xup bin = 0; underflow bin bin = 1; first bin with low-edge xlow INCLUDED bin = nbins; last bin with upper-edge xup EXCLUDED bin = nbins+1; overflow bin- Specified by:
getBinContentin interfaceHistogram- Parameters:
bin- the index- Returns:
- numeric bin content
-
getDataCount
public int getDataCount()
Description copied from interface:DataSetGet the number of data points in the data set.- Specified by:
getDataCountin interfaceDataSet- Returns:
- the number of data points
-
isEquiDistant
public boolean isEquiDistant()
- Specified by:
isEquiDistantin interfaceHistogram- Returns:
- true if bin sizes are equal
-
recomputeLimits
public DataSet recomputeLimits(int dimIndex)
- Specified by:
recomputeLimitsin interfaceDataSet- Overrides:
recomputeLimitsin classAbstractDataSet<AbstractHistogram>- Parameters:
dimIndex- the dimension to recompute the range for (-1 for all dimensions)- Returns:
- itself for method chaining
-
getBinLimits
public double getBinLimits(int dimIndex, Histogram.Boundary boundary, int binIndex)- Specified by:
getBinLimitsin interfaceHistogram- Parameters:
dimIndex- the dimension indexboundary- for upper or lower bound limitsbinIndex- index- Returns:
- bin limits for axis and upper/lower bound for dimIndex bin
-
getBoundsType
public AbstractHistogram.HistogramOuterBounds getBoundsType()
-
getValue
public double getValue(int dimIndex, double... x)Description copied from interface:DataSetReturns the value along the 'dimIndex' axis of a point specified by thexcoordinate.- Specified by:
getValuein interfaceDataSet- Overrides:
getValuein classAbstractDataSet<AbstractHistogram>- Parameters:
dimIndex- the dimension index (ie. '0' equals 'X', '1' equals 'Y')x- horizontal 'dimIndex' coordinate- Returns:
- 'dimIndex' value
-
reset
public void reset()
Description copied from interface:Histogramreset histogram content
-
swap
protected static <T> void swap(T[] arr, int i, int j)
-
-