我使用 DatasetChangeListener
来监视某些 XYSeriesCollection
的修改,因为一个系列中的更改必须反映到我的应用程序图表的其他系列中。
public void datasetChanged(DatasetChangeEvent arg0) {
XYSeriesCollection d = (XYSeriesCollection)arg0.getDataset();
System.out.println(d.getGroup().getID());
}
我使用 DatasetGroup
来存储唯一标识数据集的字符串。
现在的重点是,我只想知道发生更改的数据集的单个条目,否则我将被迫迭代所有数据集并检查所有数据。有什么办法可以做到这一点吗?
例如,我想知道集合中的系列 1 在第三个元素的 y 值上发生了更改。这可能吗?
I'm using a DatasetChangeListener
to monitor the modification of some XYSeriesCollection
because a change in one series must be reflected to other series of my application's charts.
public void datasetChanged(DatasetChangeEvent arg0) {
XYSeriesCollection d = (XYSeriesCollection)arg0.getDataset();
System.out.println(d.getGroup().getID());
}
I'm using DatasetGroup
to store a string that uniquely identify the dataset.
Now the point is, I would like to know only the single entry of the dataset on which the changed occured, otherwise I am forced to iterate through all the dataset and inspect all datas. Is there any way to do that?
For example I would like to know that a changed occured for the series 1 in the collection, on the y value of the third element. Is that possible?
发布评论
评论(2)
数据集 rel="nofollow">
getDataset()
在这种情况下可能没有用。相反,请查看的来源SeriesChangeEvent
。您可能必须重写XYSeries
跟踪更改详细信息。The
Dataset
returned bygetDataset()
is probably not useful in this context. Instead, look at the source of aSeriesChangeEvent
. You'll probably have to override one or more of theadd()
methods in a subclass ofXYSeries
to track the change details.我使用 SeriesChangeListener 部分解决了问题,并向每个系列添加了描述字符串,但我仍然需要检查系列内的所有值。
这是比使用 DatasetChangeListener 更好的解决方案(我不需要检查数据集中所有系列的所有值),但它并不完美。
I partially solved using SeriesChangeListener and adding a description String to each serie, but I still need to inspect all the values inside the serie.
It's a better solution than using a DatasetChangeListener (I don't need to inspect all values of all series in the dataset) but it's not perfect.