荣格图形每次都能出现在同一个地方吗?
我正在使用 JUNG ( http://jung.sourceforge.net/index.html )在java中绘制图形。这个软件很棒,但我有一个小问题。我如何确保每次显示的图表都是相同的(架构或位置没有变化)?
更具体地说:图形模型(要表示的数据)不会改变,但每次我点击“查看图形”按钮时,它的表示都会改变:) [一些顶点在其他地方,例如:有时在上部窗口的,有时在下部]
谢谢你,
Iulian
I'm using JUNG ( http://jung.sourceforge.net/index.html ) to draw graphics in java. The software is great but I have a small question. How can I be sure that the displayed graph is each time the same (no changes is architecture or position)?
To be more specific: the graph model (data to be represented) doesn't change but its representation changes each time I hit the "View graph" button :) [some vertices are in other places, for example: sometimes in the upper part of the window, sometimes in the lower part ]
Thank you,
Iulian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
StaticLayout 可以让您指定顶点到 Point2D 变压器。这将允许您控制顶点的放置位置并且应该执行您想要执行的操作。您应该使用以下 构造函数:
您需要实现自己的 变压器< /a> 接受一个顶点并返回该顶点应出现的位置。其使用示例:
于 2010 年 2 月 20 日添加:
另一种方法是使用 PersistentLayoutImpl 将顶点的位置保存到文件中。但是,您还需要以某种方式持久化图形以获取其中的顶点和顶点(这需要单独持久化)。 edu.uci.ics.jung.io。这是一个仅使用 PersistentLayoutImpl 的示例:
请注意,该示例尚未保留顶点和边,因为我还没有时间弄清楚如何使用 edu.uci.ics.jung.io 尚未。
A StaticLayout lets you specify a vertex to Point2D transformer. This will allow you to control where the vertices are placed and should do what you want to do. You should use the following constructor:
You'll need to implement your own transformer that takes in a vertex and returns the location where the vertex should appear. An example of its in use:
Added 20 Feb 2010:
An alternative is to use a PersistentLayoutImpl to save the locations of the vertices to a file. However, you need to also somehow persist the graph to get which vertices and vertices were on there (this needs to persisted separately). There are number of classes for persisting the graph in edu.uci.ics.jung.io. This is an example that uses just PersistentLayoutImpl:
Note that the example does not persist the vertices and edges yet, as I haven't had the time to figure out how use the classes in edu.uci.ics.jung.io yet.