Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@plotterFactory/plotterFactory.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,58 @@ +% PLOTTERFACTORY factory constructor for different plotter objects. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: PLOTTERFACTORY factory constructor for different plotter objects. +% +% CONSTRUCTOR: +% +% p = plotterFactory.makePlotter(objects) +% +% +% VERSION: $Id: plotterFactory.m,v 1.2 2011/04/08 08:56:38 hewitson Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +classdef plotterFactory + + methods (Abstract=true) + dummy(varargin); % dummy abstract method to ensure this factory can't be instantiated + end + + methods (Static=true) + + function p = makePlotter(varargin) + obj_cl = class(varargin{1}); + objs = utils.helper.collect_objects(varargin(:), obj_cl); + + switch obj_cl + case 'ao' + dcl = class(objs(1).data); + % Check if all the ao.data objects are of the same class; if not, + % we return an aoplotter. + for kk=1:numel(objs) + obj = objs(kk); + if ~strcmp(class(obj.data), dcl) + warning('Object [%s] has a different data type to object [%s]; returning a default aoplotter'); + p = aoplotter(objs); + return + end + end + + % Otherwise go on and attempt to build a more specialised plotter + switch dcl + case 'tsdata' + p = tsplotter(objs); + otherwise + p = aoplotter(objs); + warning('I don''t know how to make a plotter for %s/%s data objects; returning a default plotter', obj_cl, dcl); + end + + otherwise + error('I don''t know how to make a plotter for %s objects', cl); + end % End switch on object class + + end % End makePlotter + + end % End static methods block + +end +% END