Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Some Queries (Read 3525 times)
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Some Queries
Mar 18th, 2009 at 6:56am
Print Post  
Hi,

I been trying to develop an application in which there are few randomly linked nodes and two buttons named as "Distribute Horizontally" and "Distribute Vertically".

Button called "Distribute Horizontally" aligns all the linked nodes such a way that all the adjacent nodes are placed equally spaced horizontally but it has no effect on those nodes which are not connected to any other node in the diagram.

Similarly button called "Distribute Vertically" aligns all the connected nodes such a way that all the adjacent connected nodes are placed equally spaced vertically but it has no effect on the nodes which are not connected to any node in the diagram.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some Queries
Reply #1 - Mar 19th, 2009 at 1:15pm
Print Post  
Hi,

Adjacent nodes can be distributed strictly horizontally or vertically only if you have chains of nodes of max.degree 2 (maximum number of connections per node). The GridLayout implements something of that kind for the general case where nodes can have arbitrary number of connections.

Stoyan
  
Back to top
 
IP Logged
 
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Some Queries
Reply #2 - Mar 19th, 2009 at 2:35pm
Print Post  
Hi Stoyan,

Can you please provide me the sample code for how can I restrict the arrangement of the nodes strictly Horizontally and Vertically.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some Queries
Reply #3 - Mar 19th, 2009 at 2:42pm
Print Post  
If all your nodes are indeed in chains of max degree 2, it's just a simple loop that starts from the node of degree one and sets the position of each next node in the chain so its Bounds.X values is set to the Bounds.Right of the previous node + some offset.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some Queries
Reply #4 - Mar 19th, 2009 at 5:26pm
Print Post  
Actually, TreeLayout can arrange such chains of nodes automatically. Set its Type property to Centered, Direction to LeftToRight or TopToBottom, and MultipleGraphLayout to Vertical or Horizontal.
  
Back to top
 
IP Logged
 
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Some Queries
Reply #5 - Mar 20th, 2009 at 5:18am
Print Post  
Hi Stoyan,

Thanks for the suggestion.

But there are few issues with such an arrangement.

1. I do not want the nodes which do not have any link to be effected anyway when I say "Distribute Horizontally" or "Distribute Vertically" there position should not be changed at present they are getting aligned with other nodes.

2. Also when I say "Distribute Horizontally" the vertical coordinates of the nodes should not get changed that should remain the same only the horizontal spacing between all the nodes which are connected through links should be same. Same applies to "Distribute Vertically" i.e when I say "Distribute Vertically" only the vertical spacing between the nodes connected by links should become equal, the horizontal coordinates of the nodes should not change they should be same as before the arrangement.

Any suggestions how I can accomplish these requirements.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some Queries
Reply #6 - Mar 20th, 2009 at 7:13am
Print Post  
Hi Anant,

Loop over all nodes, and for each node that has a single connection and the link is outgoing, run TreeLayout with Root set to that node and KeepRootPosition = true.

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