I am using the LayeredDigraphLayout to provide an autolayout functionality for my diagrams.
In my scenario, I got 2 kinds of nodes. At first a component with port symbols and “free flying” port symbols.
I donÂ´t know, why the red marked ports (RPort and RPort1) within the image (the are just nodes) are not placed at left-most position. How can I solve the problem?
Thank you very much!
That’s odd. Have you set any layout-related properties on those two nodes? I assume you are using a different template for them.
Or have you customized the layout at all?
Yes I used different XAML templates for them. I call the layouter one time by using the following source code:
LayeredDigraphLayout layoutEngine = new LayeredDigraphLayout(); layoutEngine.LayerSpacing = 150; layoutEngine.PackOption = LayeredDigraphPack.All; layoutEngine.AggressiveOption = LayeredDigraphAggressive.More; layoutEngine.SetsPortSpots = false; layoutEngine.Diagram = this.compositionDiagramView;layoutEngine.DoLayout(layoutEngine.Diagram.Nodes, layoutEngine.Diagram.Links);
Are you sure that the Links go from the red marked Nodes to the ASWC Node? If the direction of the links are reversed, I think you would get that layout. Select one of the Links and look at it in the debugger.
Yes you are right. If I change the "From <–> To " direction, the RPorts will layouted correctly and the layouter places PPort and PPort1 wrong. Can I change the behavior by changing the LayeredDigraphLayout class. I have more than two kind of free flying ports and I thing the layouter has to orientate at the specified spot of the free flying port.
In general, I think you’re going to have to state what you mean. If you don’t, any links connecting those “free flying” nodes to each other would be ambiguous what the intended direction is. (But you might not care about that case, if you cannot have that situation.)
I got the same problem with with the PPort the other way around (if the PPort at the component is on the other component side)
That scenario looks like this:
But I have no idea how I can handle that problem dynamically within the layouter.
You just need to be sure that the link goes from the node highlighted in red to your ASWC1 node. The FromSpot and the ToSpot do not affect the layer-decisions of any layout.
Yes I understand the situation, but I think I cannot change the “From” and “To” information for each link in each situation. In my scenario you can move the Port2 in the ASWC1 Component to each side of the node. Also you can move the “Free flying” Port2 to every position within the diagram. If the component port Port2 is placed on the right side, I want to place the free flying port Port2 on the right side of the component. If the component port Port2 is placed on the left side, I want to place the free flying port Port2 on the left side of the component if I used the LayeredDigraphLayout.
I’m assuming you do not want the layout to automatically change the position and orientation of any ports on any nodes. (That’s correct, isn’t it?)
If the placement of the PPort2 port on the left or right side of the ASWC1 node is performed explicitly, then at that time you could make sure that the direction of the connected link is appropriate, reversing it if needed.
If I changed the “From <–> To” relation directly before executing the autolayout it seems to work.
Thank you :)