Class CircularBufferDataProvider
- java.lang.Object
-
- org.eclipse.nebula.visualization.xygraph.dataprovider.AbstractDataProvider
-
- org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider
-
- All Implemented Interfaces:
IDataProvider
- Direct Known Subclasses:
ClippedCircularBufferDataProvider
public class CircularBufferDataProvider extends AbstractDataProvider
Provides data to a trace.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CircularBufferDataProvider.PlotMode
static class
CircularBufferDataProvider.UpdateMode
-
Field Summary
Fields Modifier and Type Field Description private boolean
concatenate_data
private double
currentXData
private double[]
currentXDataArray
private boolean
currentXDataArrayChanged
private boolean
currentXDataChanged
private double
currentYData
private double[]
currentYDataArray
private boolean
currentYDataArrayChanged
private boolean
currentYDataChanged
private long
currentYDataTimestamp
private boolean
duringDelay
private java.lang.Runnable
fireUpdate
private CircularBufferDataProvider.PlotMode
plotMode
private CircularBuffer<ISample>
traceData
private int
updateDelay
private CircularBufferDataProvider.UpdateMode
updateMode
private boolean
xAxisDateEnabled
-
Fields inherited from class org.eclipse.nebula.visualization.xygraph.dataprovider.AbstractDataProvider
chronological, listeners, xDataMinMax, yDataMinMax
-
-
Constructor Summary
Constructors Constructor Description CircularBufferDataProvider(boolean chronological)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addDataArray()
add a new data point to trace data.private void
addDataPoint()
add a new data point to trace data.void
addSample(ISample sample)
void
clearTrace()
Clear all data on in the data provider.protected void
fireDataChange()
a data change has occuredISample
getSample(int index)
Get sample by indexint
getSize()
Total number of samples.CircularBufferDataProvider.UpdateMode
getUpdateMode()
boolean
isConcatenate_data()
java.util.Iterator<ISample>
iterator()
void
setBufferSize(int bufferSize)
void
setConcatenate_data(boolean concatenate_data)
void
setCurrentXData(double newValue)
void
setCurrentXDataArray(double[] newValue)
void
setCurrentYData(double newValue)
Set current YData.void
setCurrentYData(double newValue, long timestamp)
Set current YData and its timestamp when the new value generated.void
setCurrentYDataArray(double[] newValue)
void
setCurrentYDataTimestamp(long timestamp)
Set the time stamp of currrent YDatavoid
setPlotMode(CircularBufferDataProvider.PlotMode plotMode)
void
setUpdateDelay(int updateDelay)
void
setUpdateMode(CircularBufferDataProvider.UpdateMode updateMode)
void
setXAxisDateEnabled(boolean xAxisDateEnabled)
If xAxisDateEnable is true, you will need to usesetCurrentYData(double, long)
orsetCurrentYDataTimestamp(long)
to set the time stamp of ydata.void
triggerUpdate()
In TRIGGER update mode, the trace data could be updated by this methodprivate void
tryToAddDataArray()
Try to add a new data array to trace data.private void
tryToAddDataPoint()
Try to add a new data point to trace data.-
Methods inherited from class org.eclipse.nebula.visualization.xygraph.dataprovider.AbstractDataProvider
addDataProviderListener, getDataRange, getDataRange, getXDataMinMax, getXDataMinMax, getYDataMinMax, getYDataMinMax, isChronological, removeDataProviderListener, setChronological
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.nebula.visualization.xygraph.dataprovider.IDataProvider
hasErrors
-
-
-
-
Field Detail
-
traceData
private CircularBuffer<ISample> traceData
-
currentXData
private double currentXData
-
currentYData
private double currentYData
-
currentYDataTimestamp
private long currentYDataTimestamp
-
currentXDataChanged
private boolean currentXDataChanged
-
currentYDataChanged
private boolean currentYDataChanged
-
currentXDataArray
private double[] currentXDataArray
-
currentYDataArray
private double[] currentYDataArray
-
currentXDataArrayChanged
private boolean currentXDataArrayChanged
-
currentYDataArrayChanged
private boolean currentYDataArrayChanged
-
xAxisDateEnabled
private boolean xAxisDateEnabled
-
updateDelay
private int updateDelay
-
duringDelay
private boolean duringDelay
-
concatenate_data
private boolean concatenate_data
-
updateMode
private CircularBufferDataProvider.UpdateMode updateMode
-
plotMode
private CircularBufferDataProvider.PlotMode plotMode
-
fireUpdate
private java.lang.Runnable fireUpdate
-
-
Method Detail
-
setCurrentXData
public void setCurrentXData(double newValue)
- Parameters:
currentXData
- the currentXData to set
-
setCurrentYData
public void setCurrentYData(double newValue)
Set current YData. It will automatically make timestamp disabled.- Parameters:
currentYData
- the currentYData to set
-
addSample
public void addSample(ISample sample)
-
setCurrentYDataTimestamp
public void setCurrentYDataTimestamp(long timestamp)
Set the time stamp of currrent YData- Parameters:
timestamp
- timestamp of Y data in milliseconds.
-
setCurrentYData
public void setCurrentYData(double newValue, long timestamp)
Set current YData and its timestamp when the new value generated.- Parameters:
currentYData
- the currentYData to settimestamp
- timestamp of Y data in milliseconds.
-
tryToAddDataPoint
private void tryToAddDataPoint()
Try to add a new data point to trace data. Whether it will be added or not is up to the update mode.
-
addDataPoint
private void addDataPoint()
add a new data point to trace data.
-
setCurrentXDataArray
public void setCurrentXDataArray(double[] newValue)
- Parameters:
currentXData
- the currentXData to set
-
setCurrentYDataArray
public void setCurrentYDataArray(double[] newValue)
- Parameters:
currentXData
- the currentXData to set
-
tryToAddDataArray
private void tryToAddDataArray()
Try to add a new data array to trace data. Whether it will be added or not is up to the update mode.
-
addDataArray
private void addDataArray()
add a new data point to trace data.
-
clearTrace
public void clearTrace()
Clear all data on in the data provider.
-
iterator
public java.util.Iterator<ISample> iterator()
-
setBufferSize
public void setBufferSize(int bufferSize)
- Parameters:
bufferSize
- the bufferSize to set
-
setUpdateMode
public void setUpdateMode(CircularBufferDataProvider.UpdateMode updateMode)
- Parameters:
updateMode
- the updateMode to set
-
getUpdateMode
public CircularBufferDataProvider.UpdateMode getUpdateMode()
- Returns:
- the update mode.
-
triggerUpdate
public void triggerUpdate()
In TRIGGER update mode, the trace data could be updated by this method- Parameters:
triggerValue
- the triggerValue to set
-
setPlotMode
public void setPlotMode(CircularBufferDataProvider.PlotMode plotMode)
- Parameters:
plotMode
- the plotMode to set
-
getSample
public ISample getSample(int index)
Description copied from interface:IDataProvider
Get sample by indexSynchronization: Since the data might change dynamically,
synchronize
on theIDataProvider
around calls togetSize()
andgetSample()
.- Specified by:
getSample
in interfaceIDataProvider
- Specified by:
getSample
in classAbstractDataProvider
- Parameters:
index
- Sample index, 0...getSize()-1
- Returns:
- the ISample element at the given index
-
getSize
public int getSize()
Description copied from interface:IDataProvider
Total number of samples.- Specified by:
getSize
in interfaceIDataProvider
- Specified by:
getSize
in classAbstractDataProvider
- Returns:
- size
- See Also:
IDataProvider.getSample(int)
-
setXAxisDateEnabled
public void setXAxisDateEnabled(boolean xAxisDateEnabled)
If xAxisDateEnable is true, you will need to usesetCurrentYData(double, long)
orsetCurrentYDataTimestamp(long)
to set the time stamp of ydata. This flag will be automatically enabled when either of these two methods were called. The default value is false.- Parameters:
xAxisDateEnabled
- the xAxisDateEnabled to set
-
setUpdateDelay
public void setUpdateDelay(int updateDelay)
- Parameters:
updateDelay
- Delay in milliseconds between plot updates. This may help to reduce CPU usage. The default value is 0ms.
-
fireDataChange
protected void fireDataChange()
Description copied from class:AbstractDataProvider
a data change has occured- Overrides:
fireDataChange
in classAbstractDataProvider
-
setConcatenate_data
public void setConcatenate_data(boolean concatenate_data)
-
isConcatenate_data
public boolean isConcatenate_data()
-
-