1 | %
|
---|
2 | % definition for the kml_substyle super (base) and sub (derived) class.
|
---|
3 | %
|
---|
4 | % [kml]=kml_substyle(varargin)
|
---|
5 | %
|
---|
6 | % where the optional varargin and defaults are:
|
---|
7 | % id (char, substyle id, '')
|
---|
8 | %
|
---|
9 | % note that zero arguments constructs a default instance; one
|
---|
10 | % argument of the class copies the instance; and two or more
|
---|
11 | % arguments constructs a new instance from the arguments.
|
---|
12 | %
|
---|
13 | classdef kml_substyle < kml_object
|
---|
14 | properties
|
---|
15 | end
|
---|
16 |
|
---|
17 | methods
|
---|
18 | function [kml]=kml_substyle(varargin)
|
---|
19 |
|
---|
20 | kml=kml@kml_object(varargin{:});
|
---|
21 |
|
---|
22 | switch nargin
|
---|
23 |
|
---|
24 | % create a default object
|
---|
25 |
|
---|
26 | case 0
|
---|
27 |
|
---|
28 | % copy the object or create the object from the input
|
---|
29 |
|
---|
30 | otherwise
|
---|
31 | if (nargin == 1) && isa(varargin{1},class(kml))
|
---|
32 | kml=varargin{1};
|
---|
33 |
|
---|
34 | else
|
---|
35 | fnames=fieldnames(kml);
|
---|
36 |
|
---|
37 | for i=length(fieldnames(kml_object()))+1:min(nargin,length(fnames))
|
---|
38 | if isa(varargin{i},class(kml.(fnames{i})))
|
---|
39 | if ~isempty(varargin{i})
|
---|
40 | kml.(fnames{i})=varargin{i};
|
---|
41 | end
|
---|
42 | else
|
---|
43 | if ~isempty(inputname(i))
|
---|
44 | warning('Argument ''%s'' for field ''%s'' is a ''%s'' class object, not ''%s''.',...
|
---|
45 | inputname(i),fnames{i},class(varargin{i}),class(kml.(fnames{i})));
|
---|
46 | else
|
---|
47 | warning('Argument %d for field ''%s'' is a ''%s'' class object, not ''%s''.',...
|
---|
48 | i ,fnames{i},class(varargin{i}),class(kml.(fnames{i})));
|
---|
49 | end
|
---|
50 | end
|
---|
51 | end
|
---|
52 | end
|
---|
53 |
|
---|
54 | end
|
---|
55 |
|
---|
56 | end
|
---|
57 |
|
---|
58 | % display the object
|
---|
59 |
|
---|
60 | function []=disp(kml)
|
---|
61 |
|
---|
62 | for i=1:numel(kml)
|
---|
63 | if strcmp(class(kml),'kml_substyle')
|
---|
64 | disp(sprintf('class ''%s'' object ''%s%s'' = \n',...
|
---|
65 | class(kml),inputname(1),string_dim(kml,i)));
|
---|
66 | end
|
---|
67 | disp@kml_object(kml(i));
|
---|
68 | if strcmp(class(kml),'kml_substyle')
|
---|
69 | disp(sprintf('\n'));
|
---|
70 | end
|
---|
71 | end
|
---|
72 |
|
---|
73 | end
|
---|
74 |
|
---|
75 | % write the object
|
---|
76 |
|
---|
77 | function []=kml_write(kml,fid,indent)
|
---|
78 |
|
---|
79 | if ~exist('fid','var') || isempty(fid)
|
---|
80 | fid=1;
|
---|
81 | end
|
---|
82 | if ~exist('indent','var') || isempty(indent)
|
---|
83 | indent='';
|
---|
84 | end
|
---|
85 |
|
---|
86 | % loop over the substyles
|
---|
87 |
|
---|
88 | for i=1:numel(kml)
|
---|
89 | if strcmp(class(kml),'kml_substyle')
|
---|
90 | if ~isempty(kml(i).id)
|
---|
91 | fprintf(fid,'%s<!SubStyle id="%s">\n',indent,kml(i).id);
|
---|
92 | else
|
---|
93 | fprintf(fid,'%s<!SubStyle>\n',indent);
|
---|
94 | end
|
---|
95 | end
|
---|
96 | kml_write@kml_object(kml(i),fid,indent);
|
---|
97 | if strcmp(class(kml),'kml_substyle')
|
---|
98 | fprintf(fid,'%s<!/SubStyle>\n',indent);
|
---|
99 | end
|
---|
100 | end
|
---|
101 |
|
---|
102 | end
|
---|
103 |
|
---|
104 | end
|
---|
105 |
|
---|
106 | end
|
---|
107 |
|
---|