Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) LayeredLayout problem (Read 11314 times)
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
LayeredLayout problem
Sep 1st, 2009 at 3:49pm
Print Post  
Hi, i need help in this scenario, I have graph, something like class diagram, and I need to layout it into hierarchical layout. I use LayeredLayout (TreeLayout is not possible, graph might not be a tree), but this is still happnenig to me: sometimes some links have unwanted crossings just like on the first screenshot. Is there a way how to generate layout without these crossings?
bad:

good:
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: LayeredLayout problem
Reply #1 - Sep 1st, 2009 at 3:56pm
Print Post  
Also another issue, I use my own structures for serializing info about created nodes and links: Bounds for nodes, and Origin+Destination+Line points for links. I'm still experiencing problems with recreating the original layout with this information: Links are somehow stubborn - even though I set manually number of segments and every point on the connection line, the lines go through different places the before.
So the question is, if I know origin node, destination node and the shape where the link was before, how to create new graph with the same items and same link positions?
for now I use:
Code
Select All
DiagramLink item = new DiagramLink(diagram, origin, destination)
    {Style = LinkStyle.Cascading, SegmentCount = (short) (link.Points.Count - 1)};
for (int i = 0; i < link.Points.Count; i++) item.ControlPoints[i] = link.Points[i];
origin.OutgoingLinks.Add(item);
destination.IncomingLinks.Add(item);
item.Route(); 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LayeredLayout problem
Reply #2 - Sep 1st, 2009 at 6:23pm
Print Post  
Version 5.3.2 (now in beta tests) adds a StraightenLongLinks property to LayeredLayout that should help in that case. The following code created the layout shown below.

Code
Select All
foreach (DiagramNode node in diagram.Nodes)
	node.AnchorPattern = AnchorPattern.TopInBottomOut;

var ll = new LayeredLayout();
ll.StraightenLongLinks = true;
ll.NodeDistance /= 2;
ll.Orientation = Orientation.Vertical;
ll.LinkType = LayeredLayoutLinkType.Cascading;
ll.Anchoring = Anchoring.Reassign;
ll.Arrange(diagram);

diagram.ResizeToFitItems(5);
 





Regarding custom serialization, make sure the AutoRoute property of links is disabled before setting the links SegmentCount and ControlPoints values.

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


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: LayeredLayout problem
Reply #3 - Sep 4th, 2009 at 8:42am
Print Post  
The StraightenLongLinks works perfectly, thanks, looking forward to final 5.3.2 version Smiley

But the problems with recreating links still persists.
It looks like this: when the diagram is created, it looks quite good, but once node is moved, links no longer looks cascading. After some investigation I found, that the anchor points are in right places, but the direction of link direction from node is not up/down, but left - it looks weird in top-middle or bottom-middle anchor point. How could this happen?
Edit: solved using
Code
Select All
CascadeOrientation = Orientation.Vertical 


Oh My God, It's Full of Switches Smiley


And another question, if I use switch:
Code
Select All
MultipleGraphsPlacement = MultipleGraphsPlacement.MinimalArea 


in LayeredLayout, is it possible to set minimal horizontal and vertical distance between each graph? Now they are really tightly coupled together and it doesn't look well.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LayeredLayout problem
Reply #4 - Sep 4th, 2009 at 9:05am
Print Post  
Yes, we've been hoarding switches for years... 8) The algorithm should leave empty space around the subgraphs as large as specified in layout.Margins, so try setting a larger Margins value.

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


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: LayeredLayout problem
Reply #5 - Sep 9th, 2009 at 8:16am
Print Post  
Another question - if I got two nodes, that are connected with two links with same direction (two independent relations between them). Both links got Text value set. Is there a way how to arrange them automatically in a way, that both text labels are readable, not overlapping?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LayeredLayout problem
Reply #6 - Sep 9th, 2009 at 11:12am
Print Post  
Try calling the ReassignAnchorPoints method on both nodes to pull their links apart.

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


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: LayeredLayout problem
Reply #7 - Sep 18th, 2009 at 2:31pm
Print Post  
I've got this issue for quite a long time: When I select a group nodes - about 6, some of them linked, and I want to layout hem into layered or tree layout. But if I call my layout method, selected nodes are moved automatically to the upper left location of diagram. Is there a way to, that these layouted nodes will be moved to:
- empty space somewhere in diagram
- the center point of the their previous location
Using root node is a good idea, but not every time is possible to select the right root node.

And other question, can you give me some hint, which layouting mechanism might be best for this situation:
I've got a diagram with dozens of nodes, they are of three kinds currently, but there might be more kinds in the future. They are in linked in generic (visual studio class-like) diagram.
I use Layered layout now, but sometimes nodes are placed quite strangely...
Any recommendation? Smiley
It should be graph aligned to some grid, it should look compact and it needs to be easy to identify all relations there.
Example:
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LayeredLayout problem
Reply #8 - Sep 18th, 2009 at 2:55pm
Print Post  
I suppose you could set LayeredLayout.Margins to make the selected items appear their initial position. Does that image show what results you are after, or what you are getting?
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: LayeredLayout problem
Reply #9 - Sep 19th, 2009 at 5:58pm
Print Post  
Using LayeredLayout.Margins is not a good idea, because this value is used for each graph in selection when using MultipleGraphsPlacement switch. There should be some easy way how to preserve the location of selected nodes when layouting.
Also it looks, that it does not work as expected
For example when current selection has bounds: X960, Y160, W90, H115, then I set  layeredLayout.margins = new SizeF(bounds.Location), but after Arrange call the selection is moved to some freaky location X1495 Y240.

The solution is probably moving layouted nodes selection manually in code to chosen location, there's no build in method, is it?

Also another idea, if I set root node in LayeredLayout, nodes from other subgraphs are not layouted at all. That's normal behavior? Is there a way to layout yeach subgraph in it's root and then put these subgraphs aligned next to each other?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LayeredLayout problem
Reply #10 - Sep 21st, 2009 at 7:20am
Print Post  
The Margins value is added to Diagram.Bounds.Location to determine the location of the arranged graphs, so you could temporarily change Diagram.Bounds to a rect that corresponds to the selection bounding rect minus the margins you are using.

Setting Root specifies just which subgraph connected to the root node should be arranged. In TreeLayout it further specifies which tree branch should be arranged.

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


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: LayeredLayout problem
Reply #11 - Sep 22nd, 2009 at 10:57am
Print Post  
Thanks for help, I've solved the issue with my own methods for moving group of nodes around Diagram.

Is there an event, that is fired right after creating of new link using dragging is canceled by releasing pressed mouse button? There's about 12 Link events, but none of them is especially for this purpose as far as I know.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LayeredLayout problem
Reply #12 - Sep 22nd, 2009 at 11:44am
Print Post  
There is a LinkModifyCancelled event, so we'll add a similar event raised when creating links. It should be ready in a few days.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LayeredLayout problem
Reply #13 - Sep 26th, 2009 at 9:37am
Print Post  
This version adds NodeCreateCancelled and LinkCreateCancelled events:
https://mindfusion.eu/_beta/fcnet_cancelcreate.zip

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


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: LayeredLayout problem
Reply #14 - May 3rd, 2010 at 1:03pm
Print Post  
Hi, I'm looking for a hint, we're using diagrams with generic relations and named links, also currently using the layered layout for positioning the nodes. We're facing issues with the final layout, because it doesn't look "good" - for example, the named polyline links is not, what we want - straight simple link would be better. Is there a way to force the layout algorithm to generate more appealing graph?

Or perhaps, is there a way saying "these links are more strong, than those links, so prefer the strong links in hierarchical layout and then position those weaker links somehow". (Folder is strong link, Lookup field is a weak link in the first image)

The first image shows the common type of links between nodes. The second attached screen shows the common result of layouting using layered layout - it looks quite chaotic.

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