How to accelerate the update of visible UITree Nodes
11 次查看(过去 30 天)
显示 更早的评论
Hi guys,
When importing data into a UITree using callback functions, the functions execute perfectly, but it takes the tree quite a while to display its nodes in the GUI afterwards. Is there a way to accelerate the drawing of the UITree, or to at least get a callback like finishedUpdating() ?
Thanks
Edit:
I would still be happy if someone could answer this. It seems like internal problem to save "big" amounts on data within uiTree nodes. Appearantly there is some sort of ultra-inefficient memory reservation algorithm working in the back of an uiTree, which makes updating just HORRIBLY slow.
Im talking about >5 minutes in some cases, where Im just adding 40 nodes with 2kB each.
Edit:
I figured out that its the conversion from matlab to java arrays which kills it.
javaValue(j,k) = java.lang.Double(matlabValue(j,k));
When storing large matrices, this thing turns 1 million of calls into 60 seconds of runtime. Seems like there is no way out of it.
1 个评论
Petr Kryze
2024-2-29
+1 Would be happy to have an answer for this. GUI updates of uitree are also super slow in my app, even though the code in the callback runs just fine.
回答(1 个)
Amanda Irving
2019-8-9
Maho,
Can you give a code example of how the uitreenodes are created and what relationship they have with the 2kB of data? Also, what release of MATLAB are you using?
Here are some ideas of what you can do to help get the uitree view to update as the tree is being built:
1. Create all first level nodes first (before deeper levels of the hierarchy) so the nodes that the end user will most likely see appears in the uitree first.
2. Use drawnow to force incremental updates to the view so that the end user is not waiting for all nodes to be created before the view updates. For example, if the uitree is only tall enough to show 10 notes, create 10 nodes, call drawnow, then continue building the rest of the tree.
t = uitree();
for x = 1:10
uitreenode(t, "Text", "Node" + x);
end
drawnow;
for x = 11:100
uitreenode(t, "Text", "Node" + x);
end
3. If you have a uitree with a very deep hierarchy, you can choose to create nodes dynamically when the end user expands a node. That way, the deep hierarchy is only being built if the person using the tree is browsing that area. The NodeExpandedFcn provides a way to specify a callback for the node expanded event.
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!