如何更改JUNG中边的边标签?

发布于 2024-10-02 06:01:09 字数 176 浏览 4 评论 0原文

我正在使用 JUNG API 进行图形可视化。我不知道如何更改图中边缘的边缘标签。

情况是该图已经在程序中创建了。我不断删除边缘和节点,并且找到了一种方法来对这些内容进行动画处理并在图表中更新它们。一些在线演示很有帮助。但是以后有没有办法改变图中一条边的边标签呢?

我知道 JUNG 要求边缘标签是唯一的。

I'm using the JUNG API for graph visualization. I cannot figure out how to change the edge label of an edge in the graph.

The situation is that the graph has already been created in the program. I keep dropping edges and nodes and I've found a way to animate those things and update them in the graph. Some of the demos online are helpful. But is there no way to change an edge label of an edge in the graph later?

I understand that JUNG requires the edge labels to be unique.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不一样的天空 2024-10-09 06:01:09

JUNG 中边缘标记的基础知识由以下代码片段演示:

            vv.getRenderContext().setEdgeLabelTransformer(new Transformer<MyEdge, String>() {
                public String transform(MyEdge e) {
                    return (e.toString() + " " + e.getWeight() + "/" + e.getCapacity());
                }
            });

这里,vv 是您的 VisualizationViewerMyEdge 是指您的自定义边缘类。就我而言,我定义了函数 getWeight()getCapacity() 来返回边缘的权重和容量。

然后,我为每个边创建了一个弹出菜单,允许用户输入边权重和容量,然后使用 setWeight()setCapacity() 函数来更新我的边。我从 http://www.grotto-networking.com/JUNG 了解了如何准确创建边缘弹出窗口/

您可以借用此示例来设置您自己的边缘标签。

The basics of edge labelling in JUNG are demonstrated by this snippet of code:

            vv.getRenderContext().setEdgeLabelTransformer(new Transformer<MyEdge, String>() {
                public String transform(MyEdge e) {
                    return (e.toString() + " " + e.getWeight() + "/" + e.getCapacity());
                }
            });

Here, vv is your VisualizationViewer and MyEdge refers to your custom edge class. In my case, I've defined the functions getWeight() and getCapacity() to return the weight and capacity of my edge.

Then I created a popup menu for each edge that allows the user to enter the edge weight and capacity and then used the setWeight() and setCapacity() functions to update my edge. I picked up how exactly to create the edge popups from http://www.grotto-networking.com/JUNG/

You could borrow from this example to set your own edge labels.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文