-
Notifications
You must be signed in to change notification settings - Fork 0
/
FigureHandler.m
86 lines (86 loc) · 2.74 KB
/
FigureHandler.m
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
classdef FigureHandler < handle
properties
figs
verbosity
end
properties (SetAccess = private)
default_profile
end
methods
function FH = FigureHandler(default_profile)
global VERBOSE;
if nargin == 0
FH.default_profile = 'default';
else
FH.default_profile = default_profile;
end
FH.figs = Dictionary;
FH.verbosity = VERBOSE;
end
function new(obj,name,profile)
dbprint(obj.verbosity==1,'Creating new figure...')
if nargin == 2
profile = obj.default_profile;
end
if strcmp(name,obj.figs.get_Keys)
obj.close(name);
end
dbprint(obj.verbosity==1,'Creating cFigure object...');
f = cfigure(name,profile);
dbprint(obj.verbosity==1,'Adding cFigure to dictionary...');
obj.figs.set(name,f);
end
function map(obj,target_keys,fn,args)
if isempty(target_keys)
target_keys=obj.figs.get_Keys;
end
for i=1:length(target_keys)
h = obj.figs.get(target_keys{i});
dbprint(obj.verbosity==1,obj.figs.get_Keys{i});
h.(fn)(args{:})
end
end
function whos(obj)
obj.figs.display
end
function cfig_obj = get_cfig(obj,name)
cfig_obj = obj.figs.get(name);
end
function axis_handle = get_axes(obj,name)
cfig = obj.get_cfig(name);
axis_handle = cfig.Hax;
end
function figure_handle = get_fig(obj,name)
cfig = obj.get_cfig(name);
figure_handle = cfig.Hfg;
end
function append(obj,cfig_obj)
obj.figs.set(cfig_obj.name,cfig_obj);
end
function extend(obj,fighandler)
new_keys=fighandler.figs.get_Keys;
for i=1:length(new_keys)
new_key=new_keys{i};
obj.figs.set(new_key,fighandler.figs.get(new_key))
end
end
% extensions of cfig methods
function show(obj,varargin)
obj.map(varargin,'show',{})
end
function hide(obj,varargin)
obj.map(varargin,'hide',{})
end
function save(obj,path,format,varargin)
obj.map(varargin,'show',{})
obj.map(varargin,'save',{path,format});
end
% function save_mult(obj,path,formats,varargin)
% obj.map(varargin,'save_mult',{path,formats});
% end
function close(obj,varargin)
obj.map(varargin,'close',{})
obj.figs.clear(varargin);
end
end
end