Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Cascading Links on Layered Layout (Read 6494 times)
ChrisGC
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 2nd, 2010
Cascading Links on Layered Layout
Jul 22nd, 2010 at 10:32am
Print Post  


Hi,

Given the above diagram layered layout, as you can see it is impossible to deduce the parant node for a given child. Is there a way i can avoid link overlap whilst still using the Cascading LinkStyle?

Thanks in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cascading Links on Layered Layout
Reply #1 - Jul 22nd, 2010 at 11:21am
Print Post  
Hi,

Try this to avoid overlapping links:

Code
Select All
private void OnLayout(object sender, RoutedEventArgs e)
{
	var ll = new LayeredLayout();
	ll.Anchoring = Anchoring.Ignore;
	ll.Arrange(diagram);

	foreach (var node in diagram.Nodes)
		DistributeLinks(node);
	diagram.RouteAllLinks();
}

private void DistributeLinks(DiagramNode node)
{
	double d = node.Bounds.Width / (node.OutgoingLinks.Count + 1);
	double x = node.Bounds.Left + d;
	double y = node.Bounds.Bottom;

	var links = new List<DiagramLink>(node.OutgoingLinks);
	links.Sort((l1, l2) => l1.Destination.Bounds.Left.CompareTo(l2.Destination.Bounds.Left));
	foreach (DiagramLink link in links)
	{
		link.ControlPoints[0] = new Point(x, y);
		link.UpdateFromPoints();
		x += d;
	}
} 



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


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 2nd, 2010
Re: Cascading Links on Layered Layout
Reply #2 - Jul 22nd, 2010 at 1:14pm
Print Post  
That is looking a lot better thank you very much!
  
Back to top
 
IP Logged
 
binuvc
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 46
Joined: Nov 7th, 2011
Re: Cascading Links on Layered Layout
Reply #3 - May 4th, 2012 at 1:06pm
Print Post  
Hi,

We are using layred layout as follows :
Private void ApplyLayout()
{
            LayeredLayout layout = new MindFusionLayout.LayeredLayout();      
            layout.Anchoring = Anchoring.Ignore;
            layout.Direction = MindFusionLayout.Direction.Straight;
            layout.EnforceLinkFlow = true;
            layout.KeepGroupLayout = false;
            layout.KeepRootPosition = false;
            layout.LayerDistance = 50;
            layout.LinksCompactFactor = 3;
            layout.LinkType = LayeredLayoutLinkType.Cascading;
            layout.MultipleGraphsPlacement = MultipleGraphsPlacement.Vertical;
            layout.NodeDistance = 100;
            layout.Orientation = MindFusionLayout.Orientation.Vertical;
            layout.SplitLayers = false;
            layout.StableSort = true;
            layout.StraightenLongLinks = false;
            layout.Arrange(diagramLite);

            foreach (var node in diagramLite.Nodes)
                DistributeLinks(node, layout.LayerDistance);
            diagramLite.RouteAllLinks();

}

private void DistributeLinks(DiagramNode node, double layerDistance)
        {
            double x = node.Bounds.Left + node.Bounds.Width / 2;
            double y = node.Bounds.Bottom;

            var links = new List<DiagramLink>(node.OutgoingLinks);
            links.Sort((l1, l2) => l1.Destination.Bounds.Left.CompareTo(l2.Destination.Bounds.Left));
            foreach (DiagramLink link in links)
            {
                link.OriginIndex = 3;
                link.ControlPoints[0] = new Point(x, y);
                link.ControlPoints[1] = new Point(x, y + layerDistance / 2);
                link.DestinationIndex = 1;
            }
     }

The layout generated is not the expected one
Please find the attachments of the  actual layout(attachment 1) and expected layout (attachment 2)
Please advice on how to achieve the the expected layout.

Thanks
BinuVC
  

layred_current.jpg (Attachment deleted)
layred_expected.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cascading Links on Layered Layout
Reply #4 - May 7th, 2012 at 8:54am
Print Post  
You should get results similar to layout_expected if you remove the DistributeLinks and RouteAllLinks calls. In order to center the links relatively to the nodes, you might have to set the nodes AnchorPattern property and run the layout with Anchoring set to Keep/Reassign.

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


I love YaBB 1G - SP1!

Posts: 46
Joined: Nov 7th, 2011
Re: Cascading Links on Layered Layout
Reply #5 - May 18th, 2012 at 12:08pm
Print Post  
HI,


I am still not able to achieve the desired layout.
Please find the following attachment as well.

Please advice.



Thanks
BinuVC
  

illustration.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cascading Links on Layered Layout
Reply #6 - May 21st, 2012 at 8:24am
Print Post  
If this shows the layout you expect, you can't get it automatically because LayeredLayout places child nodes on the layer directly below their closest ancestor in the directed graph. E.g. "Application Model" and "Form" from the image will be placed on the same layer if using the default behavior - the layout class cannot find automatically that you'd like them on different layers. If you know what node should go to what layer, set LayeredLayout.EnableCustomLayers to true and assign layer indices to LayoutTraits[LayeredLayoutTraits.Layer].

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