Package de.gsi.dataset.spi
Class LimitedIndexedTreeDataSet
- java.lang.Object
-
- de.gsi.dataset.spi.AbstractStylable<D>
-
- de.gsi.dataset.spi.AbstractDataSet<D>
-
- de.gsi.dataset.spi.AbstractErrorDataSet<LimitedIndexedTreeDataSet>
-
- de.gsi.dataset.spi.LimitedIndexedTreeDataSet
-
- All Implemented Interfaces:
DataSet,DataSetError,DataSetMetaData,EventSource
public class LimitedIndexedTreeDataSet extends AbstractErrorDataSet<LimitedIndexedTreeDataSet>
DataSet implementation based on a sorted indexed TreeDataSets. This tree data set is sorted (allows on-the-fly insertions), indexed (required for the chart interface to efficiently parse through the data ('efficient' for most 'normal' implementations), limited queue (to limit the maximum number samples stored), and limited in time (based on 'x').- Author:
- rstein
- See Also:
DataSet,DataSetError
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classLimitedIndexedTreeDataSet.DataAtom-
Nested classes/interfaces inherited from interface de.gsi.dataset.DataSetError
DataSetError.ErrorType
-
-
Field Summary
Fields Modifier and Type Field Description protected IndexedNavigableSet<LimitedIndexedTreeDataSet.DataAtom>dataprotected doublemaxLengthprotected intmaxQueueSize-
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 LimitedIndexedTreeDataSet(java.lang.String name, int maxQueueSize)Creates a new instance ofDefaultDataSet.LimitedIndexedTreeDataSet(java.lang.String name, int maxQueueSize, double maxLength)Creates a new instance ofDefaultDataSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LimitedIndexedTreeDataSetadd(double[] xValues, double[] yValues)Adds data points to this data set.LimitedIndexedTreeDataSetadd(double[] xValues, double[] yValues, double[] xErrors, double[] yErrors)Adds data points to this data set.LimitedIndexedTreeDataSetadd(double x, double y)LimitedIndexedTreeDataSetadd(double x, double y, double ex, double ey)add new pointjava.lang.StringaddDataLabel(int index, java.lang.String label)adds a custom new data label for a point The label can be used as a category name if CategoryStepsDefinition is used or for annotations displayed for data points.java.lang.StringaddDataStyle(int index, java.lang.String style)A string representation of the CSS style associated with this specificDataSetdata point.LimitedIndexedTreeDataSetclearData()remove all data pointsvoidexpire()checks X data range and removes old data points if they exceed the maximum data rangevoidexpire(double now)checks X data range and removes old data points if they exceed the maximum data rangeIndexedNavigableSet<LimitedIndexedTreeDataSet.DataAtom>getData()intgetDataCount()Get the number of data points in the data setjava.lang.StringgetDataLabel(int index)Returns label of a data point specified by the index.doublegetMaxLength()intgetMaxQueueSize()java.lang.StringgetStyle(int index)A string representation of the CSS style associated with this specificDataSetdata point.doublegetX(int i)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.doublegetY(int i)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.LimitedIndexedTreeDataSetremove(int[] indices)Removes from this data set points with specified indices.LimitedIndexedTreeDataSetremove(int fromIndex, int toIndex)remove sub-range of data pointsjava.lang.StringremoveDataLabel(int index)remove a custom data label for a point The label can be used as a category name if CategoryStepsDefinition is used or for annotations displayed for data points.java.lang.StringremoveStyle(int index)A string representation of the CSS style associated with this specificDataSetdata point.LimitedIndexedTreeDataSetreset()removes all data pointsLimitedIndexedTreeDataSetset(double[] xValues, double[] yValues)Initialises the data set with specified data.LimitedIndexedTreeDataSetset(double[] xValues, double[] yValues, double[] xErrors, double[] yErrors, int count)Initialises the data set with specified data.LimitedIndexedTreeDataSetset(double[] xValues, double[] yValues, double[] yErrors, int count)Initialises the data set with specified data.LimitedIndexedTreeDataSetset(double[] xValues, double[] yValues, int count)Initialises the data set with specified data.LimitedIndexedTreeDataSetset(int index, double x, double y)Sets the point with index to the new coordinateLimitedIndexedTreeDataSetset(int index, double x, double y, double dx, double dy)Sets the point with index to the new coordinateLimitedIndexedTreeDataSetsetMaxLength(double maxLength)LimitedIndexedTreeDataSetsetMaxQueueSize(int maxQueueSize)-
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
binarySearchX, binarySearchY, getDataCount, getDefaultDataLabel, getEditConstraints, getErrorList, getInfoList, getMetaInfo, getName, getUndefValue, getWarningList, getXIndex, getXMax, getXMin, getXRange, getYIndex, getYMax, getYMin, getYRange, isAutoNotification, minNeigbourSearchX, 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, getName, getStyle, getUndefValue, getValue, getXIndex, getXMax, getXMin, getXValues, getYIndex, getYMax, getYMin, getYValues, isAutoNotification, setAutoNotifaction, setStyle
-
Methods inherited from interface de.gsi.dataset.DataSetError
getXErrorNegative, getXErrorPositive, getXErrorsNegative, getXErrorsPositive, getYErrorNegative, getYErrorPositive, getYErrorsNegative, getYErrorsPositive
-
Methods inherited from interface de.gsi.dataset.event.EventSource
addListener, invokeListener, invokeListener, removeListener, updateEventListener
-
-
-
-
Field Detail
-
data
protected IndexedNavigableSet<LimitedIndexedTreeDataSet.DataAtom> data
-
maxQueueSize
protected int maxQueueSize
-
maxLength
protected double maxLength
-
-
Constructor Detail
-
LimitedIndexedTreeDataSet
public LimitedIndexedTreeDataSet(java.lang.String name, int maxQueueSize)Creates a new instance ofDefaultDataSet.- Parameters:
name- name of this DataSet.maxQueueSize- maximum number of samples that is being stored- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
LimitedIndexedTreeDataSet
public LimitedIndexedTreeDataSet(java.lang.String name, int maxQueueSize, double maxLength)Creates a new instance ofDefaultDataSet.- Parameters:
name- name of this DataSet.maxQueueSize- maximum number of samples that is being storedmaxLength- maximum length between first and last sample- Throws:
java.lang.IllegalArgumentException- ifnameisnull
-
-
Method Detail
-
getMaxQueueSize
public int getMaxQueueSize()
- Returns:
- maximum number of data points before points are getting dropped
-
setMaxQueueSize
public LimitedIndexedTreeDataSet setMaxQueueSize(int maxQueueSize)
- Parameters:
maxQueueSize- maximum number of data points before points are getting dropped- Returns:
- itself (fluent design)
-
getMaxLength
public double getMaxLength()
- Returns:
- maximum X range before points are getting dropped
-
setMaxLength
public LimitedIndexedTreeDataSet setMaxLength(double maxLength)
- Parameters:
maxLength- maximum X range before points are getting dropped- Returns:
- itself (fluent design)
-
reset
public LimitedIndexedTreeDataSet reset()
removes all data points- Returns:
- itself (fluent design)
-
expire
public void expire()
checks X data range and removes old data points if they exceed the maximum data range- See Also:
setMaxLength(double)
-
expire
public void expire(double now)
checks X data range and removes old data points if they exceed the maximum data range- Parameters:
now- actual time stamp to be taken as a 't0' reference- See Also:
setMaxLength(double)
-
getData
public IndexedNavigableSet<LimitedIndexedTreeDataSet.DataAtom> getData()
- Returns:
- data container
-
getDataCount
public int getDataCount()
Description copied from interface:DataSetGet the number of data points in the data set- Returns:
- the number of data points
-
getX
public double getX(int i)
Description copied from interface:DataSetGets the x value of the data point with the index i- Parameters:
i- the index of the data point- Returns:
- the x coordinate
-
getY
public double getY(int i)
Description copied from interface:DataSetGets the y value of the data point with the index i- Parameters:
i- the index of the data point- Returns:
- the y coordinate
-
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!- Parameters:
index- of negative X error to be returned.- Returns:
- the negative error of the x coordinate
- See Also:
DataSetError.getXErrorNegative(int)
-
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!- Parameters:
index- of positive X error to be returned.- Returns:
- the positive error of the x coordinate
- See Also:
DataSetError.getXErrorPositive(int)
-
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!- Parameters:
index- of negative Y error to be returned.- Returns:
- the negative error of the y coordinate
- See Also:
DataSetError.getYErrorNegative(int)
-
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!- Parameters:
index- of positive Y error to be returned.- Returns:
- the positive error of the y coordinate
- See Also:
DataSetError.getYErrorPositive(int)
-
set
public LimitedIndexedTreeDataSet set(int index, double x, double y)
Sets the point with index to the new coordinate- Parameters:
index- the point index of the data setx- the horizontal coordinate of the data pointy- the vertical coordinate of the data point- Returns:
- itself
-
clearData
public LimitedIndexedTreeDataSet clearData()
remove all data points- Returns:
- itself (fluent design)
-
set
public LimitedIndexedTreeDataSet set(int index, double x, double y, double dx, double dy)
Sets the point with index to the new coordinate- Parameters:
index- the point index of the data setx- the horizontal coordinate of the data pointy- the vertical coordinate of the data pointdx- the horizontal errordy- the vertical error N.B. assumes symmetric errors- Returns:
- itself
-
set
public LimitedIndexedTreeDataSet set(double[] xValues, double[] yValues, double[] xErrors, double[] yErrors, int count)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinatesxErrors- symmetric X coordinate errorsyErrors- symmetric Y coordinate errorscount- number of points to be taken from specified arrays.- Returns:
- itself
-
set
public LimitedIndexedTreeDataSet set(double[] xValues, double[] yValues, int count)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinatescount- number of points to be taken from specified arrays.- Returns:
- itself
-
set
public LimitedIndexedTreeDataSet set(double[] xValues, double[] yValues, double[] yErrors, int count)
Initialises the data set with specified data.
Note: The method copies values from specified double arrays.- Parameters:
xValues- X coordinatesyValues- Y coordinatesyErrors- symmetric Y coordinate errorscount- number of points to be taken from specified arrays.- Returns:
- itself
-
set
public LimitedIndexedTreeDataSet 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
-
add
public LimitedIndexedTreeDataSet add(double x, double y)
- Parameters:
x- coordinatey- coordinate- Returns:
- itself
-
add
public LimitedIndexedTreeDataSet add(double x, double y, double ex, double ey)
add new point- Parameters:
x- horizontal point coordinatey- vertical point coordinateex- horizontal point errorey- vertical point error Note: point errors are expected to be positive- Returns:
- itself
-
add
public LimitedIndexedTreeDataSet add(double[] xValues, double[] yValues)
Adds data points to this data set.
IfusingXValuesflag is set to false - array with X coordinates is not taken into account (may benull) otherwise both arrays must be non-null and have the same length.- Parameters:
xValues- X coordinatesyValues- Y coordinates- Returns:
- itself
-
add
public LimitedIndexedTreeDataSet add(double[] xValues, double[] yValues, double[] xErrors, double[] yErrors)
Adds data points to this data set.
IfusingXValuesflag is set to false - array with X coordinates is not taken into account (may benull) otherwise both arrays must be non-null and have the same length.- Parameters:
xValues- X coordinatesyValues- Y coordinatesxErrors- horizontal errorsyErrors- vertical errors- Returns:
- itself
-
remove
public LimitedIndexedTreeDataSet remove(int fromIndex, int toIndex)
remove sub-range of data points- Parameters:
fromIndex- starting indextoIndex- stopping index- Returns:
- itself (fluent design)
-
remove
public LimitedIndexedTreeDataSet remove(int[] indices)
Removes from this data set points with specified indices.- Parameters:
indices- array of indicices to be removed- Returns:
- itself
-
addDataLabel
public java.lang.String addDataLabel(int index, java.lang.String label)adds a custom new data label for a point The label can be used as a category name if CategoryStepsDefinition is used or for annotations displayed for data points.- Overrides:
addDataLabelin classAbstractDataSet<LimitedIndexedTreeDataSet>- Parameters:
index- of the data pointlabel- for the data point specified by the index- Returns:
- the previously set label or
nullif no label has been specified
-
removeDataLabel
public java.lang.String removeDataLabel(int index)
remove a custom data label for a point The label can be used as a category name if CategoryStepsDefinition is used or for annotations displayed for data points.- Overrides:
removeDataLabelin classAbstractDataSet<LimitedIndexedTreeDataSet>- Parameters:
index- of the data point- Returns:
- the previously set label or
nullif no label has been specified
-
getDataLabel
public java.lang.String getDataLabel(int index)
Returns label of a data point specified by the index. The label can be used as a category name if CategoryStepsDefinition is used or for annotations displayed for data points.- Specified by:
getDataLabelin interfaceDataSet- Overrides:
getDataLabelin classAbstractDataSet<LimitedIndexedTreeDataSet>- Parameters:
index- of the data label- Returns:
- data point label specified by the index or
nullif no label has been specified
-
addDataStyle
public java.lang.String addDataStyle(int index, java.lang.String style)A string representation of the CSS style associated with this specificDataSetdata point. @see #getStyle()- Overrides:
addDataStylein classAbstractDataSet<LimitedIndexedTreeDataSet>- Parameters:
index- the index of the specific data pointstyle- data point CSS-style- Returns:
- the previously set style or
nullif no label has been specified
-
removeStyle
public java.lang.String removeStyle(int index)
A string representation of the CSS style associated with this specificDataSetdata point. @see #getStyle()- Overrides:
removeStylein classAbstractDataSet<LimitedIndexedTreeDataSet>- Parameters:
index- the index of the specific data point- Returns:
- the previously set style or
nullif no label has been specified
-
getStyle
public java.lang.String getStyle(int index)
A string representation of the CSS style associated with this specificDataSetdata point. @see #getStyle()- Specified by:
getStylein interfaceDataSet- Overrides:
getStylein classAbstractDataSet<LimitedIndexedTreeDataSet>- Parameters:
index- the index of the specific data point- Returns:
- user-specific data set style description (ie. may be set by user)
-
-