如何在Java中动态绘制(星形)拓扑?

发布于 2024-08-22 11:01:51 字数 757 浏览 7 评论 0原文

我需要在 Java GUI 应用程序中动态绘制(星形)拓扑。通过星形拓扑,我的意思是这样的:

网络拓扑
(来源:thebryantadvantage.com

不需要太花哨,但我不想做得太难看和粗暴。我所说的动态是指拓扑随着时间的推移很少发生变化,但由于节点数量非常少,因此完全重新绘制不会有什么坏处。

我在谷歌上搜索了一段时间,但找不到任何有用的东西——也许我只是在谷歌上搜索了错误的关键词。我也在使用 JFreeChart,但从我所看到的来看,没有包含类似的类。我的一个朋友建议搜索 Java 的思维导图库,但我只能找到完整的应用程序,这有点过分了。

我不敢相信除了形状、线条等之外别无选择?我目前正在使用 JTree,但我不敢相信没有更好的方法可以做到这一点。

附加信息:我有少量(<10)根节点,可能还有少量叶子(<10)。它与 VM<->服务器映射有关,因此叶子将随着时间的推移而更改其父节点。实时迁移时一些“动画”会很酷,但第一步不是必需的。

谢谢,请原谅我错过的任何事情 - 这是我的第一个问题。

I need to dynamically draw (star) topologies in a Java GUI application. By star topology, I mean something like this:

network topology
(source: thebryantadvantage.com)

It doesn't need to be over-fancy, but I don't want to do it too ugly and crude. By dynamically I mean that the topology changes infrequently over time, but as the number of nodes is very small, a complete repaint won't hurt.

I googled around for some time, but I couldn't find anything helpful - maybe I'm just googling the wrong keywords. I'm also using JFreeChart, but from what I can see, there's no class included for something like that. A friend of mine suggested searching for mindmapping libraries for Java, but I can just find complete applications, which is an overkill.

I can't believe there is no alternative to mess around with Shapes, Lines etc.? I'm currently using a JTree, but I can't believe there aren't any better ways to do that.

Additional infos: I have a small number (<10) of root nodes and possibly a small number of leafs (<10). It's about a VM<->Server mapping, so the leafs will change their parent over time. Some "animation" while live migration would be cool, but is not required in the first step.

Thanks, and please excuse anything I missed - this is my first question here.

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

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

发布评论

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

评论(4

深白境迁sunset 2024-08-29 11:01:52

也许 GraphViz 适合您?

编辑:

好的,JGraphT 怎么样?

Perhaps GraphViz would work for you?

EDIT:

OK, what about JGraphT

和影子一齐双人舞 2024-08-29 11:01:52

我相信 JDK 中的演示之一是动态图形布局(不是 100% 确定,我已经运行它们很多年了)。您可能不需要它的精彩动画,但我敢打赌代码相当小并且绝对是独立的。

也许您可以对其进行调整,以便查找布局所采取的步骤不再是动画的;它只显示最终状态。

I believe that one of the demos in the JDK is a dynamic graph layout (not 100% sure, it's been years since I've run them). You probably wouldn't need its whiz-bang animation, but I bet the code is fairly small and definitely self-contained.

Perhaps you could adapt it so that the steps it takes toward finding a layout aren't animated; it just displays the final state.

荒人说梦 2024-08-29 11:01:52

这是 StarLayout 的一个很好的实现。

Here's a nice implementation of a StarLayout.

随心而道 2024-08-29 11:01:52

NetBeans 提供了一个很好的图形库(可视化库)。例如 maven 插件使用它来绘制所有依赖项

NetBeans offers a nice graphical library (visual library). E.g. the maven plugin uses this to draw all the dependencies

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