Wednesday, 19 December 2007

Constants Array

One of the things that must be known in oder to position a branch node correctly is the total number of branches around its "parent" node.

Writing this infomration explicitly into the ID number would have made the xml list incredibly difficult to edit as each time you add a node to the list you would have to update the ID numbers of a large number of other nodes as the totals would be different.

To over come this problem i decided to create a counting algorithm that when given a node ID number:
1. seaches through all the nodes on the list to find nodes of the same group,
2. calcuated the total number of braches "bt".
3. returns that value to all the nodes in the group.

This is then done for the chain total "ct" , child total "cdt".

The resulting array contains a series of constants for each number cluster in a node id: b,bt,b,ct,cd,cdt.




This is done for each number cluster in each node ID.

.

This array of constants must be produced for each node ID in the XML file.

Armed with all the required data about each node the next step was to create a function that can calculate an x and y coordinate for each ID number.

No comments: