我正在使用我正在编写的用于创建抽象语法树可视化的小型编译器来玩 graphstream,如下所示:
// ASTNode is the root to to the AST tree. Given that node, this just displays
// the AST on-screen.
public static void visualize(ASTNode ast) throws IOException, URISyntaxException {
Path file = Path.of(VisualizeAbstractSyntaxTree.class.getResource("graph.css").toURI());
String css = Files.readString(file);
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
Graph graph = new SingleGraph("AST");
graph.addAttribute("ui.stylesheet", css);
construct(ast, "0", graph); // construct the tree from the AST root node.
Viewer viewer = graph.display();
}
运行程序显示了自动定位的魔力。但是,当一个节点被鼠标拖动时,其他节点保持静止。如果用鼠标拖动节点,是否有一种简单的方法可以让其他节点做出反应(也被拉动)?
这必须得到支持,但我似乎找不到任何示例或 API 参考?