改变 Jung 中边缘的形状和位置
我需要以特定方式排列节点。我尝试过静态布局。我可以更改节点的位置,但无法将边缘放置在特定位置。静态布局有一个 setLocation 方法,我用它来更改节点的位置,但对于边缘,我不知道如何将它们放置在特定位置,以便新定位的节点与边缘连接。
另一个问题:如何通过覆盖变换方法来改变 Jung 中边缘的形状。
I need to arrange the nodes in a particular way. I have tried with static layout. I can change the position of the nodes but fails to place the edges in specific locations. The static layout has a setLocation method that I used to change the position of the node but for edges, I have no idea about how to place them in specific locations so that newly positioned nodes are connected with edges.
Another question: How can I change the shape of an edge in Jung by overriding the transform method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JUNG 此时并未为边缘放置提供良好的支持。
EdgeShape
< /a>,特别是EdgeShape.Orthogonal
,将向您显示存在哪些内置支持。JUNG does not provide good support, at this time, for edge placement.
EdgeShape
, and in particularEdgeShape.Orthogonal
, will show you what built-in support exists.我知道这个线程有点旧,但我认为它需要恢复 - 希望这个问题还没有得到解答。原因是O'Madadhins先生的回答对我没有帮助。 (也许是因为我的缺乏和理解文件的意愿)
在对 JUNG 技术进行一些研究之后,我很高兴现在能得到一些合格的评论。
有两种(看似)简单的方法可以在静态布局中转换边缘。
第一种方法是覆盖 Transformer 的“transform”方法,直接影响边缘形状:(
如果使用“Graph”图形)
关于感知边缘确实有 - 即连接 - 一个简单的例子是返回一个单独的 Line2D(将由受影响的顶点所具有的中心点组成)到渲染器。
方法调用显然是:
但是:这不起作用。 (也许是因为我做错了;缺乏教程可以作为借口)
无论尝试如何使“变换”方法返回,渲染器都只会得到空值。
第二种可能性是将顶点变换分成两个变压器。第一个变换器将仅使用以下方法设置基本顶点位置:
第二个变换器是可选的。它可用于更改顶点大小或任何人们想要的形状。将需要位置变换顶点的位置,因为该变换器将覆盖位置集。
现在可以实例化布局了。它不会以默认方式使用 Graph 作为单个参数来构造,而是使用附加参数:vertexPositionTransformer。这看起来像:
在布局构造上变换边将自动将边端点设置为每个包含的顶点的中心。
在代码示例中,我放弃了“转换”方法的内容,这当然会因目的而异。使用“Transformer”类/对象必须在将顶点和边添加到受其影响的图中之后完成。就是这样。
请纠正不良风格等问题。
我很高兴收到反馈。
问候
卢卡斯·科希内
I know that this thread is a bit old but I think it needs to be revived - hoping this question hasn't been answered already. The reason is that Mr. O'Madadhains' answer couldn't help me. (maybe because of my deficit and will of understanding documentations)
After some work on JUNG techniques I'd be happy to get some qualified comment now.
There are two (seeming to be) simple ways to transform edges in a static layout.
The first way is to override the "transform" method of the Transformer directly affecting the edge shape:
(if there is used a "Graph" graph)
Concerning the sense edges do have - which is to connect - a simple example would be returning an individual Line2D (which will consist of the center points the affected vertices do have) to the renderer.
The method call obviously is:
BUT: this just doesn't work. (maybe because I did it wrong; the lack of tutorials excuses that)
Whatever one will try to make the "transform" method return, the renderer will just get null-values.
The 2nd possibility is to split the vertex transformation into two transformers. The first transformer will set only the basic vertex position by using:
The 2nd one is optional. It may be used to change the vertex size or whatever one want the shape to look like. There will be needed the positions of the location transformed vertices, because this transformer would override the position set.
Now the layout can be instanciated. It will not be constructed the default way with the Graph as single parameter but with an additional one: the vertexPositionTransformer. That will look like:
Transforming the edges on layout construction will automatically set the edge endpoints to the center of each included vertex.
In the code examples I waived the content of the "transform" methods which of course would differ from purpose to purpose. Using the "Transformer" classes/objects has to be done after adding the vertices and edges to the graph that shall be affected by them. That's it.
Please correct bad style and such issues.
I am glad getting feedback.
Greetings
Lukas Koschine