Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Construction of special sorted tree (Read 3178 times)
caseopeia
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Apr 8th, 2009
Construction of special sorted tree
Aug 24th, 2009 at 10:11am
Print Post  
Dear Users, hello Stoyo (are you out there?)

below you can find two pictures of a tree I wish to generate, the pictures are showing different situations in the same tree.

The nodes should be positioned in a column/row manner. Important for this layout is the position of the nodes: all items must be positioned in virtual layers (horizontal and vertical).
In my application I use own nodes derived from ContainerNode. Currently I use a combination of LayeredLayout and OrthogonalRouter with some options set.
The first layer is sorted manually using LayoutTraits[LayeredLayoutTraits.Layer] == 0
The problem with the combination is, that the resulting graph is not that strictly displayed like in the pictures below.

The idea behind is something like that in Picture 1:
* AV 100 is at position 0,0 (x,y)
* AV 200 is at position 1,0 (x,y)
* ...
* AV 330 is at position 2,3 (x,y)

With such a logic it is easy to generate something like Picture 2:
* AV 100 is at position 0,0 (x,y)
* (1,0 is empty: tree logic cares about positioning)
* AV 111 is at position 1,1 (x,y)
* (2,0 is empty: tree logic cares about positioning)
* (2,1 is empty: tree logic cares about positioning)
* (2,2 is empty: tree logic cares about positioning)
* AV 114 is at position 2,3 (x,y)

With the parameters Nodedistance and behaviour control settings for the arrows it woluld be very easy to get a graphically strict positioned diagram.
I think something like this is already done with lane diagrams.

Can you give be advices or hints or do you have ideas how to construct such a tree?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special sorted tree
Reply #1 - Aug 25th, 2009 at 11:48am
Print Post  
Hi,

Do you mean you have some constraints for which nodes should be placed in the same column? Or you can let the layout function choose the columns, but want them aligned as in the pictures?

Stoyan
  
Back to top
 
IP Logged
 
caseopeia
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Apr 8th, 2009
Re: Construction of special sorted tree
Reply #2 - Aug 26th, 2009 at 9:24am
Print Post  
Hello,

yes I have constrains: the numbers of the nodes.

On their basis the tree must be build and aligned.

So the layout function can not choose the column.

AV 100 is first node in 1. column,
  AV 110 is second node in 1. column,
  AV 120 is third node in 1. column,
  ...
AV 200 is first node 2. column
   ...

Due to the "Missing" nodes in 2. picture (empty space above AV111) I think this is difficult for current layout mechanisms regarding strict layout as shown in the pictures. Maybe you have a solution?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special sorted tree
Reply #3 - Aug 26th, 2009 at 12:10pm
Print Post  
So you know the order of the columns, and what nodes go in what column. Additionally, the order of nodes in a column is determined by the flow in the graph, right, there won't be links going up?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special sorted tree
Reply #4 - Aug 26th, 2009 at 2:20pm
Print Post  
Try this code:

Code
Select All
LayeredLayout ll = new LayeredLayout();
ll.Orientation = MindFusion.Diagramming.Layout.Orientation.Vertical;
ll.EnforceLinkFlow = true;
ll.StraightenLongLinks = true;
ll.NodeDistance /= 2;
ll.Arrange(diagram);

foreach (ShapeNode node in diagram.Nodes)
{
	int column = int.Parse(node.Text);
	node.Move(20 + column * 50, node.Bounds.Y);
}

foreach (DiagramLink link in diagram.Links)
{
	link.ControlPoints[0] = GetBottomCenter(link.Origin);
	link.ControlPoints[link.ControlPoints.Count - 1] = GetTopCenter(link.Destination);
}

diagram.RouteAllLinks();
 



Replace the int.Parse line with one that gets the column value from where you have it stored.

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


I love YaBB 1G - SP1!

Posts: 17
Joined: Apr 8th, 2009
Re: Construction of special sorted tree
Reply #5 - Aug 27th, 2009 at 8:51am
Print Post  
Hello,

can you give me a hint how GetTopCenter and GetBottomCenter are defined. I tried (without luck) with:

Code
Select All
        PointF GetBottomCenter(DiagramNode node)
        {
            PointF pt = new PointF(node.Bounds.X+(node.Bounds.Width/2), node.Bounds.Bottom);
            return pt;
        }
        PointF GetTopCenter(DiagramNode node)
        {
            PointF pt = new PointF(node.Bounds.X + (node.Bounds.Width / 2), node.Bounds.Top);
            return pt;
        } 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special sorted tree
Reply #6 - Aug 27th, 2009 at 9:01am
Print Post  
Hi,

Here's our version:

Code
Select All
private PointF GetBottomCenter(DiagramNode node)
{
	RectangleF r = node.Bounds;
	return new PointF(r.Left + r.Width / 2, r.Bottom);
}

private PointF GetTopCenter(DiagramNode node)
{
	RectangleF r = node.Bounds;
	return new PointF(r.Left + r.Width / 2, r.Top);
}
 



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


I love YaBB 1G - SP1!

Posts: 17
Joined: Apr 8th, 2009
Re: Construction of special sorted tree
Reply #7 - Aug 27th, 2009 at 12:33pm
Print Post  
Hello,

I programmed a small example which seems to work (see attached picture). Thanks a lot!

Now it is maybe a little bit difficult to calculate the column number based on the nodes text.

Do you think I have a chance to put the column number e.g. in a nodes "LayoutTraits"? So it should be easy to define the column number at tree build time and afterwards I can use the number to move the nodes like in your example. I am not sure if I disturb the layout mechanisms if I use e.g. LayeredLayoutTraits.Layer

What would you do to accomplish this saving?



Sincerly, Dirk.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special sorted tree
Reply #8 - Aug 27th, 2009 at 3:15pm
Print Post  
Hi Dirk,

There shouldn't be any problems if you save the column number in LayoutTraits, as long as you don't use one of the keys used by other layout classes that might try to typecast the value to a type different than int.

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