I have some kind of drawpane, where the user can draw different kinds of Shapes, like Pathes, Rectangles, Texts, etc. Now I´d like to persist the DrawState, so that I can recreate it at any time.
I just tried it with xstream, but like usual I get a whole lot of dependencies within these Shapes when persisting it in XML. After some research I found this Thread here:
I liked the idea of jewelsea using the SceneBuilder API to serialize my shapes, since they are all supported and the FXML contains all the things I probably will need without any disturbing references.
Do you have any experiences with the Scenebuilder API? In the thread its pointed out, that it might be difficult to get only the things needed. Or can you maybe recommend any other way to serialize Shapes in XML?
Using annotations to describe what data to save, JAXB makes it very simple to save/load objects to/from XML.
You'll probably want to create template objects for each JavaFX object so you can control what data you are storing. Here's a tutorial on using JAXB.
This might come a bit late, but if you use XStream, note that we shared a collection of Converters for JavaFX types: see https://github.com/dooApp/XStreamFX