Home > classes > @timespan > display.m

display

PURPOSE ^

DISPLAY overloads display functionality for timespan objects.

SYNOPSIS ^

function varargout = display(varargin)

DESCRIPTION ^

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

 DESCRIPTION: DISPLAY overloads display functionality for timespan objects.

 CALL:        txt = display(ts)

 INPUT:       ts  - timespan object

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

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

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

 VERSION:     $Id: display.m,v 1.9 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 timespan objects.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: DISPLAY overloads display functionality for timespan objects.
0005 %
0006 % CALL:        txt = display(ts)
0007 %
0008 % INPUT:       ts  - timespan object
0009 %
0010 % OUTPUT:      txt - cell array with strings to display the timespan object
0011 %
0012 % M-FILE INFO: Get information about this methods by calling
0013 %              >> timespan.getInfo('display')
0014 %
0015 %              Get information about a specified set-plist by calling:
0016 %              >> timespan.getInfo('display', 'None')
0017 %
0018 % VERSION:     $Id: display.m,v 1.9 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   ts = utils.helper.collect_objects(varargin(:), 'timespan');
0035 
0036   txt = {};
0037 
0038   for ii = 1:numel(ts)
0039     t = ts(ii);
0040 
0041     b_banner = sprintf('---------- timespan %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       % Add before the fields 'created' and 'version' a blank line
0061       if strcmp(field, 'created')
0062         txt{end+1} = ' ';
0063       end
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         if isa(t.(field), 'time') || isa(t.(field), 'timeformat') || isa(t.(field), 'plist') || isa(t.(field), 'provenance')
0084           txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field)));
0085         else
0086           txt{end+1} = sprintf ('%s: %s-object',str_field, class(t.(field)));
0087         end
0088 
0089         % Display: Java Objects
0090       elseif isjava(t.(field))
0091         if strcmp(class(t.(field)), 'sun.util.calendar.ZoneInfo')
0092           EE = java.text.SimpleDateFormat('Z');
0093           EE.setTimeZone(t.(field))
0094           zone_id = t.(field).getID;
0095           if strcmp(zone_id, 'UTC')
0096             txt{end+1} = sprintf ('%s: %s',str_field, char(t.(field).getID));
0097           else
0098             txt{end+1} = sprintf ('%s: %s (UTC%s)',str_field, char(t.(field).getID), char(EE.format(ts.start.utc_epoch_milli)));
0099           end
0100         else
0101           error ('### Unknown java class %s', class(t.(field)))
0102         end
0103 
0104       else
0105         error ('### Please define the output for this property %s', field)
0106       end
0107 
0108     end
0109 
0110 
0111     e_banner(1:length(b_banner)) = '-';
0112     txt{end+1} = e_banner;
0113 
0114     txt{end+1} = ' ';
0115     txt{end+1} = ' ';
0116 
0117   end
0118 
0119   if nargout == 0
0120     for ii=1:length(txt)
0121       disp(txt{ii});
0122     end
0123   end
0124   
0125   varargout{1} = txt;
0126   
0127 end
0128 
0129 
0130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0131 %                               Local Functions                               %
0132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0133 
0134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0135 %
0136 % FUNCTION:    getInfo
0137 %
0138 % DESCRIPTION: Get Info Object
0139 %
0140 % HISTORY:     11-07-07 M Hewitson
0141 %                Creation.
0142 %
0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0144 
0145 function ii = getInfo(varargin)
0146   if nargin == 1 && strcmpi(varargin{1}, 'None')
0147     sets = {};
0148     pl   = [];
0149   else
0150     sets = {'Default'};
0151     pl   = getDefaultPlist;
0152   end
0153   % Build info object
0154   ii = minfo(mfilename, 'timespan', '', utils.const.categories.output, '$Id: display.m,v 1.9 2008/09/04 15:29:31 ingo Exp $', sets, pl);
0155 end
0156 
0157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0158 %
0159 % FUNCTION:    getDefaultPlist
0160 %
0161 % DESCRIPTION: Get Default Plist
0162 %
0163 % HISTORY:     11-07-07 M Hewitson
0164 %                Creation.
0165 %
0166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0167 
0168 function plo = getDefaultPlist()
0169   plo = plist();
0170 end
0171

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