Home > classes > @timeformat > display.m

display

PURPOSE ^

DISPLAY overloads display functionality for timeformat objects.

SYNOPSIS ^

function txt = display(tt)

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.2 2007/09/12 14:01:38 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)
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.2 2007/09/12 14:01:38 ingo Exp $
0015 %
0016 % HISTORY:     23-07-2007 Diepholz
0017 %                 Creation
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 txt = {};
0022 
0023 tt = reshape(tt, numel(tt), 1);
0024 
0025 for ii = 1:length(tt)
0026   t = tt(ii);
0027 
0028   b_banner = sprintf('---------- timeformat %02d ----------', ii);
0029   txt{end+1} = b_banner;
0030   txt{end+1} = ' ';
0031 
0032   fields = fieldnames(t);
0033   max_length = length(fields{1});
0034   for jj = 2:length(fields)
0035     if length(fields{jj}) > max_length
0036       max_length = length(fields{jj});
0037     end
0038   end
0039 
0040   for jj = 1:length(fields)
0041     field = fields{jj};
0042 
0043     str_field = [];
0044     str_field(1:max_length-length(field)) = ' ';
0045     str_field = [field str_field];
0046 
0047     % Display: Number
0048     if isnumeric(t.(field))
0049       txt{end+1} = sprintf ('%s: %s',str_field, num2str(t.(field)));
0050 
0051     % Display: Strings
0052     elseif ischar(t.(field))
0053       txt{end+1} = sprintf ('%s: %s',str_field, t.(field));
0054 
0055     % Display: Logicals
0056     elseif islogical(t.(field))
0057       if t.(field) == true
0058         txt{end+1} = sprintf ('%s: true',str_field);
0059       else
0060         txt{end+1} = sprintf ('%s: false',str_field);
0061       end
0062 
0063     % Display: Objects
0064     elseif isobject(t.(field))
0065       txt{end+1} = sprintf ('%s: %s class',str_field, class(t.(field)));
0066 
0067     % Display: Java Objects
0068     elseif isjava(t.(field))
0069         error ('### Unknown java class %s', class(t.(field)))
0070 
0071     else
0072       error ('### Please define the output for this property %s', field)
0073     end
0074 
0075   end
0076 
0077 
0078   e_banner(1:length(b_banner)) = '-';
0079   txt{end+1} = e_banner;
0080 
0081   txt{end+1} = ' ';
0082   txt{end+1} = ' ';
0083 
0084 end
0085 
0086 if nargout == 0
0087   for ii=1:length(txt)
0088     disp(txt{ii});
0089   end
0090 end
0091 
0092

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003