2

我认为这是非常基本的,但我找不到解决方案。我有这样的事情:

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();
        }
    }
4

2 回答 2

0

我一直使用 clear() 来删除绘图并且从未出现过图形闪烁。您是在模拟器上还是在真实设备上尝试这个?

我还找到了这些方法:

historyPlot.getSeriesSet.removeAll(historySeries);
historyPlot.removeMarkers();

我不确定闪烁是否会更好

于 2013-10-03T20:10:02.487 回答
0

奇怪的是没有内置函数clear()或函数。正如您已经提到的,最好的解决方法是修改源代码以添加该功能。但是,对于那些不愿意这样做的人,您可以调用直到从系列中删除所有条目。到目前为止,它对我来说工作正常。removeAll()SimpleXYSeriesremoveLast()

while (series.size() > 0) {
    series.removeLast();
}
于 2016-06-03T03:55:18.467 回答