From 7037e2a4bced9d0028ad228434e7d9dd733ade8a Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Wed, 15 May 2013 17:11:13 +0200 Subject: [PATCH] reporting: centralize/automate display.m --- matlab/reports/@elements/display.m | 8 +- matlab/reports/@graph/display.m | 36 +-------- matlab/reports/@objArray/display.m | 7 +- matlab/reports/@page/display.m | 8 +- matlab/reports/@pages/display.m | 8 +- matlab/reports/@report/display.m | 31 +------- matlab/reports/@section/display.m | 14 +--- matlab/reports/@sections/display.m | 8 +- matlab/reports/@series/display.m | 62 +--------------- matlab/reports/@seriesElements/display.m | 11 +-- matlab/reports/@table/display.m | 28 +------ matlab/reports/@vspace/display.m | 32 ++++++++ matlab/reports/reporting_object_display.m | 89 +++++++++++++++++++++++ 13 files changed, 141 insertions(+), 201 deletions(-) create mode 100644 matlab/reports/@vspace/display.m create mode 100644 matlab/reports/reporting_object_display.m diff --git a/matlab/reports/@elements/display.m b/matlab/reports/@elements/display.m index 9f6348c21..1c13a194f 100644 --- a/matlab/reports/@elements/display.m +++ b/matlab/reports/@elements/display.m @@ -3,7 +3,7 @@ function display(o) % Display a Elements object % % INPUTS -% none +% o [elements] elements object % % OUTPUTS % none @@ -28,9 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.page.section.elements'; -disp(' '); -disp([name ' = ']); -disp(' '); -disp(getElements(o)); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@graph/display.m b/matlab/reports/@graph/display.m index e2d1f21be..9ddf4a08a 100644 --- a/matlab/reports/@graph/display.m +++ b/matlab/reports/@graph/display.m @@ -28,39 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.page.section.graph'; -disp(' '); -disp([name '.title = ']); -disp(' '); -disp([' ''' o.title '''']); - -disp(' '); -disp([name '.xlabel = ']); -disp(' '); -disp([' ''' o.xlabel '''']); - -disp(' '); -disp([name '.ylabel = ']); -disp(' '); -disp([' ''' o.ylabel '''']); - -disp(' '); -disp([name '.figname = ']); -disp(' '); -disp([' ''' o.figname '''']); - -disp(' '); -disp([name '.legend = ']); -disp(' '); -disp(o.legend); - -disp(' '); -disp([name '.shade = ']); -disp(' '); -disp(o.shade); - -disp(' '); -disp([name '.seriesElements = ']); -disp(' '); -o.seriesElements.getSeriesElements() +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@objArray/display.m b/matlab/reports/@objArray/display.m index e1665a1df..181ba5721 100644 --- a/matlab/reports/@objArray/display.m +++ b/matlab/reports/@objArray/display.m @@ -3,7 +3,7 @@ function display(oa) % Display an objArray object % % INPUTS -% none +% o [objArray] objArray object % % OUTPUTS % none @@ -28,8 +28,5 @@ function display(oa) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -disp(' '); -disp([inputname(1) '.objs = ']); -disp(' '); -disp(oa.objs); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@page/display.m b/matlab/reports/@page/display.m index b7ae6c66c..ebdcc9e0c 100644 --- a/matlab/reports/@page/display.m +++ b/matlab/reports/@page/display.m @@ -3,7 +3,7 @@ function display(o) % Display a Page object % % INPUTS -% none +% o [page] page object % % OUTPUTS % none @@ -28,9 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.page'; -disp(' '); -disp([name '.sections = ']); -disp(' '); -disp(o.sections()); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@pages/display.m b/matlab/reports/@pages/display.m index a76ab637f..728fd7c3e 100644 --- a/matlab/reports/@pages/display.m +++ b/matlab/reports/@pages/display.m @@ -3,7 +3,7 @@ function display(o) % Display a Pages object % % INPUTS -% ps [pages] pages object +% o [pages] pages object % % OUTPUTS % none @@ -28,9 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.pages'; -disp(' '); -disp([name ' = ']); -disp(' '); -disp(getPages(o)); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@report/display.m b/matlab/reports/@report/display.m index 3e7742963..92fe85a24 100644 --- a/matlab/reports/@report/display.m +++ b/matlab/reports/@report/display.m @@ -28,34 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report'; -disp(' '); -disp([name '.title = ']); -disp(' '); -disp([' ''' o.title '''']); - -disp(' ') -disp([name '.paper = ']); -disp(' '); -disp([' ''' o.paper '''']); - -disp(' ') -disp([name '.orientation = ']); -disp(' '); -disp([' ''' o.orientation '''']); - -disp(' ') -disp([name '.filename = ']); -disp(' '); -disp([' ''' o.filename '''']); - -disp(' ') -disp([name '.numPages() = ']); -disp(' '); -disp([' ' num2str(numPages(o))]); - -disp(' '); -disp([name '.pages = ']); -disp(' '); -disp(o.pages.getPages()); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@section/display.m b/matlab/reports/@section/display.m index f8dbb345b..8729efe66 100644 --- a/matlab/reports/@section/display.m +++ b/matlab/reports/@section/display.m @@ -3,7 +3,7 @@ function display(o) % Display a Section object % % INPUTS -% none +% o [section] section object % % OUTPUTS % none @@ -28,15 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.page.section'; - -disp(' '); -disp([name '.cols = ']); -disp(' '); -disp(o.cols); - -disp(' '); -disp([name '.elements = ']); -disp(' '); -disp(o.elements.getElements()); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@sections/display.m b/matlab/reports/@sections/display.m index 908bd3897..0e344d000 100644 --- a/matlab/reports/@sections/display.m +++ b/matlab/reports/@sections/display.m @@ -3,7 +3,7 @@ function display(o) % Display a Sections object % % INPUTS -% none +% o [sections] sections object % % OUTPUTS % none @@ -28,9 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'reports.page'; -disp(' '); -disp([name '.sections = ']); -disp(' '); -disp(getSections(o)); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@series/display.m b/matlab/reports/@series/display.m index 85ff7aebc..5ad241bee 100644 --- a/matlab/reports/@series/display.m +++ b/matlab/reports/@series/display.m @@ -28,65 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.page.section.graph.series'; -disp(' '); -disp([name '.data = ']); -disp(' '); -display(o.data); - -disp(' '); -disp([name '.graphLineColor = ']); -disp(' '); -disp([' ''' o.graphLineColor '''']); - -disp(' '); -disp([name '.graphLineStyle = ']); -disp(' '); -disp([' ''' o.graphLineStyle '''']); - -disp(' '); -disp([name '.graphLineWidth = ']); -disp(' '); -disp([' ''' o.graphLineWidth '''']); - -disp(' '); -disp([name '.graphMarker = ']); -disp(' '); -disp([' ''' o.graphMarker '''']); - -disp(' '); -disp([name '.graphMarkerEdgeColor = ']); -disp(' '); -disp([' ''' o.graphMarkerEdgeColor '''']); - -disp(' '); -disp([name '.graphMarkerFaceColor = ']); -disp(' '); -disp([' ''' o.graphMarkerFaceColor '''']); - -disp(' '); -disp([name '.graphMarkerSize = ']); -disp(' '); -disp([' ''' o.graphMarkerSize '''']); - -disp(' '); -disp([name '.tableAlignRight = ']); -disp(' '); -disp([' ''' o.tableAlignRight '''']); - -disp(' '); -disp([name '.tableNegColor = ']); -disp(' '); -disp([' ''' o.tableNegColor '''']); - -disp(' '); -disp([name '.tablePosColor = ']); -disp(' '); -disp([' ''' o.tablePosColor '''']); - -disp(' '); -disp([name '.tableShowMarkers = ']); -disp(' '); -disp([' ''' o.tableShowMarkers '''']); - +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@seriesElements/display.m b/matlab/reports/@seriesElements/display.m index 38061b3e9..ed1b330d1 100644 --- a/matlab/reports/@seriesElements/display.m +++ b/matlab/reports/@seriesElements/display.m @@ -1,9 +1,9 @@ function display(o) %function display(o) -% Display a Elements object +% Display a seriesElements object % % INPUTS -% none +% o [seriesElements] seriesElements object % % OUTPUTS % none @@ -28,10 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.page.section.elements.seriesElement'; - -disp(' '); -disp([name ' = ']); -disp(' '); -disp(getSeriesElements(o)); +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@table/display.m b/matlab/reports/@table/display.m index 71686e905..658722079 100644 --- a/matlab/reports/@table/display.m +++ b/matlab/reports/@table/display.m @@ -3,7 +3,7 @@ function display(o) % Display a Table object % % INPUTS -% none +% o [table] table object % % OUTPUTS % none @@ -28,29 +28,5 @@ function display(o) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -name = 'report.page.section.table'; -disp(' '); -disp([name '.title = ']); -disp(' '); -disp([' ''' o.title '''']); - -disp(' '); -disp([name '.showHlines = ']); -disp(' '); -disp(o.showHlines); - -disp(' '); -disp([name '.showVlines = ']); -disp(' '); -disp(o.showVlines); - -disp(' '); -disp([name '.precision = ']); -disp(' '); -disp(o.precision); - -disp(' '); -disp([name '.seriesElements = ']); -disp(' '); -o.seriesElements.getSeriesElements() +reporting_object_display(o); end \ No newline at end of file diff --git a/matlab/reports/@vspace/display.m b/matlab/reports/@vspace/display.m new file mode 100644 index 000000000..9d8e0097c --- /dev/null +++ b/matlab/reports/@vspace/display.m @@ -0,0 +1,32 @@ +function display(o) +%function display(o) +% Display a Vspace object +% +% INPUTS +% o [vspace] vspace object +% +% 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 . + +reporting_object_display(o); +end \ No newline at end of file diff --git a/matlab/reports/reporting_object_display.m b/matlab/reports/reporting_object_display.m new file mode 100644 index 000000000..a69b749c5 --- /dev/null +++ b/matlab/reports/reporting_object_display.m @@ -0,0 +1,89 @@ +function reporting_object_display(o) +%function reporting_object_display(o) +% Display a Reporting Object +% i.e., one of: elements +% graph +% objArray +% page +% pages +% report +% section +% sections +% series +% seriesElements +% table +% vspace +% +% INPUTS +% o [object] reporting object +% +% 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 . + +fprintf('\n%s Object = \n\n', upper(class(o))); +fields = fieldnames(o); +for i=1:length(fields) + fprintf(' %s: ', fields{i}); + val = o.(fields{i}); + if iscell(val) + fprintf('{'); + for j=1:length(val) + assert(ischar(val{j})); + fprintf('''%s''', val{j}); + if j~=length(val) + fprintf(', '); + end + end + fprintf('}'); + elseif ischar(val) + fprintf('''%s''', val); + elseif isnumeric(val) + fprintf('%s', num2str(val)); + elseif islogical(val) + if val + fprintf('true'); + else + fprintf('false'); + end + elseif isobject(val) + if isa(val, 'dynDates') + fprintf('', ... + val(1).format, val(end).format); + elseif isa(val, 'dynSeries') + if numel(val) == 1 + fprintf('', val.name{1}); + else + fprintf('%s', class(val)); + end + else + cl = class(val); + fprintf('%d', val.(['num' upper(cl(1)) cl(2:end)])); + end + else + keyboard + fprintf('fix this'); + end + fprintf('\n'); +end +fprintf('\n'); +end \ No newline at end of file