loading an array in rTree v2
Posted: Thu Feb 06, 2014 8:30 am
I have been trying to get my head around the array method of loading an rTree.
The new array structure is quite opaque to me, and the run rev newsletter example given just before rTree 2's release doesn't seem to work (well it would for me.)
In my case I have an array of some 949 items. They are table of contents (the chapter and section headings of a body of text) that I want to display as an rTree.
Currently I am stepping through my array and creating each node as I go but wondered if the array assignment method might be quicker.
My array "aNav" is two dimensional. The first index being just that, an index, the number of the entry (will correspond to the node index in the rTree) and also the reference I use to locate the selected section of the text. The second index being content details for the entry.
Of these, the ones I am interested in to construct my content tree are as follows:
aNav[displayorder]["nav_entry"]
-- The text to display at the rTree node.
aNav[displayorder]["node_depth"]
-- the depth of the entry.
This is 1 higher than the node depth as understood by rTree so I subtract 1 from it to get the rTree node depth
aNav[displayorder]["node_parent"]
-- if the node_depth is "1" then this is "ROOT".
If the node_depth is greater than "1" then this is the index ("playorder") for the parent node of this child.
I also create a custom property for each node equal to the value of "play order" which I use to display the selected section.
Ignoring any other node attributes (like "firstIconCollapsed" etc) how can I put this data into a new array that I can then just copy into an rTree?
if this method is faster than my current, node by node construction then I might be able to create my rTree on the fly.
James
The new array structure is quite opaque to me, and the run rev newsletter example given just before rTree 2's release doesn't seem to work (well it would for me.)
In my case I have an array of some 949 items. They are table of contents (the chapter and section headings of a body of text) that I want to display as an rTree.
Currently I am stepping through my array and creating each node as I go but wondered if the array assignment method might be quicker.
My array "aNav" is two dimensional. The first index being just that, an index, the number of the entry (will correspond to the node index in the rTree) and also the reference I use to locate the selected section of the text. The second index being content details for the entry.
Of these, the ones I am interested in to construct my content tree are as follows:
aNav[displayorder]["nav_entry"]
-- The text to display at the rTree node.
aNav[displayorder]["node_depth"]
-- the depth of the entry.
This is 1 higher than the node depth as understood by rTree so I subtract 1 from it to get the rTree node depth
aNav[displayorder]["node_parent"]
-- if the node_depth is "1" then this is "ROOT".
If the node_depth is greater than "1" then this is the index ("playorder") for the parent node of this child.
I also create a custom property for each node equal to the value of "play order" which I use to display the selected section.
Ignoring any other node attributes (like "firstIconCollapsed" etc) how can I put this data into a new array that I can then just copy into an rTree?
if this method is faster than my current, node by node construction then I might be able to create my rTree on the fly.
James