Home > classes > @time > display.m

display

PURPOSE ^

DISPLAY overloads display functionality for time objects.

SYNOPSIS ^

function varargout = display(varargin)

DESCRIPTION ^

 DISPLAY overloads display functionality for time objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: DISPLAY overloads display functionality for time objects.

 CALL:        txt  = display(time)

 INPUT:       time - time object

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

 M-FILE INFO: Get information about this methods by calling
              >> time.getInfo('display')

              Get information about a specified set-plist by calling:
              >> time.getInfo('display', 'set')

 VERSION:     $Id: display.m,v 1.19 2008/09/04 15:29:31 ingo Exp $

 HISTORY:     23-07-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % DISPLAY overloads display functionality for time objects.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: DISPLAY overloads display functionality for time objects.
0005 %
0006 % CALL:        txt  = display(time)
0007 %
0008 % INPUT:       time - time object
0009 %
0010 % OUTPUT:      txt  - cell array with strings to display the time object
0011 %
0012 % M-FILE INFO: Get information about this methods by calling
0013 %              >> time.getInfo('display')
0014 %
0015 %              Get information about a specified set-plist by calling:
0016 %              >> time.getInfo('display', 'set')
0017 %
0018 % VERSION:     $Id: display.m,v 1.19 2008/09/04 15:29:31 ingo Exp $
0019 %
0020 % HISTORY:     23-07-2007 Diepholz
0021 %                 Creation
0022 %
0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0024 
0025 function varargout = display(varargin)
0026 
0027   %%% Check if this is a call for parameters
0028   if utils.helper.isinfocall(varargin{:})
0029     varargout{1} = getInfo(varargin{3});
0030     return
0031   end
0032 
0033   % Collect all time-objects
0034   tt = utils.helper.collect_objects(varargin(:), 'time');
0035 
0036   txt = {};
0037 
0038   for ii = 1:numel(tt)
0039     t = tt(ii);
0040 
0041     b_banner = sprintf('---------- time %02d ----------', ii);
0042     txt{end+1} = b_banner;
0043     txt{end+1} = ' ';
0044 
0045     fields = fieldnames(t);
0046     max_length = length(fields{1});
0047     for jj = 2:length(fields)
0048       if length(fields{jj}) > max_length
0049         max_length = length(fields{jj});
0050       end
0051     end
0052 
0053     for jj = 1:length(fields)
0054       field = fields{jj};
0055 
0056       str_field = [];
0057       str_field(1:max_length-length(field)) = ' ';
0058       str_field = [field str_field];
0059 
0060       %%% Special case: ----- time_str -----
0061       %%% Compute the property time_str
0062       if strcmp(field, 'time_str')
0063         time_str = time.epoch2str(t);
0064         txt{end+1} = sprintf ('%s: %s',str_field, time_str);
0065         continue
0066       end
0067 
0068       % Add before the fields 'created' and 'version' a blank line
0069       if strcmp(field, 'created')
0070         txt{end+1} = ' ';
0071       end
0072 
0073       %%% Special case: ----- created -----
0074       %%% Compute the property created
0075       if strcmp(field, 'created')
0076         [time_str, created_str] = epoch2str(t);
0077         txt{end+1} = sprintf ('%s: %s',str_field, created_str);
0078         continue
0079       end
0080 
0081       % Display: Number
0082       if isnumeric(t.(field))
0083         txt{end+1} = sprintf ('%s: %s',str_field, num2str(t.(field)));
0084 
0085         % Display: Strings
0086       elseif ischar(t.(field))
0087         txt{end+1} = sprintf ('%s: %s',str_field, t.(field));
0088 
0089         % Display: Logicals
0090       elseif islogical(t.(field))
0091         if t.(field) == true
0092           txt{end+1} = sprintf ('%s: true',str_field);
0093         else
0094           txt{end+1} = sprintf ('%s: false',str_field);
0095         end
0096 
0097         % Display: Objects
0098       elseif isobject(t.(field))
0099         if isa(t.(field), 'timeformat') || isa(t.(field), 'plist')
0100           txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field)));
0101         else
0102           txt{end+1} = sprintf ('%s: %s class',str_field, class(t.(field)));
0103         end
0104 
0105         % Display: Java Objects
0106       elseif isjava(t.(field))
0107         if strcmp(class(t.(field)), 'sun.util.calendar.ZoneInfo')
0108           EE = java.text.SimpleDateFormat('Z');
0109           EE.setTimeZone(t.(field))
0110           zone_id = t.(field).getID;
0111           if strcmp(zone_id, 'UTC')
0112             txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field).getID));
0113           else
0114             txt{end+1} = sprintf ('%s: %s (UTC%s)',str_field, char(t.(field).getID), char(EE.format(t.utc_epoch_milli)));
0115           end
0116         else
0117           error ('### Unknown java class %s', class(t.(field)))
0118         end
0119 
0120       else
0121         error ('### Please define the output for this property %s', field)
0122       end
0123 
0124     end
0125 
0126     e_banner(1:length(b_banner)) = '-';
0127     txt{end+1} = e_banner;
0128 
0129     txt{end+1} = ' ';
0130     txt{end+1} = ' ';
0131   end
0132 
0133   if nargout == 0
0134     for ii=1:length(txt)
0135       disp(txt{ii});
0136     end
0137   end
0138 
0139   varargout{1} = txt;
0140 end
0141 
0142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0143 %                               Local Functions                               %
0144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0145 
0146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0147 %
0148 % FUNCTION:    getInfo
0149 %
0150 % DESCRIPTION: Get Info Object
0151 %
0152 % HISTORY:     11-07-07 M Hewitson
0153 %                Creation.
0154 %
0155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0156 
0157 function ii = getInfo(varargin)
0158   if nargin == 1 && strcmpi(varargin{1}, 'None')
0159     sets = {};
0160     pl   = [];
0161   else
0162     sets = {'Default'};
0163     pl   = getDefaultPlist;
0164   end
0165   % Build info object
0166   ii = minfo(mfilename, 'time', '', utils.const.categories.output, '$Id: display.m,v 1.19 2008/09/04 15:29:31 ingo Exp $', sets, pl);
0167 end
0168 
0169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0170 %
0171 % FUNCTION:    getDefaultPlist
0172 %
0173 % DESCRIPTION: Get Default Plist
0174 %
0175 % HISTORY:     11-07-07 M Hewitson
0176 %                Creation.
0177 %
0178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0179 
0180 function plo = getDefaultPlist()
0181   plo = plist();
0182 end
0183

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003