Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Node Position (Read 3214 times)
himaheshh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jul 10th, 2009
Node Position
Jul 16th, 2009 at 8:42am
Print Post  
Hi,

My requirement is to set every alternate nodes at a hight greater than the previous node. Is it achievable?

Regards
Mahesh
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node Position
Reply #1 - Jul 16th, 2009 at 10:33am
Print Post  
Hi,

Are you placing the nodes in a row, and need every second node to have a greater Height than the previous node?

Stoyan
  
Back to top
 
IP Logged
 
himaheshh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jul 10th, 2009
Re: Node Position
Reply #2 - Jul 17th, 2009 at 12:07am
Print Post  
Hi Stoyan,

Yes, I am adding nodes top to bottom and while doing that I want to set every second node to appear below(not the height of the node but the link height) the previous node.

The objective is to save the space in order increase the usability. trying to achieve something like this,

ROOT NODE


NODE 1 NODE 3

NODE 2 NODE 4
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node Position
Reply #3 - Jul 17th, 2009 at 1:55pm
Print Post  
Do you need that as a modification of the result of TreeLayout?
  
Back to top
 
IP Logged
 
himaheshh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jul 10th, 2009
Re: Node Position
Reply #4 - Jul 22nd, 2009 at 2:22am
Print Post  
Thank you.

Sorry I didnt get your question.However, I need to do this when ever I load the diagram in the screen.

Regards
Mahesh
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node Position
Reply #5 - Jul 22nd, 2009 at 6:18am
Print Post  
Do you need something close to TreeLayout, but with nodes from the same tree level placed on two rows?
  
Back to top
 
IP Logged
 
himaheshh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jul 10th, 2009
Re: Node Position
Reply #6 - Jul 22nd, 2009 at 10:13am
Print Post  
Exactly!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node Position
Reply #7 - Jul 22nd, 2009 at 12:08pm
Print Post  
Try this:

Code
Select All
TreeLayout tl = new TreeLayout();
tl.NodeDistance = 0;
tl.Arrange(diagram);

DiagramNodeCollection nodes = new DiagramNodeCollection();
GetBfsOrder(root, nodes);

for (int i = 1; i < nodes.Count; ++i)
{
	DiagramNode node = nodes[i];
	PointF p = node.Bounds.Location;
	p.Y *= 2;
	if (i % 2 != 0)
		p.Y += node.Bounds.Height;
	node.Move(p.X, p.Y);
}

private void GetBfsOrder(DiagramNode root, DiagramNodeCollection nodes)
{
	Queue<DiagramNode> queue = new Queue<DiagramNode>();
	queue.Enqueue(root);

	while (queue.Count > 0)
	{
		DiagramNode node = queue.Dequeue();
		nodes.Add(node);

		foreach (DiagramLink link in node.OutgoingLinks)
		{
			DiagramNode child = link.Destination;
			if (!nodes.Contains(child) && !queue.Contains(child))
				queue.Enqueue(child);
		}
	}
}
 



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