如何在JUNG中获取顶点坐标?
在 Jung 中使用 EditingModalGraphMouse 时有没有办法获取顶点坐标? 我已经用坐标设置器和获取器为顶点创建了一个类,但我不知道如何使用其特定坐标设置顶点? (我使用了变压器:Transformer)
Is there a way to get the vertex coordinate when using the EditingModalGraphMouse in Jung ??
I've made a class for the vertex with the coordinate setter and getter but i don't kown how to set the vertex with its specific coordinate ?
(i've user a transformer : Transformer)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面为您提供了如何获取 Jung VisualizationViewer 实例上的笛卡尔坐标的想法...
创建一个内部类,如下所示:
将插件添加到您的 GraphMouse 实例:
已编辑:
接下来的修改将为您提供考虑到荣格图形布局上所做的平移的笛卡尔坐标:
它仍然不完美,因为它省略了比例因子,但您会明白......
您需要从屏幕坐标系计算到视图坐标系统到模型坐标系,得到模型的坐标。
上述代码中的泛型类型应该更改为您自己的版本:)
已编辑
哈哈,线索已经在那里,而且是正确的方法...无需计算!
http://sourceforge.net/projects/jung/forums /forum/252062/topic/3040266?message=6522779
The following gives you an idea on how to obtain the Cartesian coordinates on a Jung VisualizationViewer instance...
Create an inner class as follows:
Add the plugin to your GraphMouse instance:
Edited:
Next modification will give you the Cartesian coordinates that take into account the translation made upon a Jung graph layout:
It is still not perfect since it omits the scale factor, but you will get the idea...
You need to calculate from the screen coordinate system to the view coordinate system to the model coordinate system to get the model's coordinates.
The generic types in the above codes should be changed to your own version :)
Edited
Haha, the clue is already there and it is the correct way...no need to calculate!
http://sourceforge.net/projects/jung/forums/forum/252062/topic/3040266?message=6522779