Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Nodes Get Delete while distribute Horizontally (Read 5182 times)
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Nodes Get Delete while distribute Horizontally
May 14th, 2009 at 12:56pm
Print Post  
Hi,

I have some nodes and links in my diagram. When I select some nodes (with and without link attached node) and try to distribute horizontally, all those nodes which have any link associated; gets deleted.

The code which I have used for this is

Code
Select All
DiagramItemCollection items = new DiagramItemCollection();
				    DiagramNodeCollection nodes = diagram.Nodes;
				    DiagramLinkCollection links = diagram.Links;

				    foreach (DiagramNode node in nodes)
				    {
					  if (node.IncomingLinks.Count != 0 || node.OutgoingLinks.Count != 0)
					  {
						items.Add(node);
					  }
				    }

				    foreach (DiagramLink link in links)
				    {
					  items.Add(link);
				    }

				    TreeLayout treeLayout = new TreeLayout();
				    treeLayout.KeepGroupLayout = true;
				    treeLayout.Type = TreeLayoutType.Cascading;
				    treeLayout.Direction = TreeLayoutDirections.LeftToRight;
				    treeLayout.MultipleGraphsPlacement = MultipleGraphsPlacement.Horizontal;
				    treeLayout.Balance = TreeLayoutBalance.RightHeavy;
				    treeLayout.Arrange(diagram, items);

				    foreach (DiagramLink link in links)
				    {
					  link.Style = LinkStyle.Polyline;
					  link.Route();
					  link.SegmentCount = 1;
				    } 



Please let me know, where I am wrong ?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes Get Delete while distribute Horizontally
Reply #1 - May 14th, 2009 at 2:03pm
Print Post  
TreeLayout might place the nodes outside the currently visible part of the diagram. Print items[0].Bounds.toString() after calling Arrange to see where the first node has been placed; my guess is it's at the upper left of diagram.Bounds.
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Nodes Get Delete while distribute Horizontally
Reply #2 - May 15th, 2009 at 4:39am
Print Post  
Hi Stoyo,

You were right.TreeLayout place the nodes outside the currently visible part of the diagram and that is BottomRight portion of the diagram.Now tell me what I could do to move them in visible area?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes Get Delete while distribute Horizontally
Reply #3 - May 15th, 2009 at 7:42am
Print Post  
Hi Bala,

Try with TreeLayout.KeepRootPosition - true.

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: Nodes Get Delete while distribute Horizontally
Reply #4 - May 15th, 2009 at 9:22am
Print Post  
Thanks Stoyan,its working Smiley
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Nodes Get Delete while distribute Horizontally
Reply #5 - Jun 16th, 2009 at 10:24am
Print Post  
Hi Stoyan,

Continuing on this link i want to know something that previously i had a requirement to distribute diagram nodes vertically/horizontally for unconnected nodes but now i want that it should appear for all the nodes whether unconnected or connected.

See code below of vertical equal distribution for more information.

Code
Select All
TreeLayout treeLayout = new TreeLayout();
    treeLayout.KeepGroupLayout = true;
treeLayout.Type = TreeLayoutType.Cascading;
treeLayout.Direction = TreeLayoutDirections.LeftToRight;
    treeLayout.MultipleGraphsPlacement = MultipleGraphsPlacement.Vertical;
    treeLayout.Balance = TreeLayoutBalance.RightHeavy;
TreeLayout.KeepRootPosition = true;
    treeLayout.Arrange(diagram);

    foreach (DiagramLink link in links)
    {
  link.Style = LinkStyle.Polyline;
  link.Route();
  link.SegmentCount = 1;
    }
 



Doing above is altering node position horizontally also, which i do not want. Please suggest what can be done here.

Thanks,
Anurodh
« Last Edit: Jun 16th, 2009 at 12:41pm by anurodhora »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes Get Delete while distribute Horizontally
Reply #6 - Jun 16th, 2009 at 12:56pm
Print Post  
Could you email us a sample diagram and an image showing what you need to do with it?
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Nodes Get Delete while distribute Horizontally
Reply #7 - Jun 16th, 2009 at 1:20pm
Print Post  
For connected nodes it is working fine please have a look at initial code see May 15th posting but now i want that this should happen for all the nodes so i have written some code in sync with that, see code in my previous post, the problem is just that for vertical distribution nodes x position is also changing and for horizontal distribution nodes y position is changing which was not the case previously.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes Get Delete while distribute Horizontally
Reply #8 - Jun 17th, 2009 at 5:26am
Print Post  
I'm still not sure if I understand what you need. Is it applying TreeLayout to each connected sub-graph in the diagram, without moving the sub-graph?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes Get Delete while distribute Horizontally
Reply #9 - Jun 18th, 2009 at 7:38am
Print Post  
We have tried this with a graph similar to the one from your images. Running LayeredLayout with Orientation set to Horizontal results in layouts similar to image1 and image2. You will have to set IgnoreLayout = true for the blue links from the images, or otherwise the nodes they connect will be placed on different layers. Then the only difference is in Y positions of the nodes from the right side of the images; you might process them additionally after the layout to align their Y coordinates to the nodes from the previous layer.

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