Package de.gsi.dataset.spi
Class FloatDataSet
- java.lang.Object
-
- de.gsi.dataset.spi.AbstractStylable<D>
-
- de.gsi.dataset.spi.AbstractDataSet<FloatDataSet>
-
- de.gsi.dataset.spi.FloatDataSet
-
- All Implemented Interfaces:
DataSet,DataSet2D,DataSetMetaData,EditableDataSet,EventSource,java.io.Serializable
public class FloatDataSet extends AbstractDataSet<FloatDataSet> implements DataSet2D, EditableDataSet
Implementation of theDataSetinterface which stores x,y values in two separate 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 float arrays.- Author:
- rstein
- See Also:
for an equivalent implementation with asymmetric errors in Y, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.floats.FloatArrayListxValuesprotected it.unimi.dsi.fastutil.floats.FloatArrayListyValues-
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 FloatDataSet(DataSet another)Creates a new instance ofFloatDataSetas copy of another (deep-copy).FloatDataSet(java.lang.String name)Creates a new instance ofFloatDataSet.FloatDataSet(java.lang.String name, float[] xValues, float[] yValues, int initalSize, boolean deepCopy)Creates a new instance ofFloatDataSet.FloatDataSet(java.lang.String name, int initalSize)Creates a new instance ofFloatDataSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FloatDataSetadd(float[] xValuesNew, float[] yValuesNew)Initialises the data set with specified data.FloatDataSetadd(float x, float y)Add point to the end of the data setFloatDataSetadd(float x, float y, java.lang.String label)Add point to the DoublePoints objectFloatDataSetadd(int index, double... newValue)add point to the data setFloatDataSetadd(int index, double x, double y)add point to the data setFloatDataSetadd(int index, float[] x, float[] y)add point to the data setFloatDataSetadd(int index, float x, float y, java.lang.String label)add point to the data setFloatDataSetclearData()clear all data pointsdoubleget(int dimIndex, int index)Gets the x value of the data point with the index iintgetCapacity()intgetDataCount()Get the number of data points in the data set.float[]getFloatValues(int dimIndex)double[]getValues(int dimIndex)float[]getXFloatValues()float[]getYFloatValues()FloatDataSetincreaseCapacity(int amount)EditableDataSetremove(int index)remove point from data setFloatDataSetremove(int fromIndex, int toIndex)removes sub-range of data pointsFloatDataSetresize(int size)ensures minimum size, enlarges if necessaryFloatDataSetset(float[] xValues, float[] yValues)Initialises the data set with specified data.FloatDataSetset(float[] xValues, float[] yValues, boolean copy)Initialises the data set with specified data.FloatDataSetset(float[] xValues, float[] yValues, int nSamples, boolean copy)Initialises the data set with specified data.FloatDataSetset(int index, double... newValue)replaces point coordinate of existing data pointFloatDataSetset(int index, double[] x, double[] y)FloatDataSetset(int index, double x, double y)FloatDataSetset(DataSet other, boolean copy)clear old data and overwrite with data from 'other' data set (deep copy)FloatDataSettrim()Trims the arrays list so that the capacity is equal to the size.-
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, getValue, getWarningList, hashCode, lock, recomputeLimits, 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, getDataLabel, getIndex, getName, getStyle, getStyle, getValue, lock, recomputeLimits, set, setStyle
-
Methods inherited from interface de.gsi.dataset.DataSet2D
getDimension, getValue, getX, getXIndex, getXValues, getY, getYIndex, getYValues
-
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
-
-
-
-
Constructor Detail
-
FloatDataSet
public FloatDataSet(DataSet another)
Creates a new instance ofFloatDataSetas copy of another (deep-copy).- Parameters:
another- name of this DataSet.
-
FloatDataSet
public FloatDataSet(java.lang.String name)
Creates a new instance ofFloatDataSet.- Parameters:
name- name of this DataSet.- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
FloatDataSet
public FloatDataSet(java.lang.String name, float[] xValues, float[] yValues, int initalSize, boolean deepCopy)Creates a new instance of
The user than specify via the copy parameter, whether the dataset operates directly on the input arrays themselves or on a copies of the input arrays. If the dataset operates directly on the input arrays, these arrays must not be modified outside of this data set.FloatDataSet.- Parameters:
name- name of this data set.xValues- X coordinatesyValues- Y coordinatesinitalSize- initial buffer sizedeepCopy- if true, the input array is copied- Throws:
java.lang.IllegalArgumentException- if any of parameters isnullor if arrays with coordinates have different lengths
-
FloatDataSet
public FloatDataSet(java.lang.String name, int initalSize)Creates a new instance ofFloatDataSet.- Parameters:
name- name of this DataSet.initalSize- initial buffer size- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
-
Method Detail
-
add
public FloatDataSet add(float x, float y)
Add point to the end of the data set- Parameters:
x- indexy- index- Returns:
- itself
-
add
public FloatDataSet add(float x, float y, java.lang.String label)
Add point to the DoublePoints object- Parameters:
x- indexy- indexlabel- the data label- Returns:
- itself
-
add
public FloatDataSet add(float[] xValuesNew, float[] yValuesNew)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValuesNew- X coordinatesyValuesNew- Y coordinates- Returns:
- itself
-
add
public FloatDataSet 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 FloatDataSet 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 FloatDataSet add(int index, float x, float 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 FloatDataSet add(int index, float[] x, float[] 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)
-
clearData
public FloatDataSet clearData()
clear all data points- Returns:
- itself (fluent design)
-
get
public 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()
Description copied from interface:DataSetGet the number of data points in the data set.- Specified by:
getDataCountin interfaceDataSet- Returns:
- the number of data points
-
increaseCapacity
public FloatDataSet increaseCapacity(int amount)
- Parameters:
amount- storage capacity increase- 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 FloatDataSet remove(int fromIndex, int toIndex)
removes sub-range of data points- Parameters:
fromIndex- start indextoIndex- stop index- Returns:
- itself (fluent design)
-
resize
public FloatDataSet resize(int size)
ensures minimum size, enlarges if necessary- Parameters:
size- the actually used array lengths- Returns:
- itself (fluent design)
-
set
public FloatDataSet set(DataSet other, boolean copy)
clear old data and overwrite with data from 'other' data set (deep copy)
-
set
public FloatDataSet set(float[] xValues, float[] 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 FloatDataSet set(float[] xValues, float[] 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 FloatDataSet set(float[] xValues, float[] yValues, 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 coordinatesnSamples- number of samples to be copiedcopy- true: makes an internal copy, false: use the pointer as is (saves memory allocation- Returns:
- itself
-
set
public FloatDataSet 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 FloatDataSet set(int index, double x, double y)
-
set
public FloatDataSet set(int index, double[] x, double[] y)
-
trim
public FloatDataSet trim()
Trims the arrays list so that the capacity is equal to the size.- Returns:
- itself (fluent design)
- See Also:
ArrayList.trimToSize()
-
getFloatValues
public float[] getFloatValues(int dimIndex)
- Parameters:
dimIndex- Dimension to get values for- Returns:
- the float array with the values
-
getValues
public double[] getValues(int dimIndex)
- Specified by:
getValuesin interfaceDataSet- Overrides:
getValuesin classAbstractDataSet<FloatDataSet>- Parameters:
dimIndex- Dimension to get values for- Returns:
- the double array with the values
-
getXFloatValues
public float[] getXFloatValues()
-
getYFloatValues
public float[] getYFloatValues()
-
-