Package de.gsi.dataset.spi
Class AbstractDataSet<D extends AbstractStylable<D>>
- java.lang.Object
-
- de.gsi.dataset.spi.AbstractStylable<D>
-
- de.gsi.dataset.spi.AbstractDataSet<D>
-
- Type Parameters:
D- java generics handling of DataSet for derived classes (needed for fluent design)
- All Implemented Interfaces:
DataSet,DataSetMetaData,EventSource
- Direct Known Subclasses:
AbstractDataSet3D,AbstractErrorDataSet,AveragingDataSet,DoubleDataSet,FloatDataSet,FragmentedDataSet,LabelledMarkerDataSet,ListDataSet,WrappedDataSet
public abstract class AbstractDataSet<D extends AbstractStylable<D>> extends AbstractStylable<D> implements DataSet, DataSetMetaData
The abstract implementation of DataSet interface that provides implementation of some methods.
- It maintains the name of the DataSet
- It maintains a list of DataSetListener objects and provides methods that can be used to dispatch DataSetEvent events.
- It maintains ranges of X and Y values.
- It gives a possibility to specify an undefined value.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Integer,java.lang.String>dataLabelsprotected java.util.Map<java.lang.Integer,java.lang.String>dataStylesprotected EditConstraintseditConstraintsprotected java.util.concurrent.locks.ReentrantLocklockprotected java.util.Map<java.lang.String,java.lang.String>metaInfoMapprotected java.lang.Stringnameprotected java.util.List<EventListener>updateListenersprotected DataRangexRangeprotected DataRangeyRange-
Fields inherited from interface de.gsi.dataset.DataSetMetaData
TAG_GAIN_RANGE, TAG_OVERSHOOT, TAG_UNDERSHOOT
-
-
Constructor Summary
Constructors Constructor Description AbstractDataSet(java.lang.String name)default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.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.protected intbinarySearchX(double search, int indexMin, int indexMax)protected intbinarySearchY(double search, int indexMin, int indexMax)protected DcomputeLimits()Computes limits (ranges) of this DataSet.DfireInvalidated(UpdateEvent event)Notifies listeners that the data has been invalidated.intgetDataCount(double xmin, double xmax)Gets the number of data points in the range xmin to xmax.java.lang.StringgetDataLabel(int index)Returns label of a data point specified by the index.protected java.lang.StringgetDefaultDataLabel(int index)Returns label of a data point specified by the index.EditConstraintsgetEditConstraints()java.util.List<java.lang.String>getErrorList()java.util.List<java.lang.String>getInfoList()java.util.Map<java.lang.String,java.lang.String>getMetaInfo()java.lang.StringgetName()Gets the name of the data set.java.lang.StringgetStyle(int index)A string representation of the CSS style associated with this specificDataSetdata point.protected DgetThis()java.lang.DoublegetUndefValue()Returns the value for undefined data points.java.util.List<java.lang.String>getWarningList()intgetXIndex(double x)Gets the index of the data point closest to the given x coordinate.doublegetXMax()Gets the maximum x value of the data set.doublegetXMin()Gets the minimum x value of the data set.DataRangegetXRange()intgetYIndex(double y)Gets the first index of the data point closest to the given y coordinate.doublegetYMax()Gets the maximum y value of the data set.doublegetYMin()Gets the minimum y value of the data set.DataRangegetYRange()booleanisAutoNotification()Checks it automatic notification is enabled.Dlock()Locks access to the data set.protected intminNeigbourSearchX(double search, int indexMin, int indexMax)java.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.DsetAutoNotifaction(boolean flag)Set the automatic notification of invalidation listeners.DsetEditConstraints(EditConstraints constraints)DsetName(java.lang.String name)Sets the name of data set (meta data)java.lang.StringtoString()Dunlock()Unlock the data set.java.util.List<EventListener>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, getStyle, getValue, getX, getXValues, getY, getYValues, setStyle
-
Methods inherited from interface de.gsi.dataset.event.EventSource
addListener, invokeListener, invokeListener, removeListener
-
-
-
-
Field Detail
-
name
protected java.lang.String name
-
updateListeners
protected final java.util.List<EventListener> updateListeners
-
lock
protected final java.util.concurrent.locks.ReentrantLock lock
-
xRange
protected DataRange xRange
-
yRange
protected DataRange yRange
-
dataLabels
protected java.util.Map<java.lang.Integer,java.lang.String> dataLabels
-
dataStyles
protected java.util.Map<java.lang.Integer,java.lang.String> dataStyles
-
editConstraints
protected EditConstraints editConstraints
-
metaInfoMap
protected final java.util.Map<java.lang.String,java.lang.String> metaInfoMap
-
-
Method Detail
-
getThis
protected D getThis()
- Overrides:
getThisin classAbstractStylable<D extends AbstractStylable<D>>
-
setName
public D setName(java.lang.String name)
Sets the name of data set (meta data)- Parameters:
name- the new name- Returns:
- itself (fluent design)
-
getName
public java.lang.String getName()
Description copied from interface:DataSetGets the name of the data set.
-
lock
public D lock()
Description copied from interface:DataSetLocks access to the data set. Multi-threaded applications should lock the data set before setting the data.
-
updateEventListener
public java.util.List<EventListener> updateEventListener()
- Specified by:
updateEventListenerin interfaceEventSource- Returns:
- list containing all update event listener (needs to be provided by implementing class)
-
setAutoNotifaction
public D setAutoNotifaction(boolean flag)
Description copied from interface:DataSetSet the automatic notification of invalidation listeners. In general, data sets should notify registered invalidation listeners, if the data in the data set has changed. Charts usually register an invalidation listener with the data set to be notified of any changes and update the charts. Setting the automatic notification to false, allows applications to prevent this behaviour, in case data sets are updated multiple times during an acquisition cycle but the chart update is only required at the end of the cycle.- Specified by:
setAutoNotifactionin interfaceDataSet- Parameters:
flag- true for automatic notification- Returns:
- itself (fluent interface)
-
isAutoNotification
public boolean isAutoNotification()
Description copied from interface:DataSetChecks it automatic notification is enabled.- Specified by:
isAutoNotificationin interfaceDataSet- Returns:
- true if automatic notification is enabled
-
getUndefValue
public java.lang.Double getUndefValue()
Description copied from interface:DataSetReturns the value for undefined data points.- Specified by:
getUndefValuein interfaceDataSet- Returns:
- the value indicating undefined data points
-
getXMin
public double getXMin()
Gets the minimum x value of the data set.
-
getXMax
public double getXMax()
Gets the maximum x value of the data set.
-
getYMin
public double getYMin()
Gets the minimum y value of the data set.
-
getYMax
public double getYMax()
Gets the maximum y value of the data set.
-
getXRange
public DataRange getXRange()
- Returns:
- horizontal range of data set
-
getYRange
public DataRange getYRange()
- Returns:
- vertical range of data set
-
computeLimits
protected D computeLimits()
Computes limits (ranges) of this DataSet.- Returns:
- itself (fluent design)
-
getDataCount
public int getDataCount(double xmin, double xmax)Gets the number of data points in the range xmin to xmax.- Specified by:
getDataCountin interfaceDataSet- Parameters:
xmin- the lower end of the rangexmax- the upper end of the range- Returns:
- the number of data points
-
getXIndex
public int getXIndex(double x)
Gets the index of the data point closest to the given x coordinate. The index returned may be less then zero or larger the the number of data points in the data set, if the x coordinate lies outside the range of the data set.
-
getYIndex
public int getYIndex(double y)
Gets the first index of the data point closest to the given y coordinate.
-
binarySearchX
protected int binarySearchX(double search, int indexMin, int indexMax)
-
binarySearchY
protected int binarySearchY(double search, int indexMin, int indexMax)
-
minNeigbourSearchX
protected int minNeigbourSearchX(double search, int indexMin, int indexMax)
-
fireInvalidated
public D fireInvalidated(UpdateEvent event)
Notifies listeners that the data has been invalidated. If the data is added to the chart, it triggers repaint.- Parameters:
event- the change event- Returns:
- itself (fluent design)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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.- 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.- Parameters:
index- of the data point- Returns:
- the previously set label or
nullif no label has been specified
-
getDefaultDataLabel
protected java.lang.String getDefaultDataLabel(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.- Parameters:
index- data point index- Returns:
- label of a data point specified by the index or
nullif none label has been specified for this data point.
-
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- 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()- Parameters:
index- the index of the specific data pointstyle- string for the data point specific CSS-styling- Returns:
- itself (fluent interface)
-
removeStyle
public java.lang.String removeStyle(int index)
A string representation of the CSS style associated with this specificDataSetdata point. @see #getStyle()- Parameters:
index- the index of the specific data point- Returns:
- itself (fluent interface)
-
getStyle
public java.lang.String getStyle(int index)
A string representation of the CSS style associated with this specificDataSetdata point. @see #getStyle()
-
getEditConstraints
public EditConstraints getEditConstraints()
-
setEditConstraints
public D setEditConstraints(EditConstraints constraints)
-
getMetaInfo
public java.util.Map<java.lang.String,java.lang.String> getMetaInfo()
- Specified by:
getMetaInfoin interfaceDataSetMetaData
-
getInfoList
public java.util.List<java.lang.String> getInfoList()
- Specified by:
getInfoListin interfaceDataSetMetaData
-
getWarningList
public java.util.List<java.lang.String> getWarningList()
- Specified by:
getWarningListin interfaceDataSetMetaData
-
getErrorList
public java.util.List<java.lang.String> getErrorList()
- Specified by:
getErrorListin interfaceDataSetMetaData
-
-