当 editpart 移动时,Gef 连接端点位置会更新
我有一个已建立连接的编辑部分。当编辑部分位置更改时,连接端点也必须更新其位置,并且与编辑部分的连接必须仅出现在矩形的四个边上。任何人都可以建议我如何实现这一目标吗?
I have an editpart's to which connections are made. When the editpart location is changed the connection endpoints also must update their location, and also the connection to the editparts must occur only to the four sides of the rectangle. Can can any one advice me how to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新端点的位置相当简单:接口 org.eclipse.draw2d.Connection 定义了分配源锚点和目标锚点的方法。确保在
Connection
实现中,在设置锚点时将AnchorListener
附加到锚点。当调用anchorMoved(...)
时,您可以重新验证(并重新绘制)连接(PolylineConnection
提供了一个很好的默认实现 - 看看它)。要定义连接应在何处进行可视化连接,您必须在
getSourceConnectionAnchor(...)
和getTargetConnectionAnchor 中提供
方法。org.eclipse.draw2d.ConnectionAnchor
的实现形状编辑部分的 (...)Updating the location of the endpoints is fairly easy: The interface
org.eclipse.draw2d.Connection
defines methods for assigning source and target anchors. Ensure that in yourConnection
implementation you attach anAnchorListener
to the anchors, when they are set. WhenanchorMoved(...)
is called, you can revalidate (and repaint) the connection (PolylineConnection
provides a good default implementation - have a look at it).To define, where the connection should connect visually, you must provide your implementation of
org.eclipse.draw2d.ConnectionAnchor
in thegetSourceConnectionAnchor(...)
andgetTargetConnectionAnchor(...)
methods of your shape edit part.