Mercurial > hg > ltpda
comparison m-toolbox/classes/@minfo/modelOverview.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 % MODELOVERVIEW prepares an html overview of a built-in model | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: MODELOVERVIEW prepares an html overview of a built-in model | |
5 % | |
6 % VERSION: $Id: modelOverview.m,v 1.5 2011/02/18 16:48:53 ingo Exp $ | |
7 % | |
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
9 | |
10 function varargout = modelOverview(varargin) | |
11 | |
12 % Get minfo objects | |
13 objs = utils.helper.collect_objects(varargin(:), 'minfo'); | |
14 | |
15 if numel(objs) > 1 | |
16 error('### Only works for one info object'); | |
17 end | |
18 | |
19 if nargin == 2 | |
20 browser = varargin{2}; | |
21 else | |
22 browser = true; | |
23 end | |
24 txts = html(objs(1),browser); | |
25 | |
26 % display the objects | |
27 if nargout > 0 | |
28 varargout{1} = txts; | |
29 elseif nargout == 0; | |
30 disp(txts); | |
31 end | |
32 end | |
33 | |
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
35 % Local Functions % | |
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
37 | |
38 function txt = html(ii, browser) | |
39 | |
40 modelFcn = ii.mname; | |
41 | |
42 txt = ''; | |
43 % Page header | |
44 txt = [txt pageHeader(ii)]; | |
45 | |
46 % Table of the navigation (top) | |
47 if browser | |
48 txt = [txt topNavigation(ii)]; | |
49 end | |
50 | |
51 % Title | |
52 txt = [txt sprintf(' <h1 class="title">Model Report for %s/%s</h1>\n', ii.mclass, ii.mname)]; | |
53 txt = [txt sprintf(' <hr>\n\n')]; | |
54 | |
55 | |
56 % Description | |
57 desc = feval(modelFcn, 'description'); | |
58 txt = [txt sprintf('<p>%s</p>\n', desc)]; | |
59 | |
60 % Documentation | |
61 doc = feval(modelFcn, 'doc'); | |
62 txt = [txt sprintf('<p>%s</p>\n', doc)]; | |
63 | |
64 % Model version table | |
65 txt = [txt modelVersionsTable(ii, modelFcn)]; | |
66 | |
67 % Table of the minfo object | |
68 txt = [txt minfoSummaryTable(ii)]; | |
69 | |
70 % Section for each version | |
71 versions = ii.plists.getOptionsForParam('VERSION'); | |
72 versionTable = feval(modelFcn, 'versionTable'); | |
73 for ll=1:numel(versions) | |
74 version = versions{ll}; | |
75 desc = feval(modelFcn, 'describe', version); | |
76 pl = feval(modelFcn, 'plist', version); | |
77 pl.remove('VERSION'); | |
78 | |
79 txt = [txt '<hr/>']; | |
80 txt = [txt sprintf('<a name="%s"/><h2>%s</h2></a>\n', strrep(version, ' ', ''), version)]; | |
81 | |
82 % description | |
83 verFcn = utils.models.functionForVersion([], versionTable, version, []); | |
84 % description for version | |
85 desc = feval(verFcn, 'description'); | |
86 txt = [txt sprintf('<p>%s</p>\n', desc)]; | |
87 | |
88 % plist table | |
89 txt = [txt pl.tohtml]; | |
90 | |
91 % Submodels table | |
92 txt = [txt subModelsTable(ii, modelFcn, version)]; | |
93 | |
94 % Back to top | |
95 txt = [txt backToTopLink()]; | |
96 | |
97 end | |
98 | |
99 | |
100 % Table of the navigation (bottom) | |
101 if browser | |
102 txt = [txt bottomNavigation(ii)]; | |
103 end | |
104 | |
105 % Footer | |
106 txt = [txt sprintf(' <p class="copy">©LTP Team</p>\n')]; | |
107 | |
108 txt = [txt sprintf(' </body>\n')]; | |
109 txt = [txt sprintf('</html>')]; | |
110 | |
111 end | |
112 | |
113 function txt = backToTopLink() | |
114 txt = ''; | |
115 txt = [txt sprintf(' <!-- ===== Back to top ===== -->\n')]; | |
116 txt = [txt sprintf(' <a href="#top_of_page">\n')]; | |
117 txt = [txt sprintf(' <img src="file://%s" border="0" align="bottom" alt="back to top"/>\n', which('doc_to_top_up.gif'))]; | |
118 txt = [txt sprintf(' back to top\n')]; | |
119 txt = [txt sprintf(' </a>\n')]; | |
120 txt = [txt sprintf(' </p>\n\n')]; | |
121 txt = [txt sprintf(' <br>\n\n')]; | |
122 txt = [txt sprintf(' <br>\n\n')];end | |
123 | |
124 function txt = pageHeader(ii) | |
125 txt = ''; | |
126 txt = [txt sprintf('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\n')]; | |
127 txt = [txt sprintf(' "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">\n\n')]; | |
128 | |
129 txt = [txt sprintf('<html lang="en">\n')]; | |
130 | |
131 % Head definition | |
132 txt = [txt sprintf(' <head>\n')]; | |
133 txt = [txt sprintf(' <title>Model Report for %s/%s</title>\n', ii.mclass, ii.mname)]; | |
134 txt = [txt sprintf(' <link rel="stylesheet" type="text/css" href="file://%s">\n', which('docstyle.css'))]; | |
135 txt = [txt sprintf(' </head>\n\n')]; | |
136 | |
137 txt = [txt sprintf(' <body>\n\n')]; | |
138 | |
139 txt = [txt sprintf(' <a name="top_of_page" id="top_of_page"></a>\n')]; | |
140 txt = [txt sprintf(' <p style="font-size:1px;"> </p>\n\n')]; | |
141 | |
142 end | |
143 | |
144 function txt = topNavigation(ii) | |
145 | |
146 txt = ''; | |
147 txt = [txt sprintf(' <table class="nav" summary="Navigation aid" border="0" width="100%%" cellpadding="0" cellspacing="0">\n')]; | |
148 txt = [txt sprintf(' <tr>\n')]; | |
149 txt = [txt sprintf(' <td valign="baseline"><b>LTPDA Toolbox</b></td>\n')]; | |
150 txt = [txt sprintf(' <td><a href="file://%s">contents</a></td>\n', which('helptoc.html'))]; | |
151 txt = [txt sprintf(' <td valign="baseline" align="right"><a href=\n')]; | |
152 txt = [txt sprintf(' "file://%s"><img src=\n', which('class_desc_main.html'))]; | |
153 txt = [txt sprintf(' "file://%s" border="0" align="bottom" alt="Class descriptions"></img></a> <a href=\n', which('b_prev.gif'))]; | |
154 txt = [txt sprintf(' "file://%s"><img src=\n', which(['class_desc_' ii.mclass '.html']))]; | |
155 txt = [txt sprintf(' "file://%s" border="0" align="bottom" alt="%s Class"></a></td>\n', which('b_next.gif'), upper(ii.mclass))]; | |
156 txt = [txt sprintf(' </tr>\n')]; | |
157 txt = [txt sprintf(' </table>\n\n')]; | |
158 | |
159 | |
160 end | |
161 | |
162 function txt = bottomNavigation(ii) | |
163 | |
164 txt = ''; | |
165 txt = [txt sprintf(' <br>\n')]; | |
166 txt = [txt sprintf(' <table class="nav" summary="Navigation aid" border="0" width="100%%" cellpadding="0" cellspacing="0">\n')]; | |
167 txt = [txt sprintf(' <tr valign="top">\n')]; | |
168 txt = [txt sprintf(' <td align="left" width="20"><a href=\n')]; | |
169 txt = [txt sprintf(' "file://%s"><img src=\n', which('class_desc_main.html'))]; | |
170 txt = [txt sprintf(' "file://%s" border="0" align="bottom" alt=\n', which('b_prev.gif'))]; | |
171 txt = [txt sprintf(' "Class descriptions"></a> </td>\n')]; | |
172 txt = [txt sprintf(' <td align="left">Class descriptions</td>\n')]; | |
173 txt = [txt sprintf(' <td> </td>\n')]; | |
174 txt = [txt sprintf(' <td align="right">%s Class</td>\n', upper(ii.mclass))]; | |
175 txt = [txt sprintf(' <td align="right" width="20"><a href=\n')]; | |
176 txt = [txt sprintf(' "file://%s"><img src=\n', which('class_desc_ao.html'))]; | |
177 txt = [txt sprintf(' "file://%s" border="0" align="bottom" alt=\n', which('b_next.gif'))]; | |
178 txt = [txt sprintf(' "%s Class"></a></td>\n', upper(ii.mclass))]; | |
179 txt = [txt sprintf(' </tr>\n')]; | |
180 txt = [txt sprintf(' </table><br>\n')]; | |
181 end | |
182 | |
183 function txt = minfoSummaryTable(ii) | |
184 | |
185 txt = ''; | |
186 txt = [txt sprintf(' <p><!-- Table of the minfo object -->\n')]; | |
187 txt = [txt sprintf(' <table cellspacing="0" class="body" cellpadding="2" border="0" width="60%%">\n')]; | |
188 txt = [txt sprintf(' <colgroup>\n')]; | |
189 txt = [txt sprintf(' <col width="25%%"/>\n')]; | |
190 txt = [txt sprintf(' <col width="75%%"/>\n')]; | |
191 txt = [txt sprintf(' </colgroup>\n')]; | |
192 txt = [txt sprintf(' <thead>\n')]; | |
193 txt = [txt sprintf(' <tr valign="top">\n')]; | |
194 txt = [txt sprintf(' <th class="categorylist" colspan="2">Some information of the method %s/%s are listed below:</th>\n', ii.mclass, ii.mname)]; | |
195 txt = [txt sprintf(' </tr>\n')]; | |
196 txt = [txt sprintf(' </thead>\n')]; | |
197 txt = [txt sprintf(' <tbody>\n')]; | |
198 txt = [txt sprintf(' <!-- Property: ''mclass'' -->\n')]; | |
199 txt = [txt sprintf(' <tr valign="top">\n')]; | |
200 txt = [txt sprintf(' <td bgcolor="#f3f4f5">Class name</td>\n')]; | |
201 txt = [txt sprintf(' <td bgcolor="#f3f4f5">%s</td>\n', ii.mclass)]; | |
202 txt = [txt sprintf(' </tr>\n')]; | |
203 txt = [txt sprintf(' <!-- Property: ''mname'' -->\n')]; | |
204 txt = [txt sprintf(' <tr valign="top">\n')]; | |
205 txt = [txt sprintf(' <td bgcolor="#ffffff">Method name</td>\n')]; | |
206 txt = [txt sprintf(' <td bgcolor="#ffffff">%s</td>\n', ii.mname)]; | |
207 txt = [txt sprintf(' </tr>\n')]; | |
208 txt = [txt sprintf(' <!-- Property: ''mversion'' -->\n')]; | |
209 txt = [txt sprintf(' <tr valign="top">\n')]; | |
210 txt = [txt sprintf(' <td bgcolor="#ffffff">CVS Version</td>\n')]; | |
211 txt = [txt sprintf(' <td bgcolor="#ffffff">%s</td>\n', ii.mversion)]; | |
212 txt = [txt sprintf(' </tr>\n')]; | |
213 txt = [txt sprintf(' </tbody>\n')]; | |
214 txt = [txt sprintf(' </table>\n')]; | |
215 txt = [txt sprintf(' </p>\n\n')]; | |
216 end | |
217 | |
218 | |
219 function txt = modelVersionsTable(ii, modelFcn) | |
220 versions = ii.plists.getOptionsForParam('VERSION'); | |
221 txt = ''; | |
222 txt = [txt sprintf(' <p><!-- Link-Table of the sets -->\n')]; | |
223 txt = [txt sprintf(' <table border="1" cellpadding="4" cellspacing="0" class="pagenavtable">\n')]; | |
224 txt = [txt sprintf(' <tr><th>Model Versions</th><th>Description</th></tr>\n')]; | |
225 versionTable = feval(modelFcn, 'versionTable'); | |
226 for ll=1:numel(versions) | |
227 version = versions{ll}; | |
228 verFcn = utils.models.functionForVersion([], versionTable, version, []); | |
229 % description for version | |
230 desc = feval(verFcn, 'description'); | |
231 txt = [txt sprintf(' <tr><td><a href="#%s">%s</a></td><td>%s</td></tr>\n', strrep(version, ' ', ''), version, desc)]; | |
232 end | |
233 txt = [txt sprintf(' </table>\n')]; | |
234 txt = [txt sprintf(' <p>\n\n')]; | |
235 end | |
236 | |
237 function txt = subModelsTable(ii, modelFcn, version) | |
238 | |
239 verinfo = feval(modelFcn, 'info', version); | |
240 children = verinfo.children; | |
241 txt = ''; | |
242 if numel(children)==0 | |
243 return | |
244 end | |
245 | |
246 txt = [txt sprintf('<p><table border="1" cellpadding="4" cellspacing="0" class="pagenavtable">\n')]; | |
247 txt = [txt sprintf(' <tr><th>Sub-models</th><th>Version</th><th>Description</th></tr>\n')]; | |
248 for jj=1:numel(children) | |
249 cii = children(jj); | |
250 % description for version | |
251 desc = feval(cii.mname, 'description'); | |
252 cver = cii.plists.find('VERSION'); | |
253 txt = [txt sprintf(' <tr><td><a href="matlab:utils.models.displayModelOverview(''%s'')">%s</a></td><td>%s</td><td>%s</td></tr>\n', cii.mname, cii.mname, cver, desc)]; | |
254 end | |
255 txt = [txt sprintf('</table>\n')]; | |
256 txt = [txt sprintf('</p>\n\n')]; | |
257 | |
258 end |