Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Query regarding layout. (Read 3753 times)
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Query regarding layout.
Mar 20th, 2009 at 6:27am
Print Post  
Hi,

I have few randomly arranged nodes in my diagram few are connected randomly to each other few have no links at all and I am using GridLayout to arrange those nodes upon click of a button.

I have following requirements while using the GridLayout arrangement for the diagram:

1. After arrangement using gridlayout the nodes should start from the top right corner of the diagram.

2. The arrangement should not change until and unless I change the position of any of the node explicitly if not done the arrangement should not change even if I keep clicking the button continuously.

3. I want the link style for the GridLayout to be straight.

Any suggestions how can I accomplish these tasks.

Thanks and Regards,
Anant Shukla.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query regarding layout.
Reply #1 - Mar 20th, 2009 at 7:21am
Print Post  
Hi,

1. This is not supported, the start node is always placed at top-left. You could loop over all nodes after calling Arrange and move them to GetContentBounds().Right - node.Bounds.X to flip the grid horizontally; that should move the start node to the top-right.

2. Set RandomSeed to some fixed value greater than 0 and the algorithm should create the same layout each time you call Arrange().

3. Loop over the links after Arrange() and set their Style to Polyline.

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


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Query regarding layout.
Reply #2 - Mar 20th, 2009 at 2:26pm
Print Post  
Hi Stoyan,

Thanks for the reply.

I have few more requirements which are as follows :

1. While arranging the nodes in GridLayout the links overlap the intermediate nodes, i.e nodes between the source and destination node for the link, in the diagram which is not desired.

2. The position of nodes with no links neither outgoing nor incoming should not be effected by the applied layout arrangement.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query regarding layout.
Reply #3 - Mar 20th, 2009 at 3:28pm
Print Post  
Hi Anant,

1. This could happen if you have implemented the suggestion for point 3 from the post above. In that case, call link.Route() after setting Style.

2. You could remember their initial positions and restore them after the layout, or use the Arrange(DiagramItemCollection) overloaded method, with all nodes and links except the unconnected nodes added to the collection.

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


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Query regarding layout.
Reply #4 - Mar 21st, 2009 at 6:30am
Print Post  
Hi Stoyan,

1. The node overlapping issue is resolved but the links between nodes after arranging the diagram in GridLayout is not working fine they are still bending I need them to be straight.

The code used by me based on your suggestions is as follows :

DiagramLinkCollection links = diagram.Links;
foreach ( DiagramLink link in links){
link.Style = LinkStyle.Polyline;
}

2. Can you please tell me how can I get those nodes from the diagram from which no link is connected neither incoming nor outgoing. A sample code of your suggestion from your last post will help a lot.

Can you tell me what I am doing wrong.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query regarding layout.
Reply #5 - Mar 22nd, 2009 at 6:30am
Print Post  
Hi Anant,

1. If link.AutoRoute is enabled, set it to false before changing Style. You might also set SegmentCount = 1.

2. Loop over DiagramNodes and check the Count property of the nodes' IncomingLinks and OutgoingLinks collections.

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


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Query regarding layout.
Reply #6 - Mar 23rd, 2009 at 11:51am
Print Post  
Hi Stoyan,

I have incorporated your suggestions from last post and the isolated nodes i.e nodes with no incoming or outgoing nodes are not altered by the layout rearrangement. But the complete layout is distorted the complete arrangement gets weird. The arrangement causes each node to be placed in an single line with links overlapping the nodes.

The code used by me is as follows :

private void btnDisHorizontally_Click(object sender, RoutedEventArgs e)
{
DiagramItemCollection items = new DiagramItemCollection();
foreach (DiagramNode node in diagram.Nodes)
{
if (node.IncomingLinks.Count != 0 || node.OutgoingLinks.Count != 0)
{
items.Add(node);
}
}

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

DiagramLinkCollection links = diagram.Links;
foreach ( DiagramLink link in links){
link.Style = LinkStyle.Polyline;
link.Route();

}
}

Can you please suggest what is that I am missing,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query regarding layout.
Reply #7 - Mar 23rd, 2009 at 1:00pm
Print Post  
Hi Anant,

You must also add all links to that collection.

Stoyan
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Query regarding layout.
Reply #8 - Mar 23rd, 2009 at 1:23pm
Print Post  
Thanks Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint