hFigBlur = blurFigure(hFig, state)
blurFigure(hFig) blurs figure hFig and prevents interaction with it. The only interaction possible is with user-created controls on the blurring panel (see below).
hFigBlur = blurFigure(hFig) returns the overlaid blurred figure pane. This is useful to present a progress bar or other GUI controls, for user interaction during the blur phase.
blurFigure(hFig,STATE) sets the blur status of figure hFig to STATE, where state is 'on','off',true or false (default='on'/true).
blurFigure(hFig,'on') or blurFigure(hFig,true) is the same as: blurFigure(hFig).
blurFigure(hFig,'off') or blurFigure(hFig,false) is the same as: close(hFigBlur).
blurFigure('demo') displays a simple demo of the blurring (see attached screenshot).
Input parameters: (all parameters are optional)
hFig - (default=gcf) Handle(s) of the modified figure(s). If component handle(s) is/are specified, then the containing figure(s) will be inferred and used.
state - (default='on'/true) blurring flag: 'on','off',true or false
hFigBlur = blurFigure(hFig); % blur hFig (alternative #1)
hFigBlur = blurFigure(hFig,true); % blur hFig (alternative #2)
hFigBlur = blurFigure(hFig,false); % un-blur hFig (alternative #1)
hFigBlur = blurFigure(hFig,'off'); % un-blur hFig (alternative #2)
close(hFigBlur); % un-blur hFig (alternative #3)
delete(hFigBlur); % un-blur hFig (alternative #4)
blurFigure('demo'); % blur demo with progress bar etc.
Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7.9 (R2009b) and higher, but use at your own risk!
IMPORTANT NOTE: this utility DOES NOT WORK on R2013b/Java7 and higher, only on earlier releases. The failure is due to a change in the way that transparency works in Java 7 compared to earlier releases. If I ever find a solution, I will post it here. In the meantime, please do not comment about this issue here.
Great utility. I have had a bit of trouble getting the overlay figure to exactly match the original. I found if I have a menu created in GUIDE, then the 'Menu' parameter is 'none' and the blurFig shortens itself.
If you add some lines to check if hProps.MenuBar is 'none', but there are uimenu objects with children, then you can launch the figure without the Menu parameter and it's fine.
Also adding space in line 180:
helps keep the height matching in other situations.
I'm really loving your blog Yair, some really useful things in there! I'm running Matlab 20112b on OSX and the following line causes the blurfigure to flicker:
hLink(3) = linkprop(hFigures,'Visible');
I've commented it out as I'm not changing visibility of the target figure during the call, but I'm just not sure why that line caused problems!
This is exactly what I need. Works like a charm with MATLAB 8.0 (R2012b)
Really simple to insert in his own code.
OK, I'll keep an eye out for it, don't see it yet. Thanks for the quick response.
@Charles - I uploaded a fix for R2011b. It should be available here shortly (maybe tomorrow)
This is exactly what I need. However, it does not work for me. I am using 2011b, which may be the problem. Here is the error I get:
Error using blurFigure (line 135)
Cannot retrieve the Java Frame reference for figure 190.0016
Error in mirror>characterize_Callback (line 3356)
Error in gui_mainfcn (line 96)
Error in mirror (line 43)
Error while evaluating uicontrol Callback
good sfuff O(∩_∩)O
Very nice utility. Why not add a parameter to allow the user to set the opacity instead of just fixing it at 0.8?
@Jan - a retrofit of JRE means installing JRE 1.6.0_10 (also called "Java 6 update 10"), or any later version (e.g., the latest available version today is 1.6 update 24). The JRE can be downloaded from http://java.com/en/download/manual.jsp and you can configure Matlab to use it according to the instructions in http://www.mathworks.com/support/solutions/en/data/1-1812J/
All of this is only necessary in Matlab releases R2009a (7.8) and earlier, which pre-bundle an earlier JRE version that does not support window frame transparency/opacity used in this submission.
Matlab R2009b (7.9) and onward, at least on Microsoft Windows, pre-bundle a JRE version that does support transparency/opacity and so do not require a retrofit.
What is a "retrofit of JRE 1.6.0_10"?
Fix for R2011a; fixed description;
Fixed the demo code
Create scripts with code, output, and formatted text in a single executable document.