sourceport/target port of an edge are not working correctly RRS feed

  • Question

  • I am using only the layout DLL and not the drawing DLL because I want to use only the automatic layout capability of the package and draw on my own using native graphic capabilities (in future this will be replaced by a 3rd party drawing engine).

    I am using Sugiyama layout with Rectilinear Edge Routing (RER). 

    Also since Sugiyama layout arranges the node from bottom-->top and since I wanted left-->right, I applied PlaneTransformation in the layoutsettings to rotate the layout 90 degrees clock wise so that bottom becomes left and top becomes right. Below is the code:

     var settings = new SugiyamaLayoutSettings {
                    Transformation = PlaneTransformation.Rotation(Math.PI / 2),
                    EdgeRoutingSettings = { EdgeRoutingMode = EdgeRoutingMode.Rectilinear },

    I want to connect Node A to Node B and each node is a rectangle. I specifically want the edge's source port to come from A's bottom boundary.I set the source and target ports accordingly as follows

                Node n1 = graph.FindNodeByUserData("A");
                Node n2 = graph.FindNodeByUserData("B");
                Edge myedge = new Edge(n1, n2);
                Microsoft.Msagl.Core.Geometry.Rectangle rect= n1.BoundingBox;
                double midx = rect.LeftBottom.X + (rect.Width/ 2); //find the midpoint of the bottom edge of the rect
                double midy = rect.LeftBottom.Y;
                Microsoft.Msagl.Core.Geometry.Point P=new Microsoft.Msagl.Core.Geometry.Point(midx,midy);
                myedge.SourcePort = new FloatingPort(n1.BoundaryCurve,P); //assign the port to the rectangle's boundary curve at point P
                myedge.TargetPort = new FloatingPort(n2.BoundaryCurve, n2.Center);

    However the edge does not appear where it needs to.

    Can you help me here?

    Monday, April 13, 2020 4:40 PM