Reputation: 89
I'm currently developing a drawing application in JavaFX for fun. I currently working on saving the contents of the drawing panel to an image. All the nodes that should be saved in that image are children of one Group. I want to use the scene snapshot method, but my problem is that I don't want to snapshot the whole scene...
Creating a new scene with the shapes group is obviously not an option since a group can only be part of one scenegraph at a time. Thus, I need a way to duplicate all the children of the shapes group in order to create a new scene that I can snapshot... Is there anyway to do this? Should I subclass the Group class and create a clone method or something? I don't really know how to proceed...
Upvotes: 1
Views: 2034
Reputation: 159486
Sounds like what you want to do is snapshot a group. In which case, use the Node snapshot method instead of the scene snapshot method. You don't need to clone a scene graph node tree just to get a snapshot of it.
Upvotes: 2
Reputation: 89
I thought of something... I used a CustomShape class that extended Group, and gave it an abstract method getShapeCopy. I made this method return a Rectangle (JavaFX node) for the CustomRectangle class, etc. This works perfectly!
Upvotes: 0