www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbctree/@browsernode/createChildren.m
function createChildren(node,Lvl,ch) %CREATECHILDREN create children for mbc browser trees % createChildren(node,Lvl,ch) % Lvl is the maximum level in the tree hierarchy to create. By default, the % entire tree is created (Lvl=Inf) % ch is the list of pointers to children. By default, % ch = children(info(node.Pointer)) % which assumes that the node is an MCTREE % Copyright 2011 The MathWorks, Inc. if nargin<2 Lvl = Inf; end if nargin<3 ch = children(info(node.Pointer)); end if ~isempty(ch) iCreateChildren(node,Lvl,ch); % add all children at once node.fireNodeStructureChanged(); end function childnode = iCreateChildren(node,Lvl,ch) if nargin<3 ch = children(info(node.Pointer)); end if ~isempty(ch) for i=1:length(ch) childnode(i) = i_makeNode( node, ch(i) ); % add node to Java tree and connect node node.TreeNode.add( childnode(i).TreeNode ); node.connect( childnode(i), 'down' ); set( childnode(i), 'Tree', node.Tree ); if Lvl>1 % create next level iCreateChildren(childnode(i),Lvl-1); end end else childnode = []; end function node = i_makeNode( node, p ) %i_makeNode create individual node d = xregGui.uddDispatcher; mct = info(p); node = d.feval( @mbctree.browsernode, 'Tree',node.Tree, 'Pointer',p,... 'Name',getname(mct),'Icon',iconfile(mct),'Editable',node.Tree.Editable );