reporting (WIP)
parent
ff4a155f07
commit
1c371389df
|
@ -18,10 +18,5 @@ function e = addGraph(e, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(nargin >= 1 && nargin <= 3)
|
||||
if nargin == 1
|
||||
e.objArray = e.objArray.addObj(graph());
|
||||
else
|
||||
e.objArray = e.objArray.addObj(varargin{:});
|
||||
end
|
||||
e.objArray = e.objArray.addObj(graph(varargin{:}));
|
||||
end
|
|
@ -18,10 +18,5 @@ function e = addTable(e, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(nargin >= 1 && nargin <= 3)
|
||||
if nargin == 1
|
||||
e.objArray = e.objArray.addObj(table());
|
||||
else
|
||||
e.objArray = e.objArray.addObj(varargin{:});
|
||||
end
|
||||
e.objArray = e.objArray.addObj(table(varargin{:}));
|
||||
end
|
|
@ -0,0 +1,107 @@
|
|||
function o = createGraph(o)
|
||||
%function o = createGraph(o)
|
||||
% Create the graph
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.data));
|
||||
assert(isa(o.data, 'dynSeries')) ;
|
||||
|
||||
if ~isempty(o.figname)
|
||||
warning('Will overwrite %s with new graph\n', o.figname);
|
||||
end
|
||||
|
||||
%o = readConfig(o);
|
||||
|
||||
h = figure('visible','off');
|
||||
hold on;
|
||||
box on;
|
||||
%set(0, 'CurrentFigure',h);
|
||||
%set(h, 'PaperPositionMode', 'auto');
|
||||
%set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]);
|
||||
|
||||
if strcmpi(o.seriestoplot, 'all')
|
||||
data = o.data.data;
|
||||
else
|
||||
data = o.data{o.seriestoplot{:}}.data;
|
||||
end
|
||||
|
||||
x=[1:1:o.data.nobs];
|
||||
xlabels=getDatesCellStringArray(o.data.time);
|
||||
|
||||
plot(x, data);
|
||||
|
||||
if ~isempty(o.shade)
|
||||
x1 = strmatch(lower(o.shade{1}), xlabels, 'exact');
|
||||
x2 = strmatch(lower(o.shade{2}), xlabels, 'exact');
|
||||
yrange = get(gca, 'YLim');
|
||||
|
||||
% From ShadePlotForEmpahsis (Matlab Exchange)
|
||||
% use patch bc area doesn't work with matlab2tikz
|
||||
patch([repmat(x1, 1, 2) repmat(x2, 1, 2)], [yrange fliplr(yrange)], ...
|
||||
'b', 'FaceAlpha', .2);
|
||||
end
|
||||
|
||||
set(gca,'XTick', x);
|
||||
set(gca,'XTickLabel', xlabels);
|
||||
|
||||
if o.legend
|
||||
if strcmpi(o.seriestoplot, 'all')
|
||||
lh = legend(o.data.name);
|
||||
else
|
||||
lh = legend(o.seriestoplot{:});
|
||||
end
|
||||
set(lh, 'orientation', o.legend_orientation);
|
||||
set(lh, 'Location', o.legend_location);
|
||||
set(lh, 'FontSize', o.legend_font_size);
|
||||
legend('boxoff');
|
||||
end
|
||||
|
||||
if ~isempty(o.xlabel)
|
||||
xlabel(['$\textbf{\footnotesize ' o.xlabel '}$'],'Interpreter','LaTex');
|
||||
end
|
||||
|
||||
if ~isempty(o.ylabel)
|
||||
ylabel(['$\textbf{\footnotesize ' o.ylabel '}$'],'Interpreter','LaTex');
|
||||
end
|
||||
|
||||
if ~isempty(o.title)
|
||||
title(['$\textbf{\large ' o.title '}$'],'Interpreter','LaTex');
|
||||
end
|
||||
drawnow;
|
||||
|
||||
o.figname = ['figure-' num2str(cputime) '.tex'];
|
||||
matlab2tikz('filename', o.figname, ...
|
||||
'showInfo', false, ...
|
||||
'showWarnings', false, ...
|
||||
'checkForUpdates', false);
|
||||
|
||||
box off;
|
||||
hold off;
|
||||
close(h);
|
||||
clear h;
|
||||
end
|
|
@ -30,9 +30,19 @@ function display(o)
|
|||
|
||||
name = 'report.page.section.graph';
|
||||
disp(' ');
|
||||
disp([name '.caption = ']);
|
||||
disp([name '.title = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.caption '''']);
|
||||
disp([' ''' o.title '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.xlabel = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.xlabel '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.ylabel = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.ylabel '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.footnote = ']);
|
||||
|
@ -40,7 +50,32 @@ disp(' ');
|
|||
disp([' ''' o.footnote '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.filename = ']);
|
||||
disp([name '.figname = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.filename '''']);
|
||||
disp([' ''' o.figname '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.data = ']);
|
||||
disp(' ');
|
||||
display(o.data);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.seriestoplot = ']);
|
||||
disp(' ');
|
||||
disp(o.seriestoplot);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.config = ']);
|
||||
disp(' ');
|
||||
disp([' ''' o.config '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.legend = ']);
|
||||
disp(' ');
|
||||
disp(o.legend);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.shade = ']);
|
||||
disp(' ');
|
||||
disp(o.shade);
|
||||
end
|
|
@ -30,12 +30,25 @@ function o = graph(varargin)
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
o = struct;
|
||||
o.caption = '';
|
||||
o.footnote = '';
|
||||
o.filename = '';
|
||||
o.data = '';
|
||||
|
||||
o.config = '';
|
||||
|
||||
o.title = '';
|
||||
o.ylabel = '';
|
||||
o.xlabel = '';
|
||||
o.zlabel = '';
|
||||
o.footnote = '';
|
||||
|
||||
o.figname = '';
|
||||
o.data = '';
|
||||
o.seriestoplot = 'all';
|
||||
o.shade = ''; %{1959q1:1964q4}
|
||||
|
||||
o.legend = false;
|
||||
o.legend_location = 'SouthEast';
|
||||
o.legend_orientation = 'horizontal';
|
||||
o.legend_font_size = 8;
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'graph'),['With one arg to Graph constructor, ' ...
|
||||
'you must pass a graph object']);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
function write(o, fid, texIndent)
|
||||
%function write(o, fid)
|
||||
% Write a Page object
|
||||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write a Graph object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% fid - int, file id
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
% o - this
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
@ -28,13 +28,9 @@ function write(o, fid, texIndent)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(fid > 0);
|
||||
assert(isnumeric(texIndent));
|
||||
|
||||
fprintf(fid, '%d\% Page Object\n', texIndent);
|
||||
fprintf(fid, '%d\newpage\n', texIndent);
|
||||
|
||||
o.sections.write(fid, texIndent+2);
|
||||
|
||||
fprintf(fid, '%d\% End Page Object\n', texIndent);
|
||||
assert(fid ~= -1);
|
||||
if isempty(o.figname)
|
||||
o = createGraph(o);
|
||||
end
|
||||
fprintf(fid, '\\input{%s}', o.figname);
|
||||
end
|
|
@ -30,10 +30,5 @@ function p = addSection(p, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(isa(p, 'page'), 'First argument must be a page object');
|
||||
if nargin == 1
|
||||
p.sections = p.sections.addSection();
|
||||
elseif nargin == 2 || nargin == 3
|
||||
p.sections = p.sections.addSection(varargin{:});
|
||||
end
|
||||
p.sections = p.sections.addSection(varargin{:});
|
||||
end
|
||||
|
|
|
@ -30,12 +30,13 @@ function o = page(varargin)
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
o = struct;
|
||||
o.caption = '';
|
||||
o.orientation = 'portrait';
|
||||
o.paper = '';
|
||||
o.title = '';
|
||||
o.orientation = '';
|
||||
o.sections = sections();
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'page'),['With one arg to Page constructor, ' ...
|
||||
assert(isa(varargin{1}, 'page'), ['With one arg to Page constructor, ' ...
|
||||
'you must pass a page object']);
|
||||
o = varargin{1};
|
||||
return;
|
||||
|
|
|
@ -23,13 +23,6 @@ switch S(1).type
|
|||
switch S(1).subs
|
||||
case fieldnames(A)
|
||||
A = A.(S(1).subs);
|
||||
case {'write'}
|
||||
if areParensNext(S)
|
||||
write(A, S(2).subs{:})
|
||||
S = shiftS(S);
|
||||
else
|
||||
assert(false);
|
||||
end
|
||||
case methods(A)
|
||||
if areParensNext(S)
|
||||
A = feval(S(1).subs, A, S(2).subs{:});
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
function write(o, fid, indent)
|
||||
%function write(o, fid, indent)
|
||||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write a Page object
|
||||
%
|
||||
% INPUTS
|
||||
% fid - int, file id
|
||||
% indent - char, number of spaces to indent tex code
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
% o - this
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
@ -31,14 +30,19 @@ function write(o, fid, indent)
|
|||
|
||||
assert(fid ~= -1);
|
||||
|
||||
fprintf(fid, '\n%s%% Page Object\n', indent);
|
||||
fprintf(fid, '\n%% Page Object\n');
|
||||
if ~isempty(o.title)
|
||||
fprintf(fid, '\\centerline{{\\Large %s}}\n', o.title);
|
||||
end
|
||||
if strcmpi(o.orientation, 'landscape')
|
||||
fprintf(fid, '%s\\begin{landscape}\n', indent);
|
||||
fprintf(fid, '\\begin{landscape}\n')
|
||||
end
|
||||
o.sections.write(fid, addIndentation(indent));
|
||||
|
||||
o.sections.write(fid);
|
||||
|
||||
if strcmpi(o.orientation, 'landscape')
|
||||
fprintf(fid, '%s\\end{landscape}\n', indent);
|
||||
fprintf(fid, '\\end{landscape}\n');
|
||||
end
|
||||
fprintf(fid, '%s\\clearpage\n', indent);
|
||||
fprintf(fid, '%s%% End Page Object\n\n', indent);
|
||||
fprintf(fid, '\\clearpage\n');
|
||||
fprintf(fid, '%% End Page Object\n\n');
|
||||
end
|
|
@ -18,10 +18,11 @@ function ps = addPage(ps, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(nargin >= 1 && nargin <= 3)
|
||||
if nargin == 1
|
||||
ps.objArray = ps.objArray.addObj(page());
|
||||
else
|
||||
ps.objArray = ps.objArray.addObj(varargin{:});
|
||||
end
|
||||
ps.objArray = ps.objArray.addObj(page(varargin{:}));
|
||||
%assert(nargin >= 1 && nargin <= 3)
|
||||
%if nargin == 1
|
||||
% ps.objArray = ps.objArray.addObj(page());
|
||||
%else
|
||||
% ps.objArray = ps.objArray.addObj(varargin{:});
|
||||
%end
|
||||
end
|
|
@ -23,13 +23,6 @@ switch S(1).type
|
|||
switch S(1).subs
|
||||
case fieldnames(A)
|
||||
A = A.(S(1).subs);
|
||||
case {'write'}
|
||||
if areParensNext(S)
|
||||
write(A, S(2).subs{:})
|
||||
S = shiftS(S);
|
||||
else
|
||||
assert(false);
|
||||
end
|
||||
case methods(A)
|
||||
if areParensNext(S)
|
||||
A = feval(S(1).subs, A, S(2).subs{:});
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
function write(o, fid, indent)
|
||||
%function write(o, fid, indent)
|
||||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write Pages object
|
||||
%
|
||||
% INPUTS
|
||||
% fid - int, file id
|
||||
% indent - char, number of spaces to indent tex code
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
% o - this
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
@ -30,10 +29,10 @@ function write(o, fid, indent)
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(fid ~= -1);
|
||||
fprintf(fid, '\n%s%% Pages Object\n', indent);
|
||||
fprintf(fid, '\n%% Pages Object\n');
|
||||
nps = numPages(o);
|
||||
for i=1:nps
|
||||
o.objArray(i).write(fid, addIndentation(indent));
|
||||
o.objArray(i).write(fid);
|
||||
end
|
||||
fprintf(fid, '%s%% End Pages Object\n\n', indent);
|
||||
fprintf(fid, '%% End Pages Object\n\n');
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
function r = addPage(r, varargin)
|
||||
%function r = addPage(r, varargin)
|
||||
function o = addPage(o, varargin)
|
||||
%function o = addPage(o, varargin)
|
||||
% Add a page to the Cell Array of pages in the report
|
||||
%
|
||||
% INPUTS
|
||||
|
@ -30,21 +30,22 @@ function r = addPage(r, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(nargin >= 1 && nargin <= 3, ['incorrect number of arguments passed ' ...
|
||||
'to addPage']);
|
||||
assert(isa(r, 'report'), 'First argument must be a report object');
|
||||
if nargin > 1
|
||||
assert(isa(varargin{1},'page'), ['Optional 2nd arg to addPage must be a ' ...
|
||||
'Page']);
|
||||
if nargin > 2
|
||||
assert(isnumeric(varargin{2}), ['Optional 3rd arg to addPage must be ' ...
|
||||
'an index']);
|
||||
end
|
||||
end
|
||||
%assert(nargin >= 1 && nargin <= 3, ['incorrect number of arguments passed ' ...
|
||||
% 'to addPage']);
|
||||
%assert(isa(r, 'report'), 'First argument must be a report object');
|
||||
%if nargin > 1
|
||||
% assert(isa(varargin{1},'page'), ['Optional 2nd arg to addPage must be a ' ...
|
||||
% 'Page']);
|
||||
% if nargin > 2
|
||||
% assert(isnumeric(varargin{2}), ['Optional 3rd arg to addPage must be ' ...
|
||||
% 'an index']);
|
||||
% end
|
||||
%end
|
||||
|
||||
if nargin == 1
|
||||
r.pages = r.pages.addPage();
|
||||
elseif nargin == 2 || nargin == 3
|
||||
r.pages = r.pages.addPage(varargin{:});
|
||||
o.pages = o.pages.addPage('orientation', o.orientation, 'paper', o.paper);
|
||||
else
|
||||
o.pages = o.pages.addPage('orientation', o.orientation, 'paper', ...
|
||||
o.paper, varargin{:});
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,6 +34,7 @@ o = struct;
|
|||
o.title = '';
|
||||
o.orientation = 'portrait';
|
||||
o.paper = 'a4';
|
||||
o.margin = '2cm';
|
||||
o.pages = pages();
|
||||
o.filename = 'report.tex';
|
||||
o.config = '';
|
||||
|
|
|
@ -23,13 +23,6 @@ switch S(1).type
|
|||
switch S(1).subs
|
||||
case fieldnames(A)
|
||||
A = A.(S(1).subs);
|
||||
case {'write'}
|
||||
if areParensNext(S)
|
||||
write(A, S(2).subs{:})
|
||||
S = shiftS(S);
|
||||
else
|
||||
write(A);
|
||||
end
|
||||
case methods(A)
|
||||
if areParensNext(S)
|
||||
A = feval(S(1).subs, A, S(2).subs{:});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
function write(o)
|
||||
%function write(o)
|
||||
function o = write(o)
|
||||
%function o = write(o)
|
||||
% Write Report object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% o - Report Object
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
% o - Report Object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
@ -36,16 +36,18 @@ end
|
|||
fprintf(fid, '%% Report Object\n');
|
||||
fprintf(fid, '\\documentclass[11pt]{article}\n');
|
||||
|
||||
fprintf(fid, '\\usepackage[%spaper,margin=2.5cm', o.paper);
|
||||
fprintf(fid, '\\usepackage[%spaper,margin=%s', o.paper, o.margin);
|
||||
if strcmpi(o.orientation, 'landscape')
|
||||
fprintf(fid, ',landscape');
|
||||
end
|
||||
fprintf(fid, ']{geometry}\n');
|
||||
fprintf(fid, '\\usepackage{graphicx}\n');
|
||||
fprintf(fid, '\\usepackage{pdflscape}\n')
|
||||
fprintf(fid, '\\usepackage{pdflscape}\n');
|
||||
fprintf(fid, '\\usepackage{pgf}\n');
|
||||
fprintf(fid, '\\usepackage{pgfplots}\n');
|
||||
fprintf(fid, '\\begin{document}\n');
|
||||
|
||||
o.pages.write(fid, addIndentation(''));
|
||||
o.pages.write(fid);
|
||||
|
||||
fprintf(fid, '\\end{document}\n');
|
||||
fprintf(fid, '%% End Report Object\n');
|
||||
|
|
|
@ -30,10 +30,5 @@ function o = addGraph(o, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(isa(o, 'section'), 'First argument must be a section object');
|
||||
if nargin == 1
|
||||
o.elements = o.elements.addGraph();
|
||||
elseif nargin == 2 || nargin == 3
|
||||
o.elements = o.elements.addGraph(varargin{:});
|
||||
end
|
||||
o.elements = o.elements.addGraph(varargin{:});
|
||||
end
|
||||
|
|
|
@ -30,10 +30,5 @@ function o = addTable(o, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(isa(o, 'section'), 'First argument must be a section object');
|
||||
if nargin == 1
|
||||
o.elements = o.elements.addTable();
|
||||
elseif nargin == 2 || nargin == 3
|
||||
o.elements = o.elements.addTable(varargin{:});
|
||||
end
|
||||
o.elements = o.elements.addTable(varargin{:});
|
||||
end
|
||||
|
|
|
@ -34,9 +34,13 @@ disp([name '.align = ']);
|
|||
disp(' ');
|
||||
disp([' ''' o.align '''']);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.cols = ']);
|
||||
disp(' ');
|
||||
disp(o.cols);
|
||||
|
||||
disp(' ');
|
||||
disp([name '.elements = ']);
|
||||
disp(' ');
|
||||
disp(o.elements.getElements());
|
||||
|
||||
end
|
|
@ -23,10 +23,8 @@ function o = section(varargin)
|
|||
o = struct;
|
||||
o.align = 't';
|
||||
o.elements = elements();
|
||||
o.rows = 1;
|
||||
o.cols = 1;
|
||||
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'section'),['With one arg to Section constructor, ' ...
|
||||
'you must pass a section object']);
|
||||
|
@ -55,4 +53,3 @@ end
|
|||
% Create section object
|
||||
o = class(o, 'section');
|
||||
end
|
||||
|
||||
|
|
|
@ -23,13 +23,6 @@ switch S(1).type
|
|||
switch S(1).subs
|
||||
case fieldnames(A)
|
||||
A = A.(S(1).subs);
|
||||
case {'write'}
|
||||
if areParensNext(S)
|
||||
write(A, S(2).subs{:})
|
||||
S = shiftS(S);
|
||||
else
|
||||
assert(false);
|
||||
end
|
||||
case methods(A)
|
||||
if areParensNext(S)
|
||||
A = feval(S(1).subs, A, S(2).subs{:});
|
||||
|
@ -41,7 +34,7 @@ switch S(1).type
|
|||
error(['Section Class: unknown field or method: ' S(1).subs]);
|
||||
end
|
||||
case '()'
|
||||
A = getElements(A, S(1).subs{:});
|
||||
A = A.elements.getElements(S(1).subs{:});
|
||||
case '{}'
|
||||
error(['Section Class: ' S(1).type ' indexing not supported.']);
|
||||
otherwise
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
function write(o, fid, indent)
|
||||
%function write(o, fid, indent)
|
||||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write Section object
|
||||
%
|
||||
% INPUTS
|
||||
% fid - int, file id
|
||||
% indent - char, number of spaces to indent tex code
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
% o - this
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
@ -31,14 +30,30 @@ function write(o, fid, indent)
|
|||
|
||||
assert(fid ~= -1);
|
||||
|
||||
fprintf(fid, '\n%s%% Section Object\n', indent);
|
||||
fprintf(fid, '%s\\noindent\\begin{minipage}[%s]{0.32\\hsize}\n', indent, o.align);
|
||||
fprintf(fid, '%% Section Object\n');
|
||||
fprintf(fid, '\\begin{table}[%shtpb]\n', o.align);
|
||||
fprintf(fid, '\\resizebox{\\textwidth}{!}{\n');
|
||||
fprintf(fid, '\\begin{tabular}{');
|
||||
for i=1:o.cols
|
||||
fprintf(fid, 'c');
|
||||
end
|
||||
fprintf(fid, '}\n');
|
||||
|
||||
% Calculate scaling factor
|
||||
%sf = round(100/o.cols)/100-.01;
|
||||
|
||||
ne = numElements(o);
|
||||
for i=1:ne
|
||||
o.elements(i).write(fid, addIndentation(indent));
|
||||
o.elements(i).write(fid);
|
||||
if rem(i, o.cols)
|
||||
fprintf(fid, ' & ');
|
||||
else
|
||||
fprintf(fid, '\\\\\n');
|
||||
end
|
||||
end
|
||||
|
||||
fprintf(fid, '%s\\end{minipage}\n', indent);
|
||||
fprintf(fid, '%s%% End Section Object\n\n', indent);
|
||||
fprintf(fid, '\\end{tabular}\n');
|
||||
fprintf(fid, '}\n');
|
||||
fprintf(fid, '\\end{table}\n');
|
||||
fprintf(fid, '%% End Section Object\n\n');
|
||||
end
|
|
@ -18,15 +18,5 @@ function ss = addSection(ss, varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(nargin >= 1 && nargin <= 3)
|
||||
if nargin > 1
|
||||
assert(isa(varargin{1},'section'), ['Optional 2nd arg to addSection ' ...
|
||||
'must be a Section']);
|
||||
end
|
||||
|
||||
if nargin == 1
|
||||
ss.objArray = ss.objArray.addObj(section());
|
||||
else
|
||||
ss.objArray = ss.objArray.addObj(varargin{:});
|
||||
end
|
||||
ss.objArray = ss.objArray.addObj(section(varargin{:}));
|
||||
end
|
|
@ -23,13 +23,6 @@ switch S(1).type
|
|||
switch S(1).subs
|
||||
case fieldnames(A)
|
||||
A = A.(S(1).subs);
|
||||
case {'write'}
|
||||
if areParensNext(S)
|
||||
write(A, S(2).subs{:})
|
||||
S = shiftS(S);
|
||||
else
|
||||
assert(false);
|
||||
end
|
||||
case methods(A)
|
||||
if areParensNext(S)
|
||||
A = feval(S(1).subs, A, S(2).subs{:});
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
function write(o, fid, indent)
|
||||
%function write(o, fid, indent)
|
||||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write Sections object
|
||||
%
|
||||
% INPUTS
|
||||
% fid - int, file id
|
||||
% indent - char, number of spaces to indent tex code
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
% o - this
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
@ -30,10 +29,10 @@ function write(o, fid, indent)
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
assert(fid ~= -1);
|
||||
fprintf(fid, '\n%s%% Sections Object\n', indent);
|
||||
fprintf(fid, '\n%% Sections Object\n');
|
||||
nps = numSections(o);
|
||||
for i=1:nps
|
||||
o.objArray(i).write(fid, indent);
|
||||
o.objArray(i).write(fid);
|
||||
end
|
||||
fprintf(fid, '%s%% End Sections Object\n\n', indent);
|
||||
fprintf(fid, '%% End Sections Object\n\n');
|
||||
end
|
|
@ -1,12 +1,12 @@
|
|||
function write(o, fid, texIndent)
|
||||
%function write(o, fid)
|
||||
% Write a Page object
|
||||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write a Table object
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
% fid - int, file id
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
% o - this
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
@ -31,10 +31,7 @@ function write(o, fid, texIndent)
|
|||
assert(fid > 0);
|
||||
assert(isnumeric(texIndent));
|
||||
|
||||
fprintf(fid, '%d\% Page Object\n', texIndent);
|
||||
fprintf(fid, '%d\newpage\n', texIndent);
|
||||
fprintf(fid, '%% Page Object\n');
|
||||
|
||||
o.sections.write(fid, texIndent+2);
|
||||
|
||||
fprintf(fid, '%d\% End Page Object\n', texIndent);
|
||||
fprintf(fid, '%% End Page Object\n');
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
function spaces=addIndentation(spaces)
|
||||
% Return new level of indentation for latex output
|
||||
%
|
||||
% INPUTS
|
||||
% spaces - char, current level of indentation
|
||||
%
|
||||
% OUTPUTS
|
||||
% spaces - char, new level of indentation
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
spaces = [spaces ' '];
|
||||
end
|
Loading…
Reference in New Issue