具有输入和输出端口的 GraphStream 节点
GraphStream nodes with input and output ports
我想在 GraphStream 中对图形建模并使用其查看器呈现它,但我的节点需要具有不同的输入和输出端口(最好在左侧和节点框的右侧),边应该连接到这些端口而不是节点中心。
在 GraphStream 中甚至可能吗?如果没有,是否可以使用另一个 Java 库?我知道 GraphViz Dot 允许这样做,但我不想通过命令行调用它,因为它引入了不属于我的项目的外部依赖项。
编辑:我想要渲染的那种东西的例子(但对于一个非常不同的域):
我完全愿意自己做渲染,但当然我仍然需要节点和边的路由和坐标。
GraphStream 中还没有办法在节点上声明锚点、句柄或端口。
但是,由于您希望在节点的左侧和右侧收紧边缘,因此您可能想尝试一下 "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");
那会给你类似的东西:
我无法使用 graphstream 实现此功能,但其他框架支持此类功能,例如:
我想在 GraphStream 中对图形建模并使用其查看器呈现它,但我的节点需要具有不同的输入和输出端口(最好在左侧和节点框的右侧),边应该连接到这些端口而不是节点中心。
在 GraphStream 中甚至可能吗?如果没有,是否可以使用另一个 Java 库?我知道 GraphViz Dot 允许这样做,但我不想通过命令行调用它,因为它引入了不属于我的项目的外部依赖项。
编辑:我想要渲染的那种东西的例子(但对于一个非常不同的域):
我完全愿意自己做渲染,但当然我仍然需要节点和边的路由和坐标。
GraphStream 中还没有办法在节点上声明锚点、句柄或端口。
但是,由于您希望在节点的左侧和右侧收紧边缘,因此您可能想尝试一下 "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");
那会给你类似的东西:
我无法使用 graphstream 实现此功能,但其他框架支持此类功能,例如: