Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Grid lanes (Read 1651 times)
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Grid lanes
May 23rd, 2013 at 8:36am
Print Post  
hello,

haven't used the layouting functionality thus far, but from the description of Grid lanes it might be the one we need. We have to couple stacks of nodes with a stack of nodes on their right. The problem is, the number of nodes can vary from 1-8 and so the vertical grid height depends on the larger of two stacks. So as example the no of nodes can be like:

2-4
4-1
1-0
1-6

(and they are to order so vertically)

Not actually sure if there are examples of Grid Lanes somewhere to look up?
How do you assign a node to a grid cell?

cheers
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Grid lanes
Reply #1 - May 23rd, 2013 at 2:00pm
Print Post  
Hi,

You don't need any special algorithms for this, you can arrange the stacks using a simple nested loop:

Code
Select All
var leftStacks = CreateTestStacks(2, 4, 1, 1);
var rightStacks = CreateTestStacks(4, 1, 0, 6);

double padding = 10, stackStart = 20, stacksPadding = 40;
for (int i = 0; i < 4; i++)
{
	double yl = stackStart;
	foreach (var node in leftStacks[i])
	{
		node.Move(20, yl);
		yl += node.Bounds.Height + padding;
	}

	double yr = stackStart;
	foreach (var node in rightStacks[i])
	{
		node.Move(80, yr);
		yr += node.Bounds.Height + padding;
	}

	stackStart = Math.Max(yl, yr) + stacksPadding;
}

List<List<DiagramNode>> CreateTestStacks(params int[] stackSizes)
{
	var stacks = new List<List<DiagramNode>>();
	foreach (int size in stackSizes)
	{
		var stack = new List<DiagramNode>();
		for (int i = 0; i < size; i++)
			stack.Add(diagram.Factory.CreateShapeNode(defBounds));
		stacks.Add(stack);
	}
	return stacks;
}

Rect defBounds = new Rect(0, 0, 30, 30); 



You could add a lane-grid row at each iteration of the outer loop and set its height according to current Y positions. There's no associations between lane cells and nodes, but you can discover what lane nodes are dropped to and align nodes to lanes from some event handlers. For an example, see the Lanes and ProcessLayout sample projects.

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


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Re: Grid lanes
Reply #2 - May 23rd, 2013 at 2:48pm
Print Post  
Thx! Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint