Port Positioning


i’m quite new to diagramm.net and i use the sample FlowCharter project and try to put ports in the center of each edge and maybe a little bit outside and not inside the node.

Is this possible with an easy solution?


If you look at GraphNode in Flowcharter, you’ll see an override for LayoutChildren.

and you’ll note that the existing code tweaks the port position for the left and right ports
on 3 of the node shapes.

That’s the spot you would want to modify to do all the ports.

Here’s the code that the GoTextNode uses to position all 4 ports.

  GoObject back = this.Background;

  if (back != null) {
    if (this.TopPort != null)
      this.TopPort.SetSpotLocation(MiddleTop, back, MiddleTop);
    if (this.RightPort != null)
      this.RightPort.SetSpotLocation(MiddleRight, back, MiddleRight);
    if (this.BottomPort != null)
      this.BottomPort.SetSpotLocation(MiddleBottom, back, MiddleBottom);
    if (this.LeftPort != null)
      this.LeftPort.SetSpotLocation(MiddleLeft, back, MiddleLeft);

You should be able to get what you want by changing the spot arguments… e.g.

this.TopPort.SetSpotLocation(MiddleTop, back, MiddleTop);


this.TopPort.SetSpotLocation(MiddleBottom, back, MiddleTop);

You got it. Thank you very much.