我认为这是非常基本的,但我找不到解决方案。我有这样的事情:
public SimpleXYSeries historySeries;
historySeries = new SimpleXYSeries("something");
然后在后台线程中,我向该系列添加了一些数据:
historySeries.addLast(newRoll, newAzimuth);
问题是,我怎样才能在需要时轻松地从系列中删除所有数据条目?
现在我有类似的东西:
public void initSeries() {
historyPlot.removeSeries(historySeries);
historySeries = null;
historyPlot.clear();
historySeries = new SimpleXYSeries("something");
historyPlot.addSeries(historySeries, lpf);
}
它可以工作,但是当我再次执行 addSeries 时,图形会闪烁。
编辑:
我通过制作自己的 SimpleXYSeries 版本解决了这个问题,并添加了一个方法:
public void removeXY() {
lock.writeLock().lock();
try {
xVals.clear();
yVals.clear();
} finally {
lock.writeLock().unlock();
}
}