Mercurial > hg > ltpda
comparison m-toolbox/classes/@plotter/plotter.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % PLOTTER base class for different plotter objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: PLOTTER base class for different plotter objects. | |
5 % | |
6 % This class defines the basic properties of a plot or series of plots. | |
7 % Namely, the data and the properties of the figure(s), axes, lines, and | |
8 % legends. | |
9 % | |
10 % The defaults for the various properties (except the data) are taken from | |
11 % the LTPDA preferences. | |
12 % | |
13 % CONSTRUCTOR: | |
14 % | |
15 % p = plotter(objects) | |
16 % p = plotter(objects, pl) | |
17 % | |
18 % <a href="matlab:utils.helper.displayMethodInfo('plotter', 'plotter')">Parameters Description</a> | |
19 % | |
20 % VERSION: $Id: plotter.m,v 1.3 2011/04/08 08:56:26 hewitson Exp $ | |
21 % | |
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
23 classdef plotter < ltpda_obj | |
24 | |
25 properties | |
26 | |
27 % Cell array of data objects to plot | |
28 data; | |
29 | |
30 % output | |
31 outputdir; | |
32 filename; | |
33 | |
34 % figure | |
35 | |
36 % axis properties | |
37 axisFontSize; | |
38 axisFontWeight; | |
39 axisFontName; | |
40 axisLineWidth; | |
41 labelFontSize; | |
42 | |
43 % Grid | |
44 gridLineStyle; | |
45 minorGridLineStyle; | |
46 showXGrid; | |
47 showXMinorGrid; | |
48 showYGrid; | |
49 showYMinorGrid; | |
50 | |
51 % line properties | |
52 lineStyle; | |
53 lineWidth; | |
54 marker; | |
55 markerSize; | |
56 plotinfoOverride; | |
57 | |
58 % Legend | |
59 legendFontSize; | |
60 includeLegend; | |
61 legendLocation; | |
62 | |
63 includeDescription; | |
64 | |
65 plotcolors; | |
66 | |
67 end | |
68 | |
69 | |
70 methods | |
71 | |
72 % Constructor | |
73 function p = plotter(varargin) | |
74 | |
75 % Collect all ltpda_uoh objects | |
76 objs = {}; | |
77 for kk=1:nargin | |
78 if isa(varargin{kk}, 'ltpda_uoh') | |
79 objs = [objs varargin(kk)]; | |
80 end | |
81 end | |
82 p.data = objs; | |
83 | |
84 % Process the input plist | |
85 pl = utils.helper.collect_objects(varargin(:), 'plist'); | |
86 pl = combine(pl, plotter.getDefaultPlist('Default')); | |
87 | |
88 % Set properties from the plist | |
89 plotter.setPropertiesFromPlist(p, pl); | |
90 | |
91 end % End of constructor | |
92 | |
93 end | |
94 | |
95 methods (Static=true, Access=private) | |
96 | |
97 % Set the object properties from the plist | |
98 function setPropertiesFromPlist(p, pl) | |
99 p.outputdir = pl.find('output directory'); | |
100 p.filename = pl.find('filename'); | |
101 p.axisFontSize = pl.find('axis FontSize'); | |
102 p.axisFontWeight = pl.find('axis FontWeight'); | |
103 p.axisFontName = pl.find('axis fontname'); | |
104 p.axisLineWidth = pl.find('axis LineWidth'); | |
105 p.gridLineStyle = pl.find('grid LineStyle'); | |
106 p.minorGridLineStyle = pl.find('minor Grid LineStyle'); | |
107 p.legendFontSize = pl.find('legend FontSize'); | |
108 p.lineWidth = pl.find('lineWidth'); | |
109 p.lineStyle = pl.find('linestyle'); | |
110 p.markerSize = pl.find('marker Size'); | |
111 p.marker = pl.find('marker'); | |
112 p.includeDescription = pl.find('include Description'); | |
113 p.includeLegend = pl.find('include Legend'); | |
114 p.plotinfoOverride = pl.find('plotinfo override'); | |
115 p.showXGrid = pl.find('Show X Grid'); | |
116 p.showXMinorGrid = pl.find('Show X Minor Grid'); | |
117 p.showYGrid = pl.find('Show Y Grid'); | |
118 p.showYMinorGrid = pl.find('Show Y Minor Grid'); | |
119 p.plotcolors = pl.find('plot colors'); | |
120 p.labelFontSize = pl.find('label fontsize'); | |
121 p.legendLocation = pl.find('legend location'); | |
122 end | |
123 | |
124 end | |
125 | |
126 methods (Static=true) | |
127 | |
128 function out = VEROUT() | |
129 out = '$Id: plotter.m,v 1.3 2011/04/08 08:56:26 hewitson Exp $'; | |
130 end | |
131 | |
132 function ii = getInfo(varargin) | |
133 ii = utils.helper.generic_getInfo(varargin{:}, 'plotter'); | |
134 end | |
135 | |
136 function out = SETS() | |
137 out = {'Default'}; | |
138 end | |
139 | |
140 function out = getDefaultPlist(set) | |
141 | |
142 if ~utils.helper.ismember(lower(smodel.SETS), lower(set)) | |
143 error('### Unknown set [%s]', set); | |
144 end | |
145 | |
146 out = plist(); | |
147 | |
148 % output directory | |
149 p = param({'output directory','A directory for use when plotting to files.'}, paramValue.EMPTY_STRING); | |
150 out.append(p); | |
151 | |
152 % output filename | |
153 p = param({'filename','A filename for use when plotting to files.'}, paramValue.EMPTY_STRING); | |
154 out.append(p); | |
155 | |
156 % axis font size | |
157 p = param({'axis FontSize','The font size for axis numbers.'}, LTPDAprefs.axesFontSize); | |
158 out.append(p); | |
159 | |
160 % label font size | |
161 p = param({'label FontSize','The font size for axis labels.'}, LTPDAprefs.axesFontSize); | |
162 out.append(p); | |
163 | |
164 % axis font name | |
165 p = param({'axis fontname','The font name for axis labels.'}, 'default'); | |
166 out.append(p); | |
167 | |
168 % axis font weight | |
169 default = LTPDAprefs.axesFontWeight; | |
170 defaultIndex = find(strcmpi(default, plotter.fontweights)); | |
171 if isempty(defaultIndex) | |
172 defaultIndex = 1; | |
173 end | |
174 p = param({'axis FontWeight','The font weight for axis labels.'}, {defaultIndex, plotter.fontweights, paramValue.SINGLE}); | |
175 out.append(p); | |
176 | |
177 % axis line width | |
178 p = param({'axis LineWidth','The line width for the axes.'}, LTPDAprefs.axesLineWidth); | |
179 out.append(p); | |
180 | |
181 % grid style | |
182 default = LTPDAprefs.gridStyle; | |
183 defaultIndex = find(strcmpi(default, plotter.linestyles)); | |
184 p = param({'grid LineStyle','The major grid line style.'}, {defaultIndex, plotter.linestyles, paramValue.SINGLE}); | |
185 out.append(p); | |
186 | |
187 % minor grid style | |
188 default = LTPDAprefs.minorGridStyle; | |
189 defaultIndex = find(strcmpi(default, plotter.linestyles)); | |
190 p = param({'minor Grid LineStyle','The minor grid line style.'}, {defaultIndex, plotter.linestyles, paramValue.SINGLE}); | |
191 out.append(p); | |
192 | |
193 % legend font size | |
194 p = param({'legend FontSize','The font size for legends.'}, LTPDAprefs.legendFontSize); | |
195 out.append(p); | |
196 | |
197 % line width | |
198 p = param({'lineWidth','The width of data lines.'}, LTPDAprefs.lineLineWidth); | |
199 out.append(p); | |
200 | |
201 % line style | |
202 p = param({'linestyle','The style of data lines.'}, {1, plotter.linestyles, paramValue.SINGLE}); | |
203 out.append(p); | |
204 | |
205 | |
206 % Include description | |
207 p = param({'include Description','Include object description in the legend.'}, paramValue.TRUE_FALSE); | |
208 out.append(p); | |
209 | |
210 % Include legend | |
211 p = param({'include Legend','Include legend on the plot.'}, paramValue.TRUE_FALSE); | |
212 out.append(p); | |
213 | |
214 % Legend locations | |
215 default = 'NorthWest'; | |
216 defaultIndex = find(strcmpi(default, plotter.legendLocations)); | |
217 p = param({'legend location','Include legend on the plot.'}, {defaultIndex, plotter.legendLocations, paramValue.SINGLE}); | |
218 out.append(p); | |
219 | |
220 % Allow plotinfo override | |
221 p = param({'plotinfo override','Allow plotinfo to override settings.'}, paramValue.TRUE_FALSE); | |
222 out.append(p); | |
223 | |
224 % marker size | |
225 p = param({'marker Size','The size of markers.'}, LTPDAprefs.lineMarkerSize); | |
226 out.append(p); | |
227 | |
228 % marker | |
229 p = param({'marker','The default marker for traces.'}, {1, plotter.markers, paramValue.SINGLE}); | |
230 out.append(p); | |
231 | |
232 % Show X grid | |
233 p = param({'Show X Grid','Show the X major grid lines.'}, paramValue.TRUE_FALSE); | |
234 out.append(p); | |
235 | |
236 % Show Y minor grid | |
237 p = param({'Show X Minor Grid','Show the X minor grid lines.'}, paramValue.TRUE_FALSE); | |
238 out.append(p); | |
239 | |
240 % Show grid | |
241 p = param({'Show Y Grid','Show the Y major grid lines.'}, paramValue.TRUE_FALSE); | |
242 out.append(p); | |
243 | |
244 % Show minor grid | |
245 p = param({'Show Y Minor Grid','Show the Y minor grid lines.'}, paramValue.TRUE_FALSE); | |
246 out.append(p); | |
247 | |
248 % Plot colors | |
249 p = param({'plot colors', 'A cell-array of plot colors to cycle through for multi-trace plots'}, getappdata(0, 'ltpda_default_plot_colors')); | |
250 out.append(p); | |
251 | |
252 end % function out = getDefaultPlist(varargin) | |
253 | |
254 function obj = initObjectWithSize(n,m) | |
255 obj = smodel.newarray([n m]); | |
256 for ii = 1:numel(obj) | |
257 obj(ii).UUID = char(java.util.UUID.randomUUID); | |
258 end | |
259 end | |
260 | |
261 function out = linestyles() | |
262 out = {'-', '--', ':', '-.'}; | |
263 end | |
264 | |
265 function out = fontweights | |
266 out = {'normal', 'bold', 'light', 'demi'}; | |
267 end | |
268 | |
269 function out = markers | |
270 out = {'none', '+', 'o', '*', '.', 'x', 's', 'd', '^', 'v', '>', '<', 'p', 'h'}; | |
271 end | |
272 | |
273 function out = legendLocations | |
274 out = {'North', 'South', 'East', 'West', 'NorthEast', 'NorthWest', 'SouthEast', ... | |
275 'SouthWest', 'NorthOutside', 'SouthOutside', 'EastOutside', 'WestOutside', ... | |
276 'NorthEastOutside', 'NorthWestOutside', 'SouthEastOutside', 'SouthWestOutside', ... | |
277 'Best', 'BestOutside'}; | |
278 end | |
279 | |
280 end | |
281 | |
282 | |
283 | |
284 end |