0

I noticed that when connecting multiple edges to a single (rectangle-shaped) vertex, the positions where they connect are evenly distributed across the side of the vertex. Is there a way to change this behavior? I'm using mxHierarchicalLayout.

In my graph, I want the edges to be as straight as possible (but only horizontal and vertical). This is what I currently have:

enter image description here

For example, why is edge "G" slightly bend? I'd like it to go in a straight horizontal line from "PIC" to "W4". Ideally, I'd like to change a setting per-vertex that sets the edge connecting behavior to "connect where you like", and let the layouting figure out the best spot where the edge makes the least corners.

I know I can set "exitX/Y" and "entryX/Y", but this would require me to calculate these values and the whole layouting process manually. I'm looking for a better way to achieve this.

Bence Kaulics
  • 7,066
  • 7
  • 33
  • 63
Maximilian Csuk
  • 584
  • 1
  • 6
  • 21

1 Answers1

3

You can have a try with Orthogonal edgestyle.

Map<String, Object> EdgeStyle = graph.getStylesheet().getDefaultEdgeStyle();
EdgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.OrthConnector);
EdgeStyle.put(mxConstants.STYLE_STROKECOLOR, "red");
EdgeStyle.put(mxConstants.STYLE_STROKEWIDTH, 2);

This will make your edges to be like the ones below. I think it should work without the ports too.

enter image description here

Do not forget to enable edge style in the layout.

layout.setDisableEdgeStyle(false);
Bence Kaulics
  • 7,066
  • 7
  • 33
  • 63