Home > classes > @timeformat > display.m

display

PURPOSE ^

DISPLAY overloads display functionality for timeformat objects.

SYNOPSIS ^

function txt = display(tt, varargin)

DESCRIPTION ^

 DISPLAY overloads display functionality for timeformat objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: DISPLAY overloads display functionality for timeformat objects.

 CALL:        txt = display(tf)

 INPUT:       tf  - timeformat object

 OUTPUT:      txt - cell array with strings to display the timeformat object

 VERSION:     $Id: display.m,v 1.5 2008/02/13 16:54:14 mauro Exp $

 HISTORY:     23-07-2007 Diepholz
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function txt = display(tt, varargin)
0002 % DISPLAY overloads display functionality for timeformat objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: DISPLAY overloads display functionality for timeformat objects.
0007 %
0008 % CALL:        txt = display(tf)
0009 %
0010 % INPUT:       tf  - timeformat object
0011 %
0012 % OUTPUT:      txt - cell array with strings to display the timeformat object
0013 %
0014 % VERSION:     $Id: display.m,v 1.5 2008/02/13 16:54:14 mauro Exp $
0015 %
0016 % HISTORY:     23-07-2007 Diepholz
0017 %                 Creation
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 VERSION = '$Id: display.m,v 1.5 2008/02/13 16:54:14 mauro Exp $';
0022 CATEGORY = 'Output';
0023 
0024 % Check if this is a call for parameters or for the cvs-version number
0025 if nargin == 2
0026   if isa(tt, 'timeformat') && ischar(varargin{1})
0027     in = char(varargin{1});
0028     if strcmp(in, 'Params')
0029       txt = plist();
0030       return
0031     elseif strcmp(in, 'Version')
0032       txt = VERSION;
0033       return
0034     elseif strcmp(in, 'Category')
0035       txt = CATEGORY;
0036       return
0037     end
0038   end
0039 end
0040 
0041 txt = {};
0042 
0043 for ii = 1:numel(tt)
0044   t = tt(ii);
0045 
0046   b_banner = sprintf('---------- timeformat %02d ----------', ii);
0047   txt{end+1} = b_banner;
0048   txt{end+1} = ' ';
0049 
0050   fields = fieldnames(t);
0051   max_length = length(fields{1});
0052   for jj = 2:length(fields)
0053     if length(fields{jj}) > max_length
0054       max_length = length(fields{jj});
0055     end
0056   end
0057 
0058   for jj = 1:length(fields)
0059     field = fields{jj};
0060 
0061     str_field = [];
0062     str_field(1:max_length-length(field)) = ' ';
0063     str_field = [field str_field];
0064 
0065     % Display: Number
0066     if isnumeric(t.(field))
0067       txt{end+1} = sprintf ('%s: %s',str_field, num2str(t.(field)));
0068 
0069     % Display: Strings
0070     elseif ischar(t.(field))
0071       txt{end+1} = sprintf ('%s: %s',str_field, t.(field));
0072 
0073     % Display: Logicals
0074     elseif islogical(t.(field))
0075       if t.(field) == true
0076         txt{end+1} = sprintf ('%s: true',str_field);
0077       else
0078         txt{end+1} = sprintf ('%s: false',str_field);
0079       end
0080 
0081     % Display: Objects
0082     elseif isobject(t.(field))
0083       txt{end+1} = sprintf ('%s: %s class',str_field, class(t.(field)));
0084 
0085     % Display: Java Objects
0086     elseif isjava(t.(field))
0087         error ('### Unknown java class %s', class(t.(field)))
0088 
0089     else
0090       error ('### Please define the output for this property %s', field)
0091     end
0092 
0093   end
0094 
0095 
0096   e_banner(1:length(b_banner)) = '-';
0097   txt{end+1} = e_banner;
0098 
0099   txt{end+1} = ' ';
0100   txt{end+1} = ' ';
0101 
0102 end
0103 
0104 if nargout == 0
0105   for ii=1:length(txt)
0106     disp(txt{ii});
0107   end
0108 end
0109 
0110

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003