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,DataSetError,DataSetMetaData,EditableDataSet,EventSource
- Direct Known Subclasses:
DefaultErrorDataSet
public class DoubleErrorDataSet extends AbstractErrorDataSet<DoubleErrorDataSet> implements DataSetError, EditableDataSet
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
-
-
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 class de.gsi.dataset.spi.AbstractDataSet
dataLabels, dataStyles, editConstraints, errorList, infoList, lock, metaInfoMap, name, updateListeners, warningList, xRange, yRange
-
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[] 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 dataintgetCapacity()intgetDataCount()Get the number of data points in the data setdoublegetX(int index)Gets the x value of the data point with the index idoublegetXErrorNegative(int index)Returns the negative error along the X axis of a point specified by theindex.doublegetXErrorPositive(int index)Returns the positive error along the X axis of a point specified by theindex.double[]getXValues()doublegetY(int index)Gets the y value of the data point with the index idoublegetYErrorNegative(int index)Returns the negative error along the Y axis of a point specified by theindex.doublegetYErrorPositive(int index)Returns the positive error along the Y axis of a point specified by theindex.double[]getYErrorsNegative()Returns the negative error along the Y axis for all available data points.double[]getYErrorsPositive()Returns the positive error along the y axis for all available data points.double[]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(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
computeLimits, fireInvalidated, getErrorType, getThis, lock, setErrorType, unlock
-
Methods inherited from class de.gsi.dataset.spi.AbstractDataSet
addDataLabel, addDataStyle, binarySearchX, binarySearchY, clearMetaInfo, getDataCount, getDataLabel, getDataLabelMap, getDataStyleMap, getEditConstraints, getErrorList, getInfoList, getMetaInfo, getName, getStyle, getUndefValue, getWarningList, getXIndex, getXMax, getXMin, getXRange, getYIndex, getYMax, getYMin, getYRange, isAutoNotification, minNeigbourSearchX, removeDataLabel, removeStyle, setAutoNotifaction, setEditConstraints, setName, toString, updateEventListener
-
Methods inherited from class de.gsi.dataset.spi.AbstractStylable
getStyle, setStyle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.gsi.dataset.DataSet
getDataCount, getDataLabel, getName, getStyle, getStyle, getUndefValue, getValue, getXIndex, getXMax, getXMin, getYIndex, getYMax, getYMin, isAutoNotification, lock, setAutoNotifaction, setStyle, unlock
-
Methods inherited from interface de.gsi.dataset.DataSetError
getErrorType, getXErrorNegative, getXErrorPositive, getXErrorsNegative, getXErrorsPositive, getYErrorNegative, getYErrorPositive
-
Methods inherited from interface de.gsi.dataset.EditableDataSet
getEditConstraints, setEditConstraints, setName
-
Methods inherited from interface de.gsi.dataset.event.EventSource
addListener, invokeListener, invokeListener, 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(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, 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
-
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, 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
-
-
Method Detail
-
getXValues
public double[] getXValues()
- Specified by:
getXValuesin interfaceDataSet- Returns:
- the x value array
-
getYValues
public double[] getYValues()
- Specified by:
getYValuesin interfaceDataSet- Returns:
- the y value array
-
getYErrorsPositive
public double[] getYErrorsPositive()
Description copied from interface:DataSetErrorReturns the positive error along the y axis for all available data points. Please note that errors are assumed to be always positive!- Specified by:
getYErrorsPositivein interfaceDataSetError- Returns:
- array containing positive y error
-
getYErrorsNegative
public double[] getYErrorsNegative()
Description copied from interface:DataSetErrorReturns the negative error along the Y axis for all available data points. Please note that errors are assumed to be always positive!- Specified by:
getYErrorsNegativein interfaceDataSetError- Returns:
- array containing negative Y error
-
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
-
clearData
public DoubleErrorDataSet clearData()
clears all data- Returns:
- itself (fluent design)
-
getCapacity
public int getCapacity()
- Returns:
- storage capacity of dataset
-
increaseCapacity
public DoubleErrorDataSet increaseCapacity(int amount)
- Parameters:
amount- storage capacity increase- 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)
-
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()
-
getX
public double getX(int index)
Description copied from interface:DataSetGets the x value of the data point with the index i
-
getY
public double getY(int index)
Description copied from interface:DataSetGets the y value of the data point with the index i
-
getXErrorNegative
public double getXErrorNegative(int index)
Description copied from interface:DataSetErrorReturns the negative error along the X axis of a point specified by theindex. Please note that errors are assumed to be always positive!- Specified by:
getXErrorNegativein interfaceDataSetError- Parameters:
index- of negative X error to be returned.- Returns:
- negative X error
-
getXErrorPositive
public double getXErrorPositive(int index)
Description copied from interface:DataSetErrorReturns the positive error along the X axis of a point specified by theindex. Please note that errors are assumed to be always positive!- Specified by:
getXErrorPositivein interfaceDataSetError- Parameters:
index- of positive X error to be returned.- Returns:
- positive X error
-
getYErrorNegative
public double getYErrorNegative(int index)
Description copied from interface:DataSetErrorReturns the negative error along the Y axis of a point specified by theindex. Please note that errors are assumed to be always positive!- Specified by:
getYErrorNegativein interfaceDataSetError- Parameters:
index- of negative Y error to be returned.- Returns:
- negative Y error
-
getYErrorPositive
public double getYErrorPositive(int index)
Description copied from interface:DataSetErrorReturns the positive error along the Y axis of a point specified by theindex. Please note that errors are assumed to be always positive!- Specified by:
getYErrorPositivein interfaceDataSetError- Parameters:
index- of positive Y error to be returned.- Returns:
- positive Y error
-
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 x, double y)
add point to the data set- Specified by:
addin interfaceEditableDataSet- 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)
-
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)
-
set
public DoubleErrorDataSet set(int index, double x, double y)
replaces point coordinate of existing data point- Specified by:
setin interfaceEditableDataSet- 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)
-
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)
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(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)
-
-