Main Content

collapse

ツリー ノードを折りたたむ

説明

collapse(parent) は、親ツリーまたはツリー ノードのノードを折り畳みます。parentTree オブジェクトの場合、ツリーの最上位ノードは折りたたまれた状態で表示されます。最上位以外の子は折りたたまれません。親が TreeNode オブジェクトの場合、指定したノードは折りたたまれた状態で表示されますが、そのノードの中にある子は折りたたまれません。

collapse(parent,'all') は、親ツリーまたはツリー ノードのすべての子を折り畳みます。

すべて折りたたむ

3 つのレベルのノードがあるツリーを作成し、すべてのノードを展開します。

fig = uifigure;
tree = uitree(fig,'Position',[20 20 175 100]);
    
% First level nodes
category1 = uitreenode(tree,'Text','Runners');
category2 = uitreenode(tree,'Text','Cyclists');

% Second level nodes
equip1 = uitreenode(category1,'Text','Equipment');
equip2 = uitreenode(category2,'Text','Equipment');
    
% Third level nodes
shoes = uitreenode(equip1,'Text','Running Shoes');
bike = uitreenode(equip2,'Text','Bicycle');
helmet = uitreenode(equip2,'Text','Helmet');

% Expand all nodes
expand(tree,'all');

Tree UI component with three levels of nodes. All nodes with children are expanded.

最上位ノードを折りたたみます。

collapse(tree)

Tree UI component with two collapsed nodes

[Cyclists] ノードを展開します。

expand(category2)

Tree UI component with two top-level nodes. The first node is collapsed, and the second node and its child node are expanded.

[Equipment] 子ノードは既に展開されています。これは、前回実行した collapse コマンドでは [Cyclists] ノードのみが折りたたまれていたためです。すべての子ノードを折りたたむには、関数 collapse を呼び出すときに 'all' オプションを指定します。

入力引数

すべて折りたたむ

親ツリーまたはノード。Tree オブジェクトまたは TreeNode オブジェクトとして指定します。

バージョン履歴

R2017b で導入