Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic stop repetition (Read 4104 times)
superNova
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Aug 5th, 2011
stop repetition
Oct 11th, 2011 at 5:34am
Print Post  
I have to map source node to destination node in between interfacenode is exist.I m facing the problem that same interfacenode those who has same id , these are repeating . I want no repetition of same interface node(id). I think there is hashmap may be a good option for me but how to use it I dont know pls guide me.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: stop repetition
Reply #1 - Oct 11th, 2011 at 6:13am
Print Post  
You could use the diagram's Tag property as an id counter and increment its value for each node created.

When initializing a new diagram:
diagram.setTag(0);

When a new node is created:
Integer idTag = (Integer)diagram.getTag();
int currentId = idTag.intValue();
newNode.setTag(currentId);
diagram.setTag(currentId + 1);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
superNova
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Aug 5th, 2011
Re: stop repetition
Reply #2 - Oct 11th, 2011 at 6:56am
Print Post  
actully  the solution that u posted to me   was not helpfull , or not working i tried. could u please tell me through hashmap object how may i stop repetition of creation node that has same id.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: stop repetition
Reply #3 - Oct 11th, 2011 at 7:38am
Print Post  
In what manner exactly it's not working? If you draw nodes with the mouse, you must run this code from the nodeCreated handler; in such case replace newNode with e.getNode(). If creating them programmatically, add that code after the Factory.create*Node() call.
  
Back to top
 
IP Logged
 
superNova
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Aug 5th, 2011
Re: stop repetition
Reply #4 - Oct 11th, 2011 at 10:14am
Print Post  
i m not creating node through mouse.  there are 50 records , in database.out of 50  there are 10 records , who has same id no. Now i m creating node through for loop. it starts from  first record to last record it means its creating 50 nodes but i want to ignore nodes those , who has same id.
means the nodes those are generating for sameid  instead 10 nodes i want only one node.
I hope , i described you in well manner.

please help me
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: stop repetition
Reply #5 - Oct 11th, 2011 at 11:35am
Print Post  
Ok, create a Hashtable<int, DiagramNode> to map identifiers to nodes, and while iterating over the dataset check the hashtable.containsKey(id) result. If it returns false, create a new node and add it to the hashtable.

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