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.4 2008/01/15 17:36:36 ingo 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.4 2008/01/15 17:36:36 ingo Exp $
0015 %
0016 % HISTORY:     23-07-2007 Diepholz
0017 %                 Creation
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 VERSION = '$Id: display.m,v 1.4 2008/01/15 17:36:36 ingo Exp $';
0022 
0023 % Check if this is a call for parameters or for the cvs-version number
0024 if nargin == 2
0025   if isa(tt, 'timeformat') && ischar(varargin{1})
0026     in = char(varargin{1});
0027     if strcmp(in, 'Params')
0028       txt = plist();
0029       return
0030     elseif strcmp(in, 'Version')
0031       txt = VERSION;
0032       return
0033     end
0034   end
0035 end
0036 
0037 txt = {};
0038 
0039 for ii = 1:numel(tt)
0040   t = tt(ii);
0041 
0042   b_banner = sprintf('---------- timeformat %02d ----------', ii);
0043   txt{end+1} = b_banner;
0044   txt{end+1} = ' ';
0045 
0046   fields = fieldnames(t);
0047   max_length = length(fields{1});
0048   for jj = 2:length(fields)
0049     if length(fields{jj}) > max_length
0050       max_length = length(fields{jj});
0051     end
0052   end
0053 
0054   for jj = 1:length(fields)
0055     field = fields{jj};
0056 
0057     str_field = [];
0058     str_field(1:max_length-length(field)) = ' ';
0059     str_field = [field str_field];
0060 
0061     % Display: Number
0062     if isnumeric(t.(field))
0063       txt{end+1} = sprintf ('%s: %s',str_field, num2str(t.(field)));
0064 
0065     % Display: Strings
0066     elseif ischar(t.(field))
0067       txt{end+1} = sprintf ('%s: %s',str_field, t.(field));
0068 
0069     % Display: Logicals
0070     elseif islogical(t.(field))
0071       if t.(field) == true
0072         txt{end+1} = sprintf ('%s: true',str_field);
0073       else
0074         txt{end+1} = sprintf ('%s: false',str_field);
0075       end
0076 
0077     % Display: Objects
0078     elseif isobject(t.(field))
0079       txt{end+1} = sprintf ('%s: %s class',str_field, class(t.(field)));
0080 
0081     % Display: Java Objects
0082     elseif isjava(t.(field))
0083         error ('### Unknown java class %s', class(t.(field)))
0084 
0085     else
0086       error ('### Please define the output for this property %s', field)
0087     end
0088 
0089   end
0090 
0091 
0092   e_banner(1:length(b_banner)) = '-';
0093   txt{end+1} = e_banner;
0094 
0095   txt{end+1} = ' ';
0096   txt{end+1} = ' ';
0097 
0098 end
0099 
0100 if nargout == 0
0101   for ii=1:length(txt)
0102     disp(txt{ii});
0103   end
0104 end
0105 
0106

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003