Mercurial > hg > ltpda
comparison m-toolbox/classes/@plotterFactory/plotterFactory.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 % PLOTTERFACTORY factory constructor for different plotter objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: PLOTTERFACTORY factory constructor for different plotter objects. | |
5 % | |
6 % CONSTRUCTOR: | |
7 % | |
8 % p = plotterFactory.makePlotter(objects) | |
9 % | |
10 % | |
11 % VERSION: $Id: plotterFactory.m,v 1.2 2011/04/08 08:56:38 hewitson Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 classdef plotterFactory | |
15 | |
16 methods (Abstract=true) | |
17 dummy(varargin); % dummy abstract method to ensure this factory can't be instantiated | |
18 end | |
19 | |
20 methods (Static=true) | |
21 | |
22 function p = makePlotter(varargin) | |
23 obj_cl = class(varargin{1}); | |
24 objs = utils.helper.collect_objects(varargin(:), obj_cl); | |
25 | |
26 switch obj_cl | |
27 case 'ao' | |
28 dcl = class(objs(1).data); | |
29 % Check if all the ao.data objects are of the same class; if not, | |
30 % we return an aoplotter. | |
31 for kk=1:numel(objs) | |
32 obj = objs(kk); | |
33 if ~strcmp(class(obj.data), dcl) | |
34 warning('Object [%s] has a different data type to object [%s]; returning a default aoplotter'); | |
35 p = aoplotter(objs); | |
36 return | |
37 end | |
38 end | |
39 | |
40 % Otherwise go on and attempt to build a more specialised plotter | |
41 switch dcl | |
42 case 'tsdata' | |
43 p = tsplotter(objs); | |
44 otherwise | |
45 p = aoplotter(objs); | |
46 warning('I don''t know how to make a plotter for %s/%s data objects; returning a default plotter', obj_cl, dcl); | |
47 end | |
48 | |
49 otherwise | |
50 error('I don''t know how to make a plotter for %s objects', cl); | |
51 end % End switch on object class | |
52 | |
53 end % End makePlotter | |
54 | |
55 end % End static methods block | |
56 | |
57 end | |
58 % END |