Mercurial > hg > ltpda
comparison m-toolbox/classes/@collection/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 collection objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: DISPLAY overloads display functionality for collection objects. | |
5 % | |
6 % CALL: txt = display(collection) | |
7 % | |
8 % INPUT: collection - collection object | |
9 % | |
10 % OUTPUT: txt - cell array with strings which displays the matrix object | |
11 % | |
12 % <a href="matlab:utils.helper.displayMethodInfo('collection', 'display')">Parameters Description</a> | |
13 % | |
14 % VERSION: $Id: display.m,v 1.10 2011/04/08 08:56:22 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 colls = utils.helper.collect_objects(varargin(:), 'collection'); | |
27 | |
28 txt = {}; | |
29 | |
30 % Print emtpy object | |
31 if isempty(colls) | |
32 hdr = sprintf('------ %s -------', class(colls)); | |
33 ftr(1:length(hdr)) = '-'; | |
34 txt = [txt; {hdr}]; | |
35 txt = [txt; sprintf('empty-object [%d,%d]',size(colls))]; | |
36 txt = [txt; {ftr}]; | |
37 end | |
38 | |
39 for i=1:numel(colls) | |
40 banner = sprintf('---- collection %d ----', i); | |
41 txt{end+1} = banner; | |
42 | |
43 % get key and value | |
44 name = colls(i).name; | |
45 | |
46 % display | |
47 txt{end+1} = [' name: ' name]; | |
48 txt{end+1} = [' num objs: ' num2str(numel(colls(i).objs)) ]; | |
49 for kk=1:numel(colls(i).objs) | |
50 if isempty(colls(i).objs{kk}) | |
51 txt{end+1} = [sprintf(' %02d: %s | ', kk, class(colls(i).objs{kk})), 'empty-object']; | |
52 else | |
53 desc = utils.helper.val2str(colls(i).objs{kk}); | |
54 Dlen = 1000; | |
55 if length(desc) > Dlen | |
56 desc = [desc(1:Dlen) '...']; | |
57 end | |
58 txt{end+1} = [sprintf(' %02d: %s | ', kk, class(colls(i).objs{kk})) desc]; | |
59 end | |
60 end | |
61 | |
62 txt{end+1} = ['description: ' colls(i).description]; | |
63 txt{end+1} = [' UUID: ' colls(i).UUID]; | |
64 banner_end(1:length(banner)) = '-'; | |
65 txt{end+1} = banner_end; | |
66 end | |
67 | |
68 if nargout == 0 | |
69 for ii=1:length(txt) | |
70 disp(txt{ii}); | |
71 end | |
72 else | |
73 varargout{1} = txt; | |
74 end | |
75 | |
76 end | |
77 | |
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
79 % Local Functions % | |
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
81 | |
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
83 % | |
84 % FUNCTION: getInfo | |
85 % | |
86 % DESCRIPTION: Get Info Object | |
87 % | |
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
89 | |
90 function ii = getInfo(varargin) | |
91 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
92 sets = {}; | |
93 pl = []; | |
94 else | |
95 sets = {'Default'}; | |
96 pl = getDefaultPlist; | |
97 end | |
98 % Build info object | |
99 ii = minfo(mfilename, 'collection', 'ltpda', utils.const.categories.output, '$Id: display.m,v 1.10 2011/04/08 08:56:22 hewitson Exp $', sets, pl); | |
100 ii.setModifier(false); | |
101 ii.setOutmin(0); | |
102 end | |
103 | |
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
105 % | |
106 % FUNCTION: getDefaultPlist | |
107 % | |
108 % DESCRIPTION: Get Default Plist | |
109 % | |
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
111 | |
112 function plout = getDefaultPlist() | |
113 persistent pl; | |
114 if exist('pl', 'var')==0 || isempty(pl) | |
115 pl = buildplist(); | |
116 end | |
117 plout = pl; | |
118 end | |
119 | |
120 function pl = buildplist() | |
121 pl = plist.EMPTY_PLIST; | |
122 end | |
123 |