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, -eyn values in separate double arrays. It provides methods allowing easily manipulate of data points.
User provides X and Y coordinates or only Y coordinates. In the former case X coordinates have value of data point index. This version being optimised for native double arrays.- Author:
- rstein
- See Also:
for an equivalent 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 intdataMaxIndexprotected double[]xValuesprotected double[]yErrorsNegprotected double[]yErrorsPosprotected double[]yValues-
Fields inherited from class de.gsi.dataset.spi.AbstractDataSet
dataLabels, dataStyles, editConstraints, lock, metaInfoMap, name, updateListeners, 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 ofDoubleDataSetas 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 nData, 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[] xValues, double[] yValues, double[] yErrorsNeg, double[] yErrorsPos)Initialises the data set with specified data.DoubleErrorDataSetadd(double x, double y)Add point to the DoublePoints object.DoubleErrorDataSetadd(double x, double y, double yErrorNeg, double yErrorPos)Add point to the DoublePoints objectEditableDataSetadd(int index, double x, double y)add point to the data setDoubleErrorDataSetclearData()clears all dataintgetDataCount()Get the number of data points in the data setjava.util.Map<java.lang.Integer,java.lang.String>getDataLabelMap()java.util.Map<java.lang.Integer,java.lang.String>getDataStyleMap()doublegetX(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()EditableDataSetremove(int index)remove point from data setDoubleErrorDataSetremove(int fromIndex, int toIndex)remove sub-range of data pointsDoubleErrorDataSetset(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)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)-
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, getDataCount, getDataLabel, getDefaultDataLabel, 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
-
-
-
-
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- maximum capacity of buffer- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
DoubleErrorDataSet
public DoubleErrorDataSet(DataSet another)
Creates a new instance ofDoubleDataSetas 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 nData, boolean deepCopy)Creates a new instance of
DoubleErrorDataSet.- Parameters:
name- name of this data set.xValues- X coordinatesyValues- Y coordinatesyErrorsNeg- Y negative coordinate erroryErrorsPos- Y positive coordinate errornData- how many data points are relevant to be takendeepCopy- if true, the input array is copied- Throws:
java.lang.IllegalArgumentException- if any of parameters isnullor if arrays with coordinates have different lengths
-
-
Method Detail
-
getDataLabelMap
public java.util.Map<java.lang.Integer,java.lang.String> getDataLabelMap()
- Returns:
- data label map for given data point
-
getDataStyleMap
public java.util.Map<java.lang.Integer,java.lang.String> getDataStyleMap()
- Returns:
- data style map (CSS-styling)
-
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)
-
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
-
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)
-
add
public DoubleErrorDataSet add(double x, double y)
Add point to the DoublePoints object. Errors in y are assumed 0.- Parameters:
x- the new x coordinatey- the new y coordinate- Returns:
- itself
-
add
public DoubleErrorDataSet add(double x, double y, double yErrorNeg, double yErrorPos)
Add point to the DoublePoints object- Parameters:
x- the new x coordinatey- the new y coordinateyErrorNeg- the +dy erroryErrorPos- the -dy error- Returns:
- itself
-
remove
public EditableDataSet 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)
-
add
public EditableDataSet add(int index, double x, double y)
Description copied from interface:EditableDataSetadd 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(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)
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)
-
-