1

I've a graph with 18 vertices and lots of edges. Due to the number of elements involved and their structure the built-in algorithms available (i.e. mxHierarchicalLayout used for the shown image ) are not working as expected, causing the majority of edges with description to overlap, as shown in the picture Current status sample.

Doing some tests and checks in the source code I managed to change only few things on the edges trough the geometry of the mxCell:

  • Edge lable
  • Control points

However I'm not finding any way to manipulate the point of the source and target terminals. Can anyone suggest me the proper classes/methods to be used to control where the terminal should be connected.

Any help/info would be appreciated.

The code I managed to test to manipulate the edges is the following:

..
    Arrays.asList(edges).stream().map(edge -> (mxCell) edge).forEach(edge -> {
            mxGeometry newGeo = (mxGeometry) edge.getGeometry().clone();
            // TODO calculate condition
            // This code actually move the label from the default
            // position
            mxPoint offset = new mxPoint(edge.getGeometry().getPoint().getX() + EDGE_OFFSET,
                    edge.getGeometry().getPoint().getY() + EDGE_OFFSET);
            newGeo.setOffset(offset);
            newGeo.setX(newGeo.getX() + 1);
            if (newGeo.getPoints() != null) {
                newGeo.getPoints().forEach(point -> {
                    point.setX(point.getX() + 200);
                    point.setY(point.getY() + 200);
                });
            }
            model.setGeometry(edge,newGeo);
    });

Thanks and regards

Frodo Baggins
  • 8,290
  • 6
  • 45
  • 55
Ugo Delle Donne
  • 183
  • 1
  • 6

1 Answers1

0

The position of source and target terminals are determined according to the shape of the cell and its border. This can be obtained by using mxGraphView.getPerimeterPoint(cellState, point...), and which uses mxGraphView.getPerimeterFunction and mxGraphView.getPerimeterBounds.

This works well for an initial placement of edge labels (I use this to place multiple edge labels--such as cardinalities in UML class diagrams).

However, this method uses an mxCellState and for some reason I do not yet know it cannot be used when repositioning using an mxEventListener on move events. cell states are still set on the previous position of the cell when events are fired.

Ronan
  • 21
  • 3