简体   繁体   English

如何更改 mxgraph 中 mxCell 和 mxPoint 之间的边缘样式?

[英]How do I change the edge style between an mxCell and mxPoint in mxgraph?

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.我正在使用 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?有什么我可以用不会出错的东西来代替点并给出连接到空间的边缘的外观吗?

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.如果您尝试在终端和边缘之间实现空间,您还可以使用STYLE_PERIMETER_SPACING作为顶点或使用STYLE_SOURCE/TARGET_PERIMETER_SPACING之一作为边缘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM