Interface IDataProvider
- All Known Implementing Classes:
AbstractDataProvider
,CircularBufferDataProvider
,ClippedCircularBufferDataProvider
public interface IDataProvider
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 Graph
synchronizes
on the IDataProvider
like 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 the
IDataProvider
should likewise synchronize
on it whenever the data is changed, and other methods like
getXDataMinMax
should probably be synchronized implementations.-
Method Summary
Modifier and Type Method Description void
addDataProviderListener(IDataProviderListener listener)
ISample
getSample(int index)
Get sample by indexint
getSize()
Total number of samples.Range
getXDataMinMax()
Get the minimum and maximum xdata.Range
getXDataMinMax(boolean positiveOnly)
Get the minimum and maximum xdata.Range
getYDataMinMax()
Get the minimum and maximum ydata.Range
getYDataMinMax(boolean positiveOnly)
Get the minimum and maximum ydata.default boolean
hasErrors()
This method is optional to implement.boolean
isChronological()
boolean
removeDataProviderListener(IDataProviderListener listener)
-
Method Details
-
getSize
int getSize()Total number of samples.- Returns:
- the size.
- See Also:
getSample(int)
-
getSample
Get sample by indexSynchronization: Since the data might change dynamically,
synchronize
on theIDataProvider
around 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
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
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:
true
if data is ascending sorted on X axis; false otherwise
-
addDataProviderListener
- Parameters:
listener
- New listener to notify when data changes
-
removeDataProviderListener
- Parameters:
listener
- Listener to no longer notify when data changes- Returns:
true
if listener was known and removed
-
hasErrors
default boolean hasErrors()This method is optional to implement. It should return whether anISample
has errors or not.- Returns:
true
if the ISample have error information.
-