Interface IDataProvider
-
- All Known Implementing Classes:
AbstractDataProvider
,CircularBufferDataProvider
,ClippedCircularBufferDataProvider
public interface IDataProvider
Interface 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 Graphsynchronizes
on theIDataProvider
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 theIDataProvider
should likewise synchronize on it whenever the data is changed, and other methods likegetXDataMinMax
should probably be synchronized implementations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods 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 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,
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
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:
true
if 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:
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.
-
-