IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
irreport.m
Go to the documentation of this file.
1 %> @brief Report base class.
2 %>
3 %> Reports are blocks that output a @ref log_report class.
4 %>
5 %> They descend from @ref vis, but they do generate output.
6 %>
7 %> The code generator @gencode.m will automatically open a web browser to show the report if it is GUI-obtained.
8 classdef irreport < vis
9  properties
10  %> =1 whther to generate the images
11  flag_images = 1;
12 
13  %> =1. Whether to create the tables
14  flag_tables = 1;
15  end;
16  methods
17  function o = irreport()
18  o.classtitle = 'HTML Report';
19  o.flag_out = 1;
20  o.flag_trainable = 0;
21  o.flag_fixednf = 0;
22  o.flag_graphics = 0;
23  o.flag_out = 1;
24  end;
25  end;
26 
27 
28  % *-*-*-*-*-*-*-* TOOLS
29  methods(Static)
30  %> Creates an "img" HTML tag that links both to the PNG and FIG versions
31  %> @param fn file name with/without extension
32  %> @param perc =100 percentage width (0-100). If zero, will use original size
33  %> @param flag_fig = 1 Whether to generate an "a" tag to the FIG version as well
34  function s = get_imgtag(fn, perc, flag_fig)
35  if nargin < 2 || isempty(perc)
36  perc = 100;
37  end;
38  if nargin < 3 || isempty(flag_fig)
39  flag_fig = 1;
40  end;
41 
42 
43  [s_path, fn, s_ext] = fileparts(fn); %#ok<NASGU,ASGLU>
44 
45  s = ['<center>', 10, ...
46  '<a href="', fn, '.png" target="_blank"><img border=0 src="', fn, '.png" ', ...
47  iif(perc > 0, ['width="', int2str(perc), '%"'], ''), '></a><br />', 10];
48  if flag_fig
49  s = cat(2, s, ['<a href="', fn, '.fig">Download FIG</a>&nbsp;&nbsp;', 10, ...
50  '<a href="matlab:open(''', fn, '.fig'')">Open FIG in MATLAB</a><br />', 10]);
51  end;
52  s = cat(2, s, ['</center>', 10]);
53  end;
54 
55  %> Used to save a figure both as png and fig, and close it
56  %> @return an "img" HTML tag that may be used if wanted
57  %> @param fn =(autogenerated) file name with/without extension
58  %> @param perc =100 percentage width (0-100)
59  %> @param res =(screen resolution) Resolution in DPI, e.g., 150, 300
60  function s = save_n_close(fn, perc, res)
61  if nargin < 1 || isempty(fn)
62  fn = find_filename('irr_image', [], 'png', 0);
63  end;
64  if nargin < 2 || isempty(perc)
65  perc = 100;
66  end;
67  if nargin < 3
68  res = [];
69  end;
70 
71  [s_path, fn, s_ext] = fileparts(fn); %#ok<NASGU,ASGLU>
72 
73  save_as_png([], fn, res);
74  save_as_fig([], fn);
75  close;
76  pause(0.25); % Attempt to wait until MATLAB gets internally sorted
77 
78  s = irreport.get_imgtag(fn, perc);
79  end;
80  end;
81 end
Visualization base class.
Definition: vis.m:4
static function get_imgtag(in fn, in perc, in flag_fig)
function save_as_png(in h, in fn, in dpi)
function iif(in cond, in x1, in x2)
Analysis Session (AS) base class.
Definition: as.m:6
function save_as_fig(in h, in fn)
function find_filename(in prefix, in suffix, in extension, in flag_return_ext)
Report base class.
Definition: irreport.m:8
MATLAB code generation to create, boot, train and use blocks.
Definition: gencode.m:9