-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetdefault.m
More file actions
69 lines (64 loc) · 2.04 KB
/
getdefault.m
File metadata and controls
69 lines (64 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function value=getdefault(varargin)
%% Get the Default Properties
% value=Groot.getdefault() returns the values of all the settable default
% properties of MATLAB graphic objects. The values are contained in a cell. Use
% Groot.findprop() to get the property names that correspond to these values.
%
% value=Groot.getdefault(Name)
% value=Groot.getdefault(NameArray)
% does the same as the built-in function:
% value=get(groot,'default'Name)
% value=get(groot,'default'NameArray)
% except that the elements in NameArray, Name1, Name2, ... are a regular
% expression. The values of all the properties that match the regular
% expression will be returned. Unlike the built-in implementation, the property
% names should not be prefixed with the string 'default'. In the first syntax,
% the output is a cell vector containing the values. In the second syntax, the
% output is a cell array of such cell vectors. The size of the cell array is
% the same as that of the NameArray.
%
% Tested on:
% - MATLAB R2018a
%
% See also: findprop, setdefault, usedefault.
%
% Copyright: Herianto Lim (http://heriantolim.com)
% Licensing: GNU General Public License v3.0
% First created: 04/04/2018
% Last modified: 05/04/2018
assert(nargin<2,...
'MatGraphics:Groot:getdefault:WrongNargin',...
'At most one input argument can be taken.');
if nargin>0 && iscell(varargin{1})
tf=false;
prop=Groot.findprop(varargin{1});
varargin=varargin{1};
else
tf=true;
prop={Groot.findprop(varargin{:})};
end
value=cell(size(prop));
for i=1:numel(prop)
if isempty(prop{i})
error('MatGraphics:Groot:getdefault:PropertyNotFound',...
'The expression ''%s'' matches no gettable default properties.',...
varargin{i});
end
value{i}=cell(size(prop{i}));
for j=1:numel(prop{i})
try
value{i}{j}=get(groot,['default',prop{i}{j}]);
catch ME1
if isempty(regexpi(ME1.identifier,':DefaultCannotBeSetGet$','once'))
rethrow(ME1);
else
warning('MatGraphics:Groot:getdefault:NoGetAccess',...
'%s',ME1.message);
end
end
end
end
if tf
value=value{1};
end
end