comparison m-toolbox/classes/@matrix/display.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % DISPLAY overloads display functionality for matrix objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: DISPLAY overloads display functionality for matrix objects.
5 %
6 % CALL: txt = display(matrix)
7 %
8 % INPUT: matrix - matrix object
9 %
10 % OUTPUT: txt - cell array with strings which displays the matrix object
11 %
12 % <a href="matlab:utils.helper.displayMethodInfo('matrix', 'display')">Parameters Description</a>
13 %
14 % VERSION: $Id: display.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18 function varargout = display(varargin)
19
20 %%% Check if this is a call for parameters
21 if utils.helper.isinfocall(varargin{:})
22 varargout{1} = getInfo(varargin{3});
23 return
24 end
25
26 objs = utils.helper.collect_objects(varargin(:), 'matrix');
27
28 txt = {};
29
30 % Print emtpy object
31 if isempty(objs)
32 hdr = sprintf('------ %s -------', class(objs));
33 ftr(1:length(hdr)) = '-';
34 txt = [txt; {hdr}];
35 txt = [txt; sprintf('empty-object [%d,%d]',size(objs))];
36 txt = [txt; {ftr}];
37 end
38
39 for i=1:numel(objs)
40 banner = sprintf('---- matrix %d ----', i);
41 txt{end+1} = banner;
42
43 % get key and value
44 name = objs(i).name;
45
46 % display
47 txt{end+1} = [' name: ' name];
48 txt{end+1} = [' size: ' num2str(size(objs(i).objs, 1)) 'x' num2str(size(objs(i).objs, 2))];
49 for kk=1:numel(objs(i).objs)
50 txt{end+1} = [sprintf(' %02d: %s | ', kk, class(objs(i).objs(kk))) char(objs(i).objs(kk))];
51 end
52
53 txt{end+1} = ['description: ' objs(i).description];
54 txt{end+1} = [' UUID: ' objs(i).UUID];
55 banner_end(1:length(banner)) = '-';
56 txt{end+1} = banner_end;
57 end
58
59 if nargout == 0
60 for ii=1:length(txt)
61 disp(txt{ii});
62 end
63 else
64 varargout{1} = txt;
65 end
66
67 end
68
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 % Local Functions %
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %
75 % FUNCTION: getInfo
76 %
77 % DESCRIPTION: Get Info Object
78 %
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
81 function ii = getInfo(varargin)
82 if nargin == 1 && strcmpi(varargin{1}, 'None')
83 sets = {};
84 pl = [];
85 else
86 sets = {'Default'};
87 pl = getDefaultPlist;
88 end
89 % Build info object
90 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.output, '$Id: display.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $', sets, pl);
91 ii.setModifier(false);
92 ii.setOutmin(0);
93 end
94
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 %
97 % FUNCTION: getDefaultPlist
98 %
99 % DESCRIPTION: Get Default Plist
100 %
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102
103 function plout = getDefaultPlist()
104 persistent pl;
105 if exist('pl', 'var')==0 || isempty(pl)
106 pl = buildplist();
107 end
108 plout = pl;
109 end
110
111 function pl = buildplist()
112 pl = plist.EMPTY_PLIST;
113 end
114