-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path_ElementWithFigure.gen.m
More file actions
133 lines (105 loc) · 3.13 KB
/
Copy path_ElementWithFigure.gen.m
File metadata and controls
133 lines (105 loc) · 3.13 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
%% ¡header!
ElementWithFigure < ConcreteElement (ef, element with figure) is an element with a figure.
%%% ¡description!
An Element with a Figure (ElementWithFigure) is an example of an element
that contains the handle of a figure with one panel that in turn contains
10 buttons.
%%% ¡seealso!
uifigure, uipanel, uibutton
%% ¡props_update!
%%% ¡prop!
ELCLASS (constant, string) is the class of the element with figure.
%%%% ¡default!
'ElementWithFigure'
%%% ¡prop!
NAME (constant, string) is the name of the element with figure.
%%%% ¡default!
'Element with a Figure'
%%% ¡prop!
DESCRIPTION (constant, string) is the description of the element with figure.
%%%% ¡default!
'An Element with a Figure (ElementWithFigure) is an example of an element that contains the handle of a figure with one panel that in turn contains 10 buttons.'
%%% ¡prop!
TEMPLATE (parameter, item) is the template of the element with figure.
%%%% ¡settings!
'ElementWithFigure'
%%% ¡prop!
ID (data, string) is a few-letter code for the element with figure.
%%%% ¡default!
'ElementWithFigure ID'
%%% ¡prop!
LABEL (metadata, string) is an extended label of the element with figure.
%%%% ¡default!
'ElementWithFigure label'
%%% ¡prop!
NOTES (metadata, string) are some specific notes about the element with figure.
%%%% ¡default!
'ElementWithFigure notes'
%% ¡props!
%%% ¡prop!
RANDOM_NUMBER (result, scalar) is a random number.
%%%% ¡calculate!
value = rand();
%% ¡props!
%%% ¡prop!
FIG (evanescent, handle) is the handle of a figure.
%%%% ¡calculate!
value = uifigure( ...
'Name', 'Figure from ElementWithFigure', ...
'Color', BRAPH2.COL ...
);
%%% ¡prop!
PANEL (evanescent, handle) is the handle of the panel.
%%%% ¡calculate!
if ~check_graphics(ef.memorize('FIG'), 'figure')
ef.set('FIG', Element.getNoValue());
end
fig = ef.memorize('FIG');
value = uipanel( ...
'Parent', fig, ...
'Units', 'normalized', ...
'Position', [.25 .25 .50 .50], ...
'BackgroundColor', BRAPH2.COL_BKG ...
);
%%% ¡prop!
BUTTONS (evanescent, handlelist) is the list of handles of the buttons.
%%%% ¡calculate!
if ~check_graphics(ef.getr('PANEL'), 'uipanel')
ef.set('PANEL', Element.getNoValue());
end
panel = ef.memorize('PANEL');
value = {};
for i = 1:1:10
value{i} = uibutton( ...
'Parent', panel, ...
'Text', ['B' int2str(i)], ...
'Position', [ ...
(i - 1) * w(panel, 'pixels') / 10 ...
(i - 1) * h(panel, 'pixels') / 10 ...
w(panel, 'pixels') / 10 ...
h(panel, 'pixels') / 10 ...
], ...
'ButtonPushedFcn', {@cb_button} ...
);
end
%%%% ¡calculate_callbacks!
function cb_button(src, ~)
disp(src.get('Text'))
end
%% ¡tests!
%%% ¡excluded_props!
[ElementWithFigure.PANEL ElementWithFigure.BUTTONS]
%%% ¡test!
%%%% ¡name!
Remove Figures
%%%% ¡code!
warning('off', [BRAPH2.STR ':ElementWithFigure'])
assert(length(findall(0, 'type', 'figure')) == 4)
delete(findall(0, 'type', 'figure'))
warning('on', [BRAPH2.STR ':ElementWithFigure'])
%%% ¡test!
Simple test
%%%% ¡code!
ef = ElementWithFigure()
ef.memorize('BUTTONS')
close(ef.get('FIG'))