Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Construction of special tree (Read 8619 times)
caseopeia
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Apr 8th, 2009
Construction of special tree
Apr 8th, 2009 at 4:19pm
Print Post  
Dear Users,

currently I process a tree similar to the left in the picture below via FlowLayout (my own tree is far more complex, the nodes are derived from ContainerNode).
Further parameters: own Anchoring, LaneType.LaneGrid, PreferredRules.ConnectorRules, Lane=0 for "Root", Lane=1 for "Node1" and "Node7".
I hope I understood the concept behind FlowLayout or that, what is yet documented, and the use of the parameters right, but I already spent some nights on that ...

But what I really want to do is shown on right in the picture below:
* no root node, but "Node1" and "Node7" both top aligned towards each other (Rule: both have no parents, so aligned topmost)
* all elements not "centered" but "left" aligned
* "Node3" below "Node2" and "Node5". (Rule: "Node3" has "Node5" as parent)

So I ask you:
* has someboy any idea how to construct the tree on the right?
* Can I do that with derived nodes from ContainerNode?
* Maybe I am also interested on writing an own LayoutManager ... where can I find information on that?

Thank you for your ideas and Greetings from Germany,
Dirk Schwier.

[img]http://www.picamatic.com/show/2009/04/08/08/13/3181587_779x495.jpg[/img]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #1 - Apr 9th, 2009 at 8:11am
Print Post  
Hi Dirk,

I think LayeredLayout is most similar to your image, though it would move node7 closer to node6 to prevent the link from crossing that many layers. In the short run, we could add some property to let you fix some nodes to specific layers, e.g. node7 and node1 to layer1, or perhaps do that based on the nodes' in-degree. Then you could post-process the resulting layout by shifting all nodes in a layer to the left or right, so that nodes in specific path are aligned horizontally (e.g. node1->node6). There is no concept of layout manager in Flowchart.NET, but you can create custom layouts by setting the Bounds property of nodes and the Style, SegmentCount and ControlPoints of links.

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 tree
Reply #2 - Apr 15th, 2009 at 9:50am
Print Post  
Hi Stoyan,

first of all thank you for your quick answer, as suggested I now use LayeredLayout, which brought us closer to our target.

I think the introduction of the suggested property would be very helpful for us.
How long will this take to add this feature?

Nevertheless I still have some questions:
* what to you mean with "nodes' in-degree"?
* how can I align nodes in layers left (I hope not through the Bounds property, because of absolute coordinates)?

What I want to do is align groups of nodes in paths (vertical) and not in layers (horizontal) -> am I right in terminology layers/paths?
I understood, that you want to align the paths indirectly through the position of layers, but this is nor possible in all cases for me, so that I need to build vertical groups.
Is this also possible through layers?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #3 - Apr 15th, 2009 at 12:00pm
Print Post  
Hi Dirk,

In-degree is the number of incoming links, in graph-theoretic terminology 8) So we might either add a way to let you fix specific nodes to the first or last layer through the LayoutTraits of individual items, or a LayeredLayout property that automatically fixes all nodes of zero in/out degree to the first/last layer. I'm afraid the only way to shift the nodes is through their Bounds property.

Now if you need nodes to be aligned both horizontally and vertically, the OrthogonalLayout or GridLayout should be a better choice. Our developer will check how hard it will be to add some constraint for all nodes from a path to be placed on the same column.

Sincerely,
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 tree
Reply #4 - Apr 15th, 2009 at 2:32pm
Print Post  
Dear Stoyan,

first of all I think we are right in LayeredLayout or FlowLayout - OrthogonalLayout or GridLayout is nothing for the project i'm working on.
To fix specific nodes to the first/last layer is really a good idea and if I can place nodes from a path in the same column I can reach many targets.
The only thing I miss then is to change the order of the above columns (from left to right, columns can be identified by first node is layer).

Can you please talk to your developer and post the results here?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #5 - Apr 17th, 2009 at 8:17am
Print Post  
Hi Dirk,

We'll try to implement assigning nodes to the first/last layer in the next few days, and will create some example that shows how to align the nodes from some path.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #6 - Apr 20th, 2009 at 8:12am
Print Post  
This version lets you assign nodes to custom layers as shown below:
https://mindfusion.eu/_beta/fcnet_custom_layers.zip

Code
Select All
private void Form1_Load(object sender, System.EventArgs e)
{
	for (int i = 0; i < 7; ++i)
		NewNode(i);
	NewLink(0, 1);
	NewLink(0, 2);
	NewLink(0, 4);
	NewLink(1, 3);
	NewLink(3, 5);
	NewLink(4, 2);
	NewLink(2, 3);
	NewLink(6, 5);

	diagram.Nodes[0].LayoutTraits[LayeredLayoutTraits.Layer] = 0;
	diagram.Nodes[6].LayoutTraits[LayeredLayoutTraits.Layer] = 0;
	diagram.Nodes[5].LayoutTraits[LayeredLayoutTraits.Layer] = -1;

	LayeredLayout ll = new LayeredLayout();
	ll.EnableCustomLayers = true;
	ll.NodeDistance = 40;
	ll.Arrange(diagram);

	OrthogonalRouter router = new OrthogonalRouter();
	router.Arrange(diagram);
}

ShapeNode NewNode(int i)
{
	ShapeNode node = diagram.Factory.CreateShapeNode(0, 0, 20, 20);
	node.Text = "Node " + (i + 1);
	return node;
}

DiagramLink NewLink(int i1, int i2)
{
	return diagram.Factory.CreateDiagramLink(
		diagram.Nodes[i1], diagram.Nodes[i2]);
}
 



Later we'll post sample code that aligns the nodes in some path. Currently the result is this:



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #7 - Apr 20th, 2009 at 11:46am
Print Post  
This code aligns the nodes from some path:

Code
Select All
private void Form1_Load(object sender, System.EventArgs e)
{
	...
	ll.Arrange(diagram);

	AlignPath(ll.LayerDistance, 0, 1, 3, 5);

	OrthogonalRouter router = new OrthogonalRouter();
	router.Arrange(diagram);
}

private void AlignPath(float layerDist, params int[] nodes)
{
	DiagramNode first = diagram.Nodes[nodes[0]];
	float x = first.GetCenter().X;

	for (int i = 1; i < nodes.Length; ++i)
	{
		DiagramNode node = diagram.Nodes[nodes[i]];
		AlignLayer(node, x, layerDist);
	}
}

private void AlignLayer(DiagramNode pathNode, float x, float layerDist)
{
	float offsetX = x - pathNode.GetCenter().X;
	List<DiagramNode> layer = new List<DiagramNode>();
	foreach (DiagramNode node in diagram.Nodes)
	{
		if (Math.Abs(pathNode.Bounds.Top - node.Bounds.Top) < layerDist / 2)
			layer.Add(node);
	}
	foreach (DiagramNode node in layer)
	{
		RectangleF r = node.Bounds;
		r.X += offsetX;
		node.Bounds = r;
	}
}
 



Also if you need to sort the child nodes under some parent node, check this thread:
http://mindfusion.eu/Forum/YaBB.pl?board=wpfdg_disc;action=display;num=121691895...

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 tree
Reply #8 - Apr 20th, 2009 at 11:50am
Print Post  
Hi Stoyan,

thank you for the quick provision!
I will try this release today and I'll post the results here.

Greetings from (currently warm and sunny)
Germany.
  
Back to top
 
IP Logged
 
caseopeia
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Apr 8th, 2009
Re: Construction of special tree
Reply #9 - Apr 20th, 2009 at 10:38pm
Print Post  
Hello,

I implemented the "CustomLayers" together with "OrthogonalRouter" now in my application, the nodes on Layer0 are now on top. This is really nice!

(TcChartNode is inherited from ContainerNode):
Code
Select All
TcChartNode node = new TcChartNode(dg, ap, av);
node.Bounds = new RectangleF(10, 10, 120, 70);
node.AnchorPattern = AnchorPattern.TopInBottomOut;
node.Obstacle = true;

LayeredLayout ll = new LayeredLayout();
ll.EnableCustomLayers = true;
ll.NodeDistance = 200;
ll.Arrange(dg);

OrthogonalRouter router = new OrthogonalRouter();
router.Arrange(dg);

dg.RoutingOptions.Anchoring = Anchoring.Reassign;
dg.RouteAllLinks();
 



But I still have the problem, that the distance between the first layer nodes und the next one is to big. See the two pictures above.

Seems to be a problem with calculating distance - the more nodes are inside diagram, the bigger seems to be the distance.

Can I avoid this big distance?

Thank you, Dirk.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #10 - Apr 21st, 2009 at 8:26am
Print Post  
I've tried to reproduce it with a similar graph, but nothing like this happened. Are you sure you are not changing the vertical positions of the nodes in first layer at some point? Could you email that graph saved as XML to support@mindfusion.eu?

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 tree
Reply #11 - Apr 21st, 2009 at 9:22am
Print Post  
Hi Stoyan,

I send you the trees in XML format via email. I do not set the positions manually.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #12 - Apr 21st, 2009 at 10:12am
Print Post  
You should not set LayoutTraits[LayeredLayoutTraits.Layer] for all nodes that are not in the first layer to -1. -1 specifies that a node should be placed in the last layer, and this breaks the algorithm a bit. I've added this after loading the file, and Arrange worked fine:

foreach (DiagramNode node in diagram.Nodes)
     if (node is ContainerNode && (int)node.LayoutTraits[LayeredLayoutTraits.Layer] == -1)
           node.LayoutTraits.Clear();

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 tree
Reply #13 - May 19th, 2009 at 7:21am
Print Post  
Hello Stoyo,

I tested yout changes the last weeks and nearly everything is o.k. for this problem (besides, I have same other difficulties, but I will post them in an other thread).

Only one thing is a real problem: the lib shows me a "Trial" hint in Diagram, although I have a valid license installed on my PC. How can I change this?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Construction of special tree
Reply #14 - May 19th, 2009 at 8:49am
Print Post  
Hi Dirk,

You can find a download link for the licensed build on the private message page.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint