www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xreglegend/copyobj.m
function new=copyobj(gr,p) % XREGLEGEND/COPYOBJ copyobj for xreglegend object % new = copyobj(gr,parent) % Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc. % Bail if we've not been given a legend object if ~isa(gr,'xreglegend') error(message('mbc:xreglegend:InvalidObject')) end new = xreglegend(p); % Copy properties gr = get(gr.axes,'UserData'); d = gr.d; new.d = d; % clear callbacks builtin('set',new.axes,'userdata',new); % set position newpos = get(gr,'Position'); newpos([1 2]) = [10 10]; % Get color if isgraphics(p, 'figure') newcol = get(p,'Color'); else newcol = get(p,'BackgroundColor'); end set(new,'visible','on','position',newpos, ... 'backgroundcolor',newcol, ... 'items',gr.items);