- Undocumented Matlab - https://undocumentedmatlab.com -
Blurred Matlab figure window
Posted By Yair Altman On April 20, 2011 | 2 Comments
Following my post two weeks ago about disabling an entire Matlab figure window [1], and my article last week about setting the transparency of a figure window [2], I would like to combine these two functionalities into a blurred-window effect for a disabled window.
The basic idea, as reader Mory pointed out [3] in a comment, is to overlay a semi-transparent empty figure window, having just the right size and position, on top of the main (disabled) figure window:
My blurFigure utility [4] on the Matlab File Exchange attempts to handle all these setups for the user. The utility is quite simple to use:
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 (see the demo below).
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. In fact, this runs the following simple code:
% Create the main (blurred) figure window
hFigMain = figure;
% Display some GUI controls in the main window
try oldWarn = warning('off','MATLAB:uitree:MigratingFunction'); catch, end
hTree = uitree('root','c:\');
drawnow;
try hTree.getTree.expandRow(0); catch, end
try warning(oldWarn); catch, end
uicontrol('string','click me!', 'units','pixel', 'pos',[300,50,100,20]);
axes('parent',gcf, 'units','pixel', 'pos',[230,100,300,300]);
surf(peaks);
set(gcf,'ToolBar','figure'); % restore the toolbar that was removed by the uicontrol() call above
% Call blurFigure() to add a semi-transparent overlaid window
hFigBlurTemp = blurFigure(hFigMain);
% Add some non-blurred controls on top of the blur
uicontrol('parent',hFigBlurTemp, 'style','text', 'units','pixel', 'pos',[130,85,390,80], ...
'string','Processing - please wait...', 'FontSize',12, 'FontWeight','bold','Fore','red','Back','yellow');
jProgressBar = javacomponent('javax.swing.JProgressBar', [180,115,310,20], hFigBlurTemp);
jProgressBar.setValue(67);
uicontrol('parent',hFigBlurTemp, 'string','Cancel', 'pos',[280,90,100,20], 'Callback','close(gcbf)');
Categories: Figure window, GUI, Java, Listeners, Medium risk of breaking in future versions, Undocumented feature
Article printed from Undocumented Matlab: https://undocumentedmatlab.com
URL to article: https://undocumentedmatlab.com/articles/blurred-matlab-figure-window
URLs in this post:
[1] disabling an entire Matlab figure window: http://undocumentedmatlab.com/blog/disable-entire-figure-window/
[2] setting the transparency of a figure window: http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/
[3] pointed out: http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#comment-40154
[4] blurFigure utility: http://www.mathworks.com/matlabcentral/fileexchange/30666-blurfigure-blurs-and-prevents-interaction-on-a-figure-window
[5] comment: http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/#respond
[6] Transparent Matlab figure window : https://undocumentedmatlab.com/articles/transparent-matlab-figure-window
[7] Minimize/maximize figure window : https://undocumentedmatlab.com/articles/minimize-maximize-figure-window
[8] Figure window customizations : https://undocumentedmatlab.com/articles/figure-window-customizations
[9] Enable/disable entire figure window : https://undocumentedmatlab.com/articles/disable-entire-figure-window
[10] Detecting window focus events : https://undocumentedmatlab.com/articles/detecting-window-focus-events
[11] Frameless (undecorated) figure windows : https://undocumentedmatlab.com/articles/frameless-undecorated-figure-windows
Click here to print.
Copyright © Yair Altman - Undocumented Matlab. All rights reserved.
2 Comments To "Blurred Matlab figure window"
#1 Comment By Paul Andrews On April 21, 2011 @ 09:01
Yair,
This is another great post. Thank you very much for sharing it. For those of us who are trying to develop professional applications using Matlab and the Matlab Compiler, your blog is extremely helpful.
Now, I do have a suggestion regarding your blurFigure function. How about using a JWindow, with opacity set to 0.8, and overlaying it over the figure? JWindow has the advantage of not having boarders, titles, menubars, etc.
The code below shows you what I had in mind.
Best regards,
Paul
#2 Comment By Yair Altman On April 21, 2011 @ 09:13
@Paul – nice touch! thanks for sharing the idea 🙂