Interface IDataProvider
-
- All Known Implementing Classes:
AbstractDataProvider,CircularBufferDataProvider,ClippedCircularBufferDataProvider
public interface IDataProviderInterface for the data provider of trace. This gives the possibilities to implement different data provider, which could have different data source or data storage structure. For example: the data source could be from user input, database, files, etc,. The storage structure could be array, queue, circular buffer, bucket buffer, etc,.An API like
public ISample[] getSamples()would be much easier to use by the XY Graph, but it forces the data provider to copy its samples into an array, which might be a performance and memory problem if considerable amounts of data are held in some other data structure that is more suitable to the application.The API is therefore based on single-sample access, allowing the application to store the samples in arbitrary data structures.
Synchronization
Since the application data might change dynamically, the XY Graphsynchronizeson theIDataProviderlike this to assert that the sample count does not change while accessing individual samples:IDataProvider data = ...; synchronized (data) { int count = data.getSize(); ... ... getSample(i) ... }Implementations of theIDataProvidershould likewise synchronize on it whenever the data is changed, and other methods likegetXDataMinMaxshould probably be synchronized implementations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddDataProviderListener(IDataProviderListener listener)ISamplegetSample(int index)Get sample by indexintgetSize()Total number of samples.RangegetXDataMinMax()Get the minimum and maximum xdata.RangegetXDataMinMax(boolean positiveOnly)Get the minimum and maximum xdata.RangegetYDataMinMax()Get the minimum and maximum ydata.RangegetYDataMinMax(boolean positiveOnly)Get the minimum and maximum ydata.default booleanhasErrors()This method is optional to implement.booleanisChronological()booleanremoveDataProviderListener(IDataProviderListener listener)
-
-
-
Method Detail
-
getSize
int getSize()
Total number of samples.- Returns:
- the size.
- See Also:
getSample(int)
-
getSample
ISample getSample(int index)
Get sample by indexSynchronization: Since the data might change dynamically,
synchronizeon theIDataProvideraround calls togetSize()andgetSample().- Parameters:
index- Sample index, 0...getSize()-1- Returns:
- the sample.
-
getXDataMinMax
Range getXDataMinMax()
Get the minimum and maximum xdata.- Returns:
- a range includes the min and max as lower and upper. return null if there is no data.
-
getYDataMinMax
Range getYDataMinMax()
Get the minimum and maximum ydata.- Returns:
- a range includes the min and max as lower and upper. return null if there is no data.
-
getXDataMinMax
Range getXDataMinMax(boolean positiveOnly)
Get the minimum and maximum xdata.- Parameters:
positiveOnly- if true, return values greater than zero- Returns:
- a range includes the min and max as lower and upper. return null if there is no data.
-
getYDataMinMax
Range getYDataMinMax(boolean positiveOnly)
Get the minimum and maximum ydata.- Parameters:
positiveOnly- if true, return values greater than zero- Returns:
- a range includes the min and max as lower and upper. return null if there is no data.
-
isChronological
boolean isChronological()
- Returns:
trueif data is ascending sorted on X axis; false otherwise
-
addDataProviderListener
void addDataProviderListener(IDataProviderListener listener)
- Parameters:
listener- New listener to notify when data changes
-
removeDataProviderListener
boolean removeDataProviderListener(IDataProviderListener listener)
- Parameters:
listener- Listener to no longer notify when data changes- Returns:
trueif listener was known and removed
-
hasErrors
default boolean hasErrors()
This method is optional to implement. It should return whether anISamplehas errors or not.- Returns:
trueif the ISample have error information.
-
-