Clear Filters
Clear Filters

Save figure with java graphic object

1 view (last 30 days)
Is there a way how to save a figure to a *.fig file with all included java objects? When you add a java object to a matlab figure (e.g. and then you save the figure and reopen it only the matlab objects are in.

Accepted Answer

Malcolm Lidierth
Malcolm Lidierth on 26 Jan 2012
Any Java objects would needs to be fully serializable. See Saving and Loading Java Objects to MAT-Files in the MATLAB docs (note that fig files are mat files).
Swing objects all carry the following caveat in the javadoc.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.
Malcolm Lidierth
Malcolm Lidierth on 27 Jan 2012
PS Early days but the next installment of Waterloo will be a 2D scientific graphics library written entirely in Java. That will allow saving (I hope) and a "pre-release" should be available in the next month or two. It is also highly interactive so axes etc can be dragged and set using the mouse and there is a MATLAB interface providing support for MATLAB style calls like line, scatter contour etc.
Sven Koerner
Sven Koerner on 3 Feb 2012
Thanks Malcom for reply. I'm looking forward to next waterloo-version.

Sign in to comment.

More Answers (0)


Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!