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 classCircularBufferDataProvider.PlotModestatic classCircularBufferDataProvider.UpdateMode
-
Field Summary
Fields Modifier and Type Field Description private booleanconcatenate_dataprivate doublecurrentXDataprivate double[]currentXDataArrayprivate booleancurrentXDataArrayChangedprivate booleancurrentXDataChangedprivate doublecurrentYDataprivate double[]currentYDataArrayprivate booleancurrentYDataArrayChangedprivate booleancurrentYDataChangedprivate longcurrentYDataTimestampprivate booleanduringDelayprivate java.lang.RunnablefireUpdateprivate CircularBufferDataProvider.PlotModeplotModeprivate CircularBuffer<ISample>traceDataprivate intupdateDelayprivate CircularBufferDataProvider.UpdateModeupdateModeprivate booleanxAxisDateEnabled-
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 voidaddDataArray()add a new data point to trace data.private voidaddDataPoint()add a new data point to trace data.voidaddSample(ISample sample)voidclearTrace()Clear all data on in the data provider.protected voidfireDataChange()a data change has occuredISamplegetSample(int index)Get sample by indexintgetSize()Total number of samples.CircularBufferDataProvider.UpdateModegetUpdateMode()booleanisConcatenate_data()java.util.Iterator<ISample>iterator()voidsetBufferSize(int bufferSize)voidsetConcatenate_data(boolean concatenate_data)voidsetCurrentXData(double newValue)voidsetCurrentXDataArray(double[] newValue)voidsetCurrentYData(double newValue)Set current YData.voidsetCurrentYData(double newValue, long timestamp)Set current YData and its timestamp when the new value generated.voidsetCurrentYDataArray(double[] newValue)voidsetCurrentYDataTimestamp(long timestamp)Set the time stamp of currrent YDatavoidsetPlotMode(CircularBufferDataProvider.PlotMode plotMode)voidsetUpdateDelay(int updateDelay)voidsetUpdateMode(CircularBufferDataProvider.UpdateMode updateMode)voidsetXAxisDateEnabled(boolean xAxisDateEnabled)If xAxisDateEnable is true, you will need to usesetCurrentYData(double, long)orsetCurrentYDataTimestamp(long)to set the time stamp of ydata.voidtriggerUpdate()In TRIGGER update mode, the trace data could be updated by this methodprivate voidtryToAddDataArray()Try to add a new data array to trace data.private voidtryToAddDataPoint()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:IDataProviderGet sample by indexSynchronization: Since the data might change dynamically,
synchronizeon theIDataProvideraround calls togetSize()andgetSample().- Specified by:
getSamplein interfaceIDataProvider- Specified by:
getSamplein classAbstractDataProvider- Parameters:
index- Sample index, 0...getSize()-1- Returns:
- the ISample element at the given index
-
getSize
public int getSize()
Description copied from interface:IDataProviderTotal number of samples.- Specified by:
getSizein interfaceIDataProvider- Specified by:
getSizein 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:AbstractDataProvidera data change has occured- Overrides:
fireDataChangein classAbstractDataProvider
-
setConcatenate_data
public void setConcatenate_data(boolean concatenate_data)
-
isConcatenate_data
public boolean isConcatenate_data()
-
-