Package de.gsi.dataset.spi
Class DoubleErrorDataSet
- java.lang.Object
-
- de.gsi.dataset.spi.AbstractStylable<D>
-
- de.gsi.dataset.spi.AbstractDataSet<D>
-
- de.gsi.dataset.spi.AbstractErrorDataSet<DoubleErrorDataSet>
-
- de.gsi.dataset.spi.DoubleErrorDataSet
-
- All Implemented Interfaces:
DataSet,DataSet2D,DataSetError,DataSetMetaData,EditableDataSet,EventSource,java.io.Serializable
- Direct Known Subclasses:
DefaultErrorDataSet
public class DoubleErrorDataSet extends AbstractErrorDataSet<DoubleErrorDataSet> implements DataSetError, EditableDataSet, DataSet2D
Implementation of theDataSetErrorinterface which stores x,y, +eyn, and -eyn values in separate double arrays. It provides methods allowing easily manipulate of data points.- Author:
- rstein
- See Also:
for an implementation without errors, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.gsi.dataset.DataSetError
DataSetError.ErrorType
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.doubles.DoubleArrayListxValuesprotected it.unimi.dsi.fastutil.doubles.DoubleArrayListyErrorsNegprotected it.unimi.dsi.fastutil.doubles.DoubleArrayListyErrorsPosprotected it.unimi.dsi.fastutil.doubles.DoubleArrayListyValues-
Fields inherited from interface de.gsi.dataset.DataSetMetaData
TAG_GAIN_RANGE, TAG_OVERSHOOT, TAG_UNDERSHOOT
-
-
Constructor Summary
Constructors Constructor Description DoubleErrorDataSet(DataSet another)Creates a new instance ofDoubleErrorDataSetas copy of another (deep-copy).DoubleErrorDataSet(java.lang.String name)Creates a new instance ofDoubleErrorDataSet.DoubleErrorDataSet(java.lang.String name, double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos, int initalSize, boolean deepCopy)Creates a new instance ofDoubleErrorDataSet.DoubleErrorDataSet(java.lang.String name, int initalSize)Creates a new instance ofDoubleErrorDataSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleErrorDataSetadd(double[] xValuesNew, double[] yValuesNew, double[] yErrorsNegNew, double[] yErrorsPosNew)Add array vectors to data set.DoubleErrorDataSetadd(double x, double y)add point to the data setDoubleErrorDataSetadd(double x, double y, double yErrorNeg, double yErrorPos)Add point to the data set.DoubleErrorDataSetadd(double x, double y, double yErrorNeg, double yErrorPos, java.lang.String label)Add point to the data set.DoubleErrorDataSetadd(int index, double... newValue)add point to the data setDoubleErrorDataSetadd(int index, double[] x, double[] y, double[] yErrorNeg, double[] yErrorPos)add point to the data setDoubleErrorDataSetadd(int index, double x, double y)add point to the data setDoubleErrorDataSetadd(int index, double x, double y, double yErrorNeg, double yErrorPos)add point to the data setDoubleErrorDataSetadd(int index, double x, double y, double yErrorNeg, double yErrorPos, java.lang.String label)add point to the data setDoubleErrorDataSetclearData()clears all datadoubleget(int dimIndex, int index)Gets the x value of the data point with the index iintgetCapacity()intgetDataCount(int dimIndex)Get the number of data points in the data set for a specific dimension.doublegetErrorNegative(int dimIndex, int index)Returns the negative error along the 'dimIndex' axis of a point specified by theindex.doublegetErrorPositive(int dimIndex, int index)Returns the positive error along the 'dimIndex' axis of a point specified by theindex.double[]getErrorsNegative(int dimIndex)Returns the negative error along the 'dimIndex' axis for all available data points.double[]getErrorsPositive(int dimIndex)Returns the positive error along the 'dimIndex' axis for all available data points.double[]getValues(int dimIndex)doublegetX(int index)Gets the x value of the data point with the index idouble[]getXValues()doublegetY(int index)Gets the y value of the data point with the index idouble[]getYValues()DoubleErrorDataSetincreaseCapacity(int amount)DoubleErrorDataSetremove(int index)remove point from data setDoubleErrorDataSetremove(int fromIndex, int toIndex)remove sub-range of data pointsDoubleErrorDataSetresize(int size)ensures minimum size, enlarges if necessaryDoubleErrorDataSetset(double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos)Initialises the data set with specified data.DoubleErrorDataSetset(double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos, boolean copy)Initialises the data set with specified data.DoubleErrorDataSetset(double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos, int nSamples, boolean copy)Initialises the data set with specified data.DoubleErrorDataSetset(int index, double... newValue)replaces point coordinate of existing data pointDoubleErrorDataSetset(int index, double[] x, double[] y, double[] yErrorNeg, double[] yErrorPos)DoubleErrorDataSetset(int index, double x, double y)replaces point coordinate of existing data pointDoubleErrorDataSetset(int index, double x, double y, double yErrorNeg, double yErrorPos)replaces point coordinate of existing data pointDoubleErrorDataSetset(DataSet other)clear old data and overwrite with data from 'other' data set (deep copy)DoubleErrorDataSettrim()Trims the arrays list so that the capacity is equal to the size.-
Methods inherited from class de.gsi.dataset.spi.AbstractErrorDataSet
fireInvalidated, getErrorType, getThis, lock, recomputeLimits, setErrorType
-
Methods inherited from class de.gsi.dataset.spi.AbstractDataSet
addDataLabel, addDataStyle, autoNotification, binarySearch, clearMetaInfo, equalDataLabels, equalEditConstraints, equalErrorValues, equalMetaData, equals, equals, equalValues, getAxisDescriptions, getDataLabel, getDataLabelMap, getDataStyleMap, getDimension, getEditConstraints, getErrorList, getIndex, getInfoList, getMetaInfo, getName, getStyle, getWarningList, hashCode, minNeigbourSearchX, 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
getAxisDescription, getAxisDescriptions, getDataCount, getDataLabel, getIndex, getName, getStyle, getStyle, lock, recomputeLimits, setStyle
-
Methods inherited from interface de.gsi.dataset.DataSet2D
getDimension, getValue, getValue, getXIndex, getYIndex
-
Methods inherited from interface de.gsi.dataset.DataSetError
getErrorNegative, getErrorPositive, getErrorType
-
Methods inherited from interface de.gsi.dataset.EditableDataSet
getEditConstraints, setEditConstraints, setName
-
Methods inherited from interface de.gsi.dataset.event.EventSource
addListener, autoNotification, invokeListener, invokeListener, invokeListener, isAutoNotification, removeListener, updateEventListener
-
-
-
-
Field Detail
-
xValues
protected it.unimi.dsi.fastutil.doubles.DoubleArrayList xValues
-
yValues
protected it.unimi.dsi.fastutil.doubles.DoubleArrayList yValues
-
yErrorsPos
protected it.unimi.dsi.fastutil.doubles.DoubleArrayList yErrorsPos
-
yErrorsNeg
protected it.unimi.dsi.fastutil.doubles.DoubleArrayList yErrorsNeg
-
-
Constructor Detail
-
DoubleErrorDataSet
public DoubleErrorDataSet(DataSet another)
Creates a new instance ofDoubleErrorDataSetas copy of another (deep-copy).- Parameters:
another- name of this DataSet.
-
DoubleErrorDataSet
public DoubleErrorDataSet(java.lang.String name)
Creates a new instance ofDoubleErrorDataSet.- Parameters:
name- name of this DataSet.- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
DoubleErrorDataSet
public DoubleErrorDataSet(java.lang.String name, double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos, int initalSize, boolean deepCopy)Creates a new instance of
The user than specify via the copy parameter, whether the dataset wraps the input arrays themselves or on a copies of the input arrays.DoubleErrorDataSet.- Parameters:
name- name of this data set.xValues- X coordinatesyValues- Y coordinatesyErrorsNeg- Y negative coordinate erroryErrorsPos- Y positive coordinate errorinitalSize- how many data points are relevant to be takendeepCopy- if true, the input array is copied- Throws:
java.lang.IllegalArgumentException- if any of the parameters isnullor if arrays with coordinates have different lengths
-
DoubleErrorDataSet
public DoubleErrorDataSet(java.lang.String name, int initalSize)Creates a new instance ofDoubleErrorDataSet.- Parameters:
name- name of this DataSet.initalSize- initial capacity of buffer (N.B. size=0)- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
-
Method Detail
-
add
public DoubleErrorDataSet add(double x, double y)
add point to the data set- Parameters:
x- horizontal coordinate of the new data pointy- vertical coordinate of the new data point- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(double x, double y, double yErrorNeg, double yErrorPos)
Add point to the data set.- Parameters:
x- the new x coordinatey- the new y coordinateyErrorNeg- the +dy erroryErrorPos- the -dy error- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(double x, double y, double yErrorNeg, double yErrorPos, java.lang.String label)
Add point to the data set.- Parameters:
x- the new x coordinatey- the new y coordinateyErrorNeg- the +dy erroryErrorPos- the -dy errorlabel- the data label- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(double[] xValuesNew, double[] yValuesNew, double[] yErrorsNegNew, double[] yErrorsPosNew)
Add array vectors to data set.- Parameters:
xValuesNew- X coordinatesyValuesNew- Y coordinatesyErrorsNegNew- the +dy errorsyErrorsPosNew- the -dy errors- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(int index, double... newValue)
add point to the data set- Specified by:
addin interfaceEditableDataSet- Parameters:
index- data point index at which the new data point should be addednewValue- new data point coordinate- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(int index, double x, double y)
add point to the data set- Parameters:
index- data point index at which the new data point should be addedx- horizontal coordinate of the new data pointy- vertical coordinate of the new data point- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(int index, double x, double y, double yErrorNeg, double yErrorPos)
add point to the data set- Parameters:
index- data point index at which the new data point should be addedx- horizontal coordinate of the new data pointy- vertical coordinate of the new data pointyErrorNeg- the +dy erroryErrorPos- the -dy error- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(int index, double x, double y, double yErrorNeg, double yErrorPos, java.lang.String label)
add point to the data set- Parameters:
index- data point index at which the new data point should be addedx- horizontal coordinates of the new data pointy- vertical coordinates of the new data pointyErrorNeg- the +dy erroryErrorPos- the -dy errorlabel- data point label (see CategoryAxis)- Returns:
- itself (fluent design)
-
add
public DoubleErrorDataSet add(int index, double[] x, double[] y, double[] yErrorNeg, double[] yErrorPos)
add point to the data set- Parameters:
index- data point index at which the new data point should be addedx- horizontal coordinate of the new data pointy- vertical coordinate of the new data pointyErrorNeg- the +dy erroryErrorPos- the -dy error- Returns:
- itself (fluent design)
-
clearData
public DoubleErrorDataSet clearData()
clears all data- Returns:
- itself (fluent design)
-
get
public final double get(int dimIndex, int index)Description copied from interface:DataSetGets the x value of the data point with the index i
-
getCapacity
public int getCapacity()
- Returns:
- storage capacity of dataset
-
getDataCount
public int getDataCount(int dimIndex)
Description copied from interface:DataSetGet the number of data points in the data set for a specific dimension.- Specified by:
getDataCountin interfaceDataSet- Parameters:
dimIndex- the dimension index (ie. '0' equals 'X', '1' equals 'Y')- Returns:
- the number of data points
-
getErrorNegative
public double getErrorNegative(int dimIndex, int index)Description copied from interface:DataSetErrorReturns the negative error along the 'dimIndex' axis of a point specified by theindex. Please note that errors are assumed to be always positive!- Specified by:
getErrorNegativein interfaceDataSetError- Parameters:
dimIndex- the dimension index (ie. '0' equals 'X', '1' equals 'Y')index- of negative 'dimIndex' error to be returned.- Returns:
- negative 'dimIndex' error
-
getErrorPositive
public double getErrorPositive(int dimIndex, int index)Description copied from interface:DataSetErrorReturns the positive error along the 'dimIndex' axis of a point specified by theindex. Please note that errors are assumed to be always positive!- Specified by:
getErrorPositivein interfaceDataSetError- Parameters:
dimIndex- the dimension index (ie. '0' equals 'X', '1' equals 'Y')index- of positive 'dimIndex' error to be returned.- Returns:
- positive 'dimIndex' error
-
getErrorsNegative
public double[] getErrorsNegative(int dimIndex)
Description copied from interface:DataSetErrorReturns the negative error along the 'dimIndex' axis for all available data points. Please note that errors are assumed to be always positive!- Specified by:
getErrorsNegativein interfaceDataSetError- Parameters:
dimIndex- the dimension index (ie. '0' equals 'X', '1' equals 'Y')- Returns:
- array containing negative 'dimIndex' error
-
getErrorsPositive
public double[] getErrorsPositive(int dimIndex)
Description copied from interface:DataSetErrorReturns the positive error along the 'dimIndex' axis for all available data points. Please note that errors are assumed to be always positive!- Specified by:
getErrorsPositivein interfaceDataSetError- Parameters:
dimIndex- the dimension index (ie. '0' equals 'X', '1' equals 'Y')- Returns:
- array containing positive 'dimIndex' error
-
getValues
public final double[] getValues(int dimIndex)
-
getX
public double getX(int index)
Description copied from interface:DataSet2DGets the x value of the data point with the index i
-
getXValues
public double[] getXValues()
- Specified by:
getXValuesin interfaceDataSet2D- Returns:
- the x value array
-
getY
public double getY(int index)
Description copied from interface:DataSet2DGets the y value of the data point with the index i
-
getYValues
public double[] getYValues()
- Specified by:
getYValuesin interfaceDataSet2D- Returns:
- the x value array
-
increaseCapacity
public DoubleErrorDataSet increaseCapacity(int amount)
- Parameters:
amount- storage capacity increase- Returns:
- itself (fluent design)
-
remove
public DoubleErrorDataSet remove(int index)
Description copied from interface:EditableDataSetremove point from data set- Specified by:
removein interfaceEditableDataSet- Parameters:
index- data point which should be removed- Returns:
- itself (fluent design)
-
remove
public DoubleErrorDataSet remove(int fromIndex, int toIndex)
remove sub-range of data points- Parameters:
fromIndex- start indextoIndex- stop index- Returns:
- itself (fluent design)
-
resize
public DoubleErrorDataSet resize(int size)
ensures minimum size, enlarges if necessary- Parameters:
size- the actually used array lengths- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(DataSet other)
clear old data and overwrite with data from 'other' data set (deep copy)- Parameters:
other- the other data set- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinatesyErrorsNeg- the +dy errorsyErrorsPos- the -dy errors- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos, boolean copy)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinatesyErrorsNeg- the +dy errorsyErrorsPos- the -dy errorscopy- true: makes an internal copy, false: use the pointer as is (saves memory allocation)- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(double[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos, int nSamples, boolean copy)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinatesyErrorsNeg- the +dy errorsyErrorsPos- the -dy errorsnSamples- number of samples to be copiedcopy- true: makes an internal copy, false: use the pointer as is (saves memory allocation)- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(int index, double... newValue)
replaces point coordinate of existing data point- Specified by:
setin interfaceEditableDataSet- Parameters:
index- data point index at which the new data point should be addednewValue- new data point coordinate- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(int index, double x, double y)
replaces point coordinate of existing data point- Parameters:
index- the index of the data pointx- new horizontal coordinatey- new vertical coordinate N.B. errors are implicitly assumed to be zero- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(int index, double x, double y, double yErrorNeg, double yErrorPos)
replaces point coordinate of existing data point- Parameters:
index- the index of the data pointx- new horizontal coordinatey- new vertical coordinateyErrorNeg- new vertical negative error of y (can be asymmetric)yErrorPos- new vertical positive error of y (can be asymmetric)- Returns:
- itself (fluent design)
-
set
public DoubleErrorDataSet set(int index, double[] x, double[] y, double[] yErrorNeg, double[] yErrorPos)
-
trim
public DoubleErrorDataSet trim()
Trims the arrays list so that the capacity is equal to the size.- Returns:
- itself (fluent design)
- See Also:
ArrayList.trimToSize()
-
-