The MindFusion Forums
Flow Diagramming Components >> Java Swing >> Is it possible to call Diagram.saveToXml(Document) without the displayed Diagram updating
https://mindfusion.eu/Forum/YaBB.pl?num=1491413707

Message started by AR on Apr 5th, 2017 at 5:35pm

Title: Is it possible to call Diagram.saveToXml(Document) without the displayed Diagram updating
Post by AR on Apr 5th, 2017 at 5:35pm
In our system users can make changes to the diagram at will - adding nodes and links and moving both within the diagram.

We automatically save the diagram, in the background, after each change, then reload the saved diagram (so we get ids for nodes etc. to use when adding links)

However, if a large background image (4.5 megabytes) is used for the diagram this save takes some time and the user can make changes whilst the save is taking place which then 'disappear' when the diagram is reloaded.

A possible solution would appear to be to remove the background image from the diagram before saving it, then put it back after the save. However, this causes the diagram to be displayed with a blank background for a significant period of time. From stepping through my code it seems to be the call to Diagram.saveToXml(document) which causes the 'backgroundless' diagram to be displayed.

Is there anyway of stopping this happening?

Or can you think of an alternative method which would allow saving all changes in the background, but would not 'loose' any changes made by the user during the time taken for the save.

Title: Re: Is it possible to call Diagram.saveToXml(Document) without the displayed Diagram updating
Post by Slavcho on Apr 5th, 2017 at 6:11pm
There are suspendRepaint and resumeRepaint methods in DiagramView. Saving and loading after each change just to get integer identifiers is an overkill. If you have the code, make Diagram.updateRuntimeIndices public and call it when you need the numbers - they will be accessible via DiagramItem.getRuntimeIndex(). We'll make that public in official release soon. Also note that the identifiers used in XML are not permanent for items, they could change between different saves, e.g. if you delete an item.

Title: Re: Is it possible to call Diagram.saveToXml(Document) without the displayed Diagram updating
Post by AR on Apr 7th, 2017 at 1:10pm
Could you let me know when you make the official release with Diagram.updateRuntimeIndices() as a public method please.

(We're only using these values very short term, not assuming they remain the same long term)

Title: Re: Is it possible to call Diagram.saveToXml(Document) without the displayed Diagram updating
Post by Slavcho on Apr 10th, 2017 at 12:59pm
You can find a pre-release build here -
https://mindfusion.eu/_beta/jdiag_rtidx.zip

Official release should be available in a couple of weeks. There are some API changes: Pen, Brush and derived classes are now in the com.mindfusion.drawing package.

Regards,
Slavcho
Mindfusion

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.