Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic tangled links in TreeLayout (Read 2126 times)
jgarrett
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 19th, 2011
tangled links in TreeLayout
Oct 27th, 2011 at 5:50pm
Print Post  
Hi,

I have created anchor points corresponding to radio buttons in my custom CompositeNode. There is a link emanating from each anchor point. Now I have an issue when arranging the chart using TreeLayout and its Anchoring value is set to Keep. For many nodes the order of child nodes in the tree does not correspond to the order of anchor points in the parent, and this makes the links all tangled up. Is there any way to make TreeLayout respect the order of my anchor points?
 
Thanks,
- Jacob
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: tangled links in TreeLayout
Reply #1 - Oct 28th, 2011 at 6:31am
Print Post  
Hi,

The only way I can think of is to arrange the links in the parent node's OutgoingLinks collection to match the order of their related anchor points.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
jgarrett
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 19th, 2011
Re: tangled links in TreeLayout
Reply #2 - Oct 29th, 2011 at 7:18am
Print Post  
Thanks for the hint - connections will be drawn by our users in no definite order, so I ended up sorting them before arranging the tree. Hopefully this will be useful to somebody:

class SortByOAP : IComparer
{
     public int Compare(object x, object y)
     {
           DiagramLink l1 = (DiagramLink)x;
           DiagramLink l2 = (DiagramLink)y;
           return l1.OriginAnchor.CompareTo(l2.OriginAnchor);
     }
}

void OnTreeLayout(object sender, EventArgs e)
{
     foreach (DiagramNode n in diagram.Nodes)
     {
           ArrayList l = new ArrayList(n.OutgoingLinks);
           l.Sort(new SortByOAP());
           n.OutgoingLinks.Clear();
           foreach (DiagramLink dl in l)
                 n.OutgoingLinks.Add(dl);
     }
     TreeLayout tl = new TreeLayout();
     tl.Type = TreeLayoutType.Centered;
     tl.Direction = TreeLayoutDirections.LeftToRight;
     tl.LinkStyle = TreeLayoutLinkType.Rounded;
     tl.Anchoring = Anchoring.Keep;
     tl.Arrange(diagram);
}

It would be great to have this as a built-in sort option in TreeLayout Smiley May I also suggest you guys add methods to implement some common operations on the Diagram, for example SelectAll, InvertSelection, AlignSelection. They weren't too hard to code myself, but it should make a nice impression to your future evaluators Smiley

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: tangled links in TreeLayout
Reply #3 - Oct 31st, 2011 at 9:42am
Print Post  
Thank you for your hints too 8) We'll try to implement them for the next release.

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