Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Want some spacing between nodes (Read 3518 times)
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Want some spacing between nodes
Jun 3rd, 2009 at 8:47am
Print Post  
Hi Stoyan,

I want some spacing between nodes at load time, i.e nodes should not intersect each other at any point.(Even in the case when Bounds of both nodes are same)

Is it possible? Please give some suggestion.

Thanks,
Bala
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Want some spacing between nodes
Reply #1 - Jun 3rd, 2009 at 9:45am
Print Post  
You could run a few iterations of AnnealLayout until you detect there are no more intersections. Starting it with Randomize set to false and a low InitialTemperature should not modify the original layout a lot. If you don't care about preserving the initial layout, you could run any of the layout classes, e.g. try GridLayout or LayeredLayout.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want some spacing between nodes
Reply #2 - Jun 3rd, 2009 at 12:29pm
Print Post  
Thanks for the reply.

We do not want to change the original layout. I think we can go with your Anneal layout suggestion. Just wanted to know how can we perform iterations till we find node interactions.

It would be nice if you could put some line of codes as we are not familiar with layout stuff and that will give us enough material to go on further with our requirements on layout.

Thanks,
Bala
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want some spacing between nodes
Reply #3 - Jun 5th, 2009 at 7:24am
Print Post  
Hi Stoyan,

Any update on this ?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Want some spacing between nodes
Reply #4 - Jun 5th, 2009 at 10:53am
Print Post  
Code
Select All
var layout = new AnnealLayout();
layout.KeepGroupLayout = true;
layout.LayoutArea = diagram.Bounds;
layout.SplitGraph = false;

while (NodesIntersect())
	layout.Arrange(diagram);

diagram.ResizeToFitItems(5);

bool NodesIntersect()
{
	for (int i = 0; i < diagram.Nodes.Count - 1; ++i)
	{
		DiagramNode node1 = diagram.Nodes[i];
		if (node1.MasterGroup != null)
			continue;
		for (int j = i + 1; j < diagram.Nodes.Count; ++j)
		{
			DiagramNode node2 = diagram.Nodes[j];
			if (node2.MasterGroup != null)
				continue;

			if (node1.Bounds.IntersectsWith(node2.Bounds))
				return true;
		}
	}

	return false;
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want some spacing between nodes
Reply #5 - Jun 8th, 2009 at 5:59am
Print Post  
Hi Stoyan,

Thanks for the code lines.

1. It is working fine but it is too different from current layout. Now Nodes are not intersecting to each other but their position has got changed (neighbor nodes are far apart from each other now).Is there any way by which we can change anneal layout such that it looks similar to previous layout?

2. It is taking too much time.I have tried it for 800 ShapeNodes and it took about 40 seconds to complete.Can we improve performance?

Thanks,
Bala
« Last Edit: Jun 8th, 2009 at 3:17pm by Bala »  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want some spacing between nodes
Reply #6 - Jun 10th, 2009 at 9:19am
Print Post  
Any update on this?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint