[6454] | 1 | %
|
---|
| 2 | % definition for the kml_style sub (derived) class.
|
---|
| 3 | %
|
---|
| 4 | % [kml]=kml_style(varargin)
|
---|
| 5 | %
|
---|
| 6 | % where the optional varargin and defaults are:
|
---|
| 7 | % id (char, style id, '')
|
---|
| 8 | % icon (char, icon style, '')
|
---|
| 9 | % label (char, label style, '')
|
---|
| 10 | % line (char, line style, '')
|
---|
| 11 | % poly (char, poly style, '')
|
---|
| 12 | % balloon (char, balloon style, '')
|
---|
| 13 | % list (char, list style, '')
|
---|
| 14 | %
|
---|
| 15 | % note that zero arguments constructs a default instance; one
|
---|
| 16 | % argument of the class copies the instance; and two or more
|
---|
| 17 | % arguments constructs a new instance from the arguments.
|
---|
| 18 | %
|
---|
| 19 | classdef kml_style < kml_styleselector
|
---|
| 20 | properties
|
---|
| 21 | % icon =kml_iconstyle.empty();
|
---|
| 22 | % label =kml_labelstyle.empty();
|
---|
| 23 | icon =[];
|
---|
| 24 | label =[];
|
---|
| 25 | line =kml_linestyle.empty();
|
---|
| 26 | poly =kml_polystyle.empty();
|
---|
| 27 | % balloon =kml_balloonstyle.empty();
|
---|
| 28 | % list =kml_liststyle.empty();
|
---|
| 29 | balloon =[];
|
---|
| 30 | list =[];
|
---|
| 31 | end
|
---|
| 32 |
|
---|
| 33 | methods
|
---|
| 34 | function [kml]=kml_style(varargin)
|
---|
| 35 |
|
---|
| 36 | kml=kml@kml_styleselector(varargin{:});
|
---|
| 37 |
|
---|
| 38 | switch nargin
|
---|
| 39 |
|
---|
| 40 | % create a default object
|
---|
| 41 |
|
---|
| 42 | case 0
|
---|
| 43 |
|
---|
| 44 | % copy the object or create the object from the input
|
---|
| 45 |
|
---|
| 46 | otherwise
|
---|
| 47 | if (nargin == 1) && isa(varargin{1},class(kml))
|
---|
| 48 | kml=varargin{1};
|
---|
| 49 |
|
---|
| 50 | else
|
---|
| 51 | fnames=fieldnames(kml);
|
---|
| 52 |
|
---|
| 53 | for i=length(fieldnames(kml_styleselector()))+1:min(nargin,length(fnames))
|
---|
| 54 | if isa(varargin{i},class(kml.(fnames{i})))
|
---|
| 55 | if ~isempty(varargin{i})
|
---|
| 56 | kml.(fnames{i})=varargin{i};
|
---|
| 57 | end
|
---|
| 58 | else
|
---|
| 59 | if ~isempty(inputname(i))
|
---|
| 60 | warning('Argument ''%s'' for field ''%s'' is a ''%s'' class object, not ''%s''.',...
|
---|
| 61 | inputname(i),fnames{i},class(varargin{i}),class(kml.(fnames{i})));
|
---|
| 62 | else
|
---|
| 63 | warning('Argument %d for field ''%s'' is a ''%s'' class object, not ''%s''.',...
|
---|
| 64 | i ,fnames{i},class(varargin{i}),class(kml.(fnames{i})));
|
---|
| 65 | end
|
---|
| 66 | end
|
---|
| 67 | end
|
---|
| 68 | end
|
---|
| 69 |
|
---|
| 70 | end
|
---|
| 71 |
|
---|
| 72 | end
|
---|
| 73 |
|
---|
| 74 | % display the object
|
---|
| 75 |
|
---|
| 76 | function []=disp(kml)
|
---|
| 77 |
|
---|
| 78 | for i=1:numel(kml)
|
---|
| 79 | disp(sprintf('class ''%s'' object ''%s%s'' = \n',...
|
---|
| 80 | class(kml),inputname(1),string_dim(kml,i)));
|
---|
| 81 | disp@kml_styleselector(kml(i));
|
---|
| 82 | disp(sprintf(' icon: %s %s' ,string_size(kml(i).icon),...
|
---|
| 83 | class(kml(i).icon)));
|
---|
| 84 | disp(sprintf(' label: %s %s' ,string_size(kml(i).label),...
|
---|
| 85 | class(kml(i).label)));
|
---|
| 86 | disp(sprintf(' line: %s %s' ,string_size(kml(i).line),...
|
---|
| 87 | class(kml(i).line)));
|
---|
| 88 | disp(sprintf(' poly: %s %s' ,string_size(kml(i).poly),...
|
---|
| 89 | class(kml(i).poly)));
|
---|
| 90 | disp(sprintf(' balloon: %s %s' ,string_size(kml(i).balloon),...
|
---|
| 91 | class(kml(i).balloon)));
|
---|
| 92 | disp(sprintf(' list: %s %s\n' ,string_size(kml(i).list),...
|
---|
| 93 | class(kml(i).list)));
|
---|
| 94 | end
|
---|
| 95 |
|
---|
| 96 | end
|
---|
| 97 |
|
---|
| 98 | % write the object
|
---|
| 99 |
|
---|
| 100 | function []=kml_write(kml,fid,indent)
|
---|
| 101 |
|
---|
| 102 | if ~exist('fid','var') || isempty(fid)
|
---|
| 103 | fid=1;
|
---|
| 104 | end
|
---|
| 105 | if ~exist('indent','var') || isempty(indent)
|
---|
| 106 | indent='';
|
---|
| 107 | end
|
---|
| 108 |
|
---|
| 109 | % loop over the styles
|
---|
| 110 |
|
---|
| 111 | for i=1:numel(kml)
|
---|
| 112 | if ~isempty(kml(i).id)
|
---|
| 113 | fprintf(fid,'%s<Style id="%s">\n',indent,kml(i).id);
|
---|
| 114 | else
|
---|
| 115 | fprintf(fid,'%s<Style>\n',indent);
|
---|
| 116 | end
|
---|
| 117 | kml_write@kml_styleselector(kml(i),fid,indent);
|
---|
| 118 | % if isa(kml(i).icon,'kml_iconstyle')
|
---|
| 119 | % kml_write(kml(i).icon,fid,[indent ' ']);
|
---|
| 120 | % else
|
---|
| 121 | % warning('kml(%d).icon is a ''%s'' class object, not ''%s''.',...
|
---|
| 122 | % i,class(kml(i).icon),'kml_iconstyle');
|
---|
| 123 | % end
|
---|
| 124 | % if isa(kml(i).label,'kml_labelstyle')
|
---|
| 125 | % kml_write(kml(i).label,fid,[indent ' ']);
|
---|
| 126 | % else
|
---|
| 127 | % warning('kml(%d).label is a ''%s'' class object, not ''%s''.',...
|
---|
| 128 | % i,class(kml(i).label),'kml_labelstyle');
|
---|
| 129 | % end
|
---|
| 130 | if isa(kml(i).line,'kml_linestyle')
|
---|
| 131 | kml_write(kml(i).line,fid,[indent ' ']);
|
---|
| 132 | else
|
---|
| 133 | warning('kml(%d).line is a ''%s'' class object, not ''%s''.',...
|
---|
| 134 | i,class(kml(i).line),'kml_linestyle');
|
---|
| 135 | end
|
---|
| 136 | if isa(kml(i).poly,'kml_polystyle')
|
---|
| 137 | kml_write(kml(i).poly,fid,[indent ' ']);
|
---|
| 138 | else
|
---|
| 139 | warning('kml(%d).poly is a ''%s'' class object, not ''%s''.',...
|
---|
| 140 | i,class(kml(i).poly),'kml_polystyle');
|
---|
| 141 | end
|
---|
| 142 | % if isa(kml(i).balloon,'kml_balloonstyle')
|
---|
| 143 | % kml_write(kml(i).balloon,fid,[indent ' ']);
|
---|
| 144 | % else
|
---|
| 145 | % warning('kml(%d).balloon is a ''%s'' class object, not ''%s''.',...
|
---|
| 146 | % i,class(kml(i).balloon),'kml_balloonstyle');
|
---|
| 147 | % end
|
---|
| 148 | % if isa(kml(i).list,'kml_liststyle')
|
---|
| 149 | % kml_write(kml(i).list,fid,[indent ' ']);
|
---|
| 150 | % else
|
---|
| 151 | % warning('kml(%d).list is a ''%s'' class object, not ''%s''.',...
|
---|
| 152 | % i,class(kml(i).list),'kml_liststyle');
|
---|
| 153 | % end
|
---|
| 154 | fprintf(fid,'%s</Style>\n',indent);
|
---|
| 155 | end
|
---|
| 156 |
|
---|
| 157 | end
|
---|
| 158 |
|
---|
| 159 | end
|
---|
| 160 |
|
---|
| 161 | end
|
---|
| 162 |
|
---|