Package de.gsi.dataset.spi
Class DoubleDataSet
- java.lang.Object
-
- de.gsi.dataset.spi.AbstractStylable<D>
-
- de.gsi.dataset.spi.AbstractDataSet<DoubleDataSet>
-
- de.gsi.dataset.spi.DoubleDataSet
-
- All Implemented Interfaces:
DataSet,DataSetMetaData,EditableDataSet,EventSource
- Direct Known Subclasses:
DefaultDataSet
public class DoubleDataSet extends AbstractDataSet<DoubleDataSet> implements EditableDataSet
Implementation of theDataSetinterface which stores x,y values in two separate arrays. It provides methods allowing easily manipulate of data points.- Author:
- rstein
- See Also:
for an implementation with asymmetric errors in Y
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.doubles.DoubleArrayListxValuesprotected 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 DoubleDataSet(DataSet another)Creates a new instance ofDoubleDataSetas copy of another (deep-copy).DoubleDataSet(java.lang.String name)Creates a new instance ofDoubleDataSet.DoubleDataSet(java.lang.String name, double[] xValues, double[] yValues, int initalSize, boolean deepCopy)Creates a new instance ofDoubleDataSet.DoubleDataSet(java.lang.String name, int initalSize)Creates a new instance ofDoubleDataSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleDataSetadd(double[] xValuesNew, double[] yValuesNew)Add array vectors to data set.DoubleDataSetadd(double x, double y)Add point to the end of the data setDoubleDataSetadd(double x, double y, java.lang.String label)Add point to the data set.DoubleDataSetadd(int index, double[] x, double[] y)add point to the data setDoubleDataSetadd(int index, double x, double y)add point to the data setDoubleDataSetadd(int index, double x, double y, java.lang.String label)add point to the data setDoubleDataSetclearData()clear all data pointsintgetCapacity()intgetDataCount()Get the number of data points in the data setdoublegetX(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()DoubleDataSetincreaseCapacity(int amount)EditableDataSetremove(int index)remove point from data setDoubleDataSetremove(int fromIndex, int toIndex)removes sub-range of data pointsDoubleDataSetresize(int size)ensures minimum size, enlarges if necessaryDoubleDataSetset(double[] xValues, double[] yValues)Initialises the data set with specified data.DoubleDataSetset(double[] xValues, double[] yValues, boolean copy)Initialises the data set with specified data.DoubleDataSetset(int index, double[] x, double[] y)DoubleDataSetset(int index, double x, double y)replaces point coordinate of existing data pointDoubleDataSetset(DataSet other)clear old data and overwrite with data from 'other' data set (deep copy)DoubleDataSettrim()Trims the arrays list so that the capacity is equal to the size.-
Methods inherited from class de.gsi.dataset.spi.AbstractDataSet
addDataLabel, addDataStyle, binarySearchX, binarySearchY, clearMetaInfo, computeLimits, fireInvalidated, getDataCount, getDataLabel, getDataLabelMap, getDataStyleMap, getEditConstraints, getErrorList, getInfoList, getMetaInfo, getName, getStyle, getThis, getUndefValue, getWarningList, getXIndex, getXMax, getXMin, getXRange, getYIndex, getYMax, getYMin, getYRange, isAutoNotification, lock, minNeigbourSearchX, removeDataLabel, removeStyle, setAutoNotifaction, setEditConstraints, setName, toString, unlock, 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.EditableDataSet
getEditConstraints, setEditConstraints, setName
-
Methods inherited from interface de.gsi.dataset.event.EventSource
addListener, invokeListener, invokeListener, removeListener, updateEventListener
-
-
-
-
Constructor Detail
-
DoubleDataSet
public DoubleDataSet(java.lang.String name)
Creates a new instance ofDoubleDataSet.- Parameters:
name- name of this DataSet.- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
DoubleDataSet
public DoubleDataSet(java.lang.String name, int initalSize)Creates a new instance ofDoubleDataSet.- Parameters:
name- name of this DataSet.initalSize- initial capacity of buffer (N.B. size=0)- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
DoubleDataSet
public DoubleDataSet(DataSet another)
Creates a new instance ofDoubleDataSetas copy of another (deep-copy).- Parameters:
another- name of this DataSet.
-
DoubleDataSet
public DoubleDataSet(java.lang.String name, double[] xValues, double[] yValues, 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.DoubleDataSet.- Parameters:
name- name of this data set.xValues- X coordinatesyValues- Y coordinatesinitalSize- 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
-
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 DoubleDataSet clearData()
clear all data points- Returns:
- itself (fluent design)
-
getCapacity
public int getCapacity()
- Returns:
- storage capacity of dataset
-
increaseCapacity
public DoubleDataSet increaseCapacity(int amount)
- Parameters:
amount- storage capacity increase- Returns:
- itself (fluent design)
-
resize
public DoubleDataSet resize(int size)
ensures minimum size, enlarges if necessary- Parameters:
size- the actually used array lengths- Returns:
- itself (fluent design)
-
trim
public DoubleDataSet 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
-
add
public DoubleDataSet add(double x, double y)
Add point to the end of the data set- Parameters:
x- indexy- index- Returns:
- itself
-
add
public DoubleDataSet add(double x, double y, java.lang.String label)
Add point to the data set.- Parameters:
x- horizontal coordinate of the new data pointy- vertical coordinate of the new data pointlabel- the data label- Returns:
- itself (fluent design)
-
add
public DoubleDataSet add(double[] xValuesNew, double[] yValuesNew)
Add array vectors to data set.- Parameters:
xValuesNew- X coordinatesyValuesNew- Y coordinates- Returns:
- itself
-
add
public DoubleDataSet 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 DoubleDataSet add(int index, double x, double y, 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 pointlabel- data point label (see CategoryAxis)- Returns:
- itself (fluent design)
-
add
public DoubleDataSet 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)
-
remove
public EditableDataSet remove(int index)
remove point from data set- Specified by:
removein interfaceEditableDataSet- Parameters:
index- data point which should be removed- Returns:
- itself (fluent design)
-
remove
public DoubleDataSet remove(int fromIndex, int toIndex)
removes sub-range of data points- Parameters:
fromIndex- start indextoIndex- stop index- Returns:
- itself (fluent design)
-
set
public DoubleDataSet 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 DoubleDataSet set(double[] xValues, double[] yValues, boolean copy)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinatescopy- true: makes an internal copy, false: use the pointer as is (saves memory allocation- Returns:
- itself
-
set
public DoubleDataSet set(double[] xValues, double[] yValues)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinates- Returns:
- itself
-
set
public DoubleDataSet set(int index, double[] x, double[] y)
-
set
public DoubleDataSet set(DataSet other)
clear old data and overwrite with data from 'other' data set (deep copy)- Parameters:
other- the source data set- Returns:
- itself (fluent design)
-
-