java - 具有输入和输出端口的 GraphStream 节点

标签 java graph rendering graphviz graphstream

我想在 GraphStream 中对图形进行建模并使用其查看器进行渲染,但我的节点需要具有不同的输入和输出端口(最好在左侧和右侧)分别是节点盒的),并且边应该与这些端口而不是节点中心连接。

这在GraphStream中可能吗?如果没有的话,还有其他的Java库可以使用吗?我知道 GraphViz Dot 允许这样做,但我不想通过命令行调用它,因为这会引入不属于我的项目的外部依赖项。

编辑:我想要渲染的示例(但对于一个非常不同的域):enter image description here

我非常愿意自己进行渲染,但当然我仍然需要节点和边的路由和坐标。

最佳答案

GraphStream 中还没有办法在节点上声明 anchor 、句柄或端口。

但是,由于您希望节点的左侧和右侧的边缘收紧,那么您可能需要尝试一下“freeplan”CSS 属性。请参阅下面的示例,尤其是图表上的“stylesheet”属性:

Graph graph = new SingleGraph("FreePlane");
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
graph.display();
graph.setAttribute("stylesheet", "node { "
        + "     shape: rounded-box; "
        + "     padding: 5px; "
        + "     fill-color: white; "
        + "     stroke-mode: plain; "
        + "     size-mode: fit; "
        + "} "
        + "edge { "
        + "     shape: freeplane; "
        + "}");
graph.addAttribute("ui.quality");
graph.addAttribute("ui.antialias");

Node a = graph.addNode("A");
Node b = graph.addNode("B");
graph.addEdge("AB", "A", "B");
Node c = graph.addNode("C");
graph.addEdge("BC", "B", "C"); 

a.addAttribute("ui.label", "node A");
b.addAttribute("ui.label", "node B");
c.addAttribute("ui.label", "node C");

这会给你类似的东西: screeshot of the window generetaed by this code

关于java - 具有输入和输出端口的 GraphStream 节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29367092/

相关文章:

Python:跟随 "path"的元组?

html - `window.matchMedia` 是否触发回流?

java - 如何连接三张 table ?

java - 将一组文本按钮添加到网格布局

java - New Relic 监控 Websockets 应用程序详细信息

algorithm - 图中循环中边的最大权重

graph - 查找大型示例图

java - 如何清理 ZK 上的网格

ios - 在 iOS 中使用 Metal 渲染时每帧更新索引缓冲区

java - GWT:如何滚动到页面底部?