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