Figures-menu adaption for standalone applications

by

 

12 Nov 2012 (Updated )

Create dockable figures for standalones and disable or remove menu items from the figures container

Create_Figure
%% #######################     HEADER START    ############################
%
% Filename:				Create_Figure.m
%
% Author:				Alexander Mering
% Created:				08-Nov-2012
%
% Changed on:			XX-XX-XXXX  by NAME		SHORT CHANGE DESCRIPTION
%						XX-XX-XXXX  by NAME		SHORT CHANGE DESCRIPTION
%
%*************************************************************************
%
% Description:
%		Prepare and open a new figure window; define all figure dependend settings.
% 
%
% Output parameter:
%		- figure_handle:	handle to the created figure
%
% #######################      HEADER END     ############################

%% #######################    FUNCTION START   ############################
function figure_handle = Create_Figure
% Create a figure and attach a property change listener for the WindowStyle property.
figure_handle = figure('NumberTitle','off');

% get java frame for sophisticated modifications
jframe = get(handle(figure_handle), 'JavaFrame');


%% Docking
% For deployed tools, docking can be made available using the JavaFrame. Unforunately, this leads to menu entries in the
% "Figures" container, which directly crash everything (if selected). To avoid this, listen for the docking property and
% invoke a callback, which deactivates these menus. Listerner code segment based on http://undocumentedmatlab.com/blog/continuous-slider-callback/

% allow docking
jframe.fHG1Client.setClientDockable(true)

% listen to the WindowStyle property to detect docking / undocking events
hProp = findprop(handle(figure_handle),'WindowStyle');  % a schema.prop object

% if the event occurs, invoke the callback
hlistener = handle.listener(handle(figure_handle), hProp, 'PropertyPostSet',{@(source, event) Callback_DockingFcn});

% attach listener to the GUI since it needs to be known (as long as the figure exists)
setappdata(figure_handle, 'Handle_Listener', hlistener);


%% further stuff
% finally set some further properties
hold on
grid on
box on

% #######################     FUNCTION END    ############################



Contact us