Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Is it possible to get node Id when it is created ? (Read 3456 times)
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Is it possible to get node Id when it is created ?
Feb 9th, 2009 at 8:57am
Print Post  
Hi,

   I have saved the graph generated as XML, and found that each node and link is having unique ID.
Would it be possible to get this ID when the node or link is created. Or it is generated at the time of xml only and not possible to access prior to xml creation.

Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is it possible to get node Id when it is creat
Reply #1 - Feb 9th, 2009 at 9:37am
Print Post  
Hi,

That ID is actually the item's ZIndex. The control always keeps the ZIndices as integers in the range 0 .. n-1 , where n is the number of items in the diagram. So, this might not work as a general-purpose unique ID, because if you delete some items or call the setZIndex method, the index of other items will change automatically. Though it is ok as a one-time ID during serialization time.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: Is it possible to get node Id when it is creat
Reply #2 - Feb 9th, 2009 at 10:00am
Print Post  
Hi,

   I want to use this node Id  to map some data with that node.
  I need not to use setZindex method. I want to make sure If i save the graph as XML and later I render it back and delete some node or add some node then the node which are in existence from previous will their id's will chage or it will not affect any more only newly added items will have new Id's. No change for Id's with items which are present from previous.
  I want to use it as unique ID. So does it make sense?

Thank you
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is it possible to get node Id when it is creat
Reply #3 - Feb 9th, 2009 at 10:27am
Print Post  
Deleting a node at some Z position will shift the nodes at higher Z one position down, and change their Z-index, so I would not use that index as a unique ID.

You could keep a global long-int counter as a value of the Diagram's Tag property, assign it to each item's Tag when a new item is created, and increment it. Then you'll be sure that the item's Tag is a unique value for this diagram. Though you might have to take care of copy/paste operations if you allow them. Also if you expect your application to be used in many millennia ahead, you might have to add a provision for when the counter reaches Long.MAX_VALUE Wink

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint