Question

I am trying to draw an edge with specific edge style, other than the default one. The problem is that I am drawing an edge between a cell and a point so that the edge appears as if coming from a cell to space in the graph.

edge = graph.insertEdge(parentCell, null, label, myCell,null);

I get exception:

"java.lang.ClassCastException: com.mxgraph.util.mxPoint cannot be cast to com.mxgraph.model.mxICell"

when I use this code:

mxGeometry geoCell = myCell.getGeometry();
mxPoint termPoint = new mxPoint(geoCell.getX() - (120 - (offset)), geoCell.getY() + 100);
graph.insertEdge(parentCell, null, "", myCell, termPoint, "edgeStyle=elbowEdgeStyle;elbow=horizontal;orthogonal=0;");

I am using JGraphX 1.10. Is there something I can replace the point with that wouldn't error and give the appearance of the edge connecting to space?

Was it helpful?

Solution

Try setting the terminal point on the geometry of the edge, you can't use the point as a source terminal as it's expected to be a cell (see exception):

edge.geometry.setTerminalPoint(termPoint, true);

If you are trying to implement a space between the terminal and the edge you can also use the STYLE_PERIMETER_SPACING for the vertex or one of STYLE_SOURCE/TARGET_PERIMETER_SPACING for the edge.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top