GraphStream 中还没有办法在节点上声明锚点、句柄或端口。
但是,由于您希望边缘在节点的左侧和右侧收紧,那么您可能需要尝试“freeplan”CSS 属性。请参见下面的示例,尤其是图表上的“样式表”属性:
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");
那会给你类似的东西: