Ignore:
Timestamp:
10/29/10 10:13:49 (14 years ago)
Author:
jschierm
Message:

Addition of set methods to all the kml classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/kml/kml_polystyle.m

    r6454 r6455  
    4848                            else
    4949                                if ~isempty(inputname(i))
    50                                     warning('Argument ''%s'' for field ''%s'' is a ''%s'' class object, not ''%s''.',...
     50                                    warning('Argument ''%s'' for property ''%s'' is a ''%s'' class object, not ''%s''.',...
    5151                                        inputname(i),fnames{i},class(varargin{i}),class(kml.(fnames{i})));
    5252                                else
    53                                     warning('Argument %d for field ''%s'' is a ''%s'' class object, not ''%s''.',...
     53                                    warning('Argument %d for property ''%s'' is a ''%s'' class object, not ''%s''.',...
    5454                                        i           ,fnames{i},class(varargin{i}),class(kml.(fnames{i})));
    5555                                end
     
    7272                disp(sprintf('          fill: %d'      ,kml(i).fill));
    7373                disp(sprintf('       outline: %d\n'    ,kml(i).outline));
     74            end
     75
     76        end
     77
     78%  set the properties of the object
     79
     80        function [kml]=set(kml,varargin)
     81
     82            kmlref=feval(class(kml));
     83
     84%  loop through each parameter in the input list (comparing to the reference
     85%  object in case property types have been changed)
     86
     87            for i=1:2:length(varargin)
     88                if isfield(kmlref,varargin{i})
     89                    if isa(varargin{i+1},class(kmlref.(varargin{i})))
     90                        kml.(varargin{i})=varargin{i+1};
     91                    else
     92                        if ~isempty(inputname(i+1))
     93                            warning('Argument ''%s'' for property ''%s'' is a ''%s'' class object, not ''%s''.',...
     94                                inputname(i+1),varargin{i},class(varargin{i+1}),class(kmlref.(varargin{i})));
     95                        else
     96                            warning('Argument %d for property ''%s'' is a ''%s'' class object, not ''%s''.',...
     97                                i+1           ,varargin{i},class(varargin{i+1}),class(kmlref.(varargin{i})));
     98                        end
     99                    end
     100                else
     101                    warning('Property ''%s'' for class ''%s'' does not exist.',...
     102                        varargin{i},class(kmlref));
     103                end
    74104            end
    75105
Note: See TracChangeset for help on using the changeset viewer.