Is it possible to use the memento pattern for undo operation in JFreeChart?
If it's possible please give me some examples of it.
Yes, the memento pattern can be used with JFreeChart
. This typical example manages a String
, but your Memento
class would contain a suitable concrete implementation of your chosen Dataset
. An instance of that dataset would be held by your Originator
. Your Caretaker
would then contain a List<Originator.Memento>
. Your implementation of Originator::set
and Originator::restoreFromMemento
can use setDataset()
, as shown here , to set the chart's current dataset or restore the chart to any previously saved state. For convenience, many implementations of Dataset
implement Cloneable
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.