gpt4 book ai didi

graph - 在 Graphstream 中检索鼠标点击

转载 作者:行者123 更新时间:2023-11-30 09:22:01 38 4
gpt4 key购买 nike

因为我找不到任何特定的地方来讨论这个,我想我会在这里发帖......我正在使用 graphstream 1.1 ( http://graphstream-project.org/ ),一个用于 java 的图形可视化库,来开发数据可视化工具。我需要检索节点上的鼠标点击以显示相关数据,但在按照库教程进行操作后,我仍然不清楚如何执行此操作。有没有人使用过这个可以帮助我提供更直接的答案?我正在关注的教程位于:

http://graphstream-project.org/doc/Tutorials/Graph-Visualisation_1.0/#retrieving-mouse-clicks-on-the-viewer

public class Clicks implements ViewerListener {
protected boolean loop;

public static void main(String args[]) {
new Clicks();
}
public Clicks() {
// We do as usual to display a graph. This
// connect the graph outputs to the viewer.
// The viewer is a sink of the graph.
Graph graph = new SingleGraph("Clicks");
Viewer viewer = graph.display();

// The default action when closing the view is to quit
// the program.
viewer.setCloseFramePolicy(Viewer.CloseFramePolicy.HIDE_ONLY);

// We connect back the viewer to the graph,
// the graph becomes a sink for the viewer.
// We also install us as a viewer listener to
// intercept the graphic events.
ViewerPipe fromViewer = viewer.newViewerPipe();
fromViewer.addViewerListener(this);
fromViewer.addSink(graph);

// Then we need a loop to wait for events.
// In this loop we will need to call the
// pump() method to copy back events that have
// already occured in the viewer thread inside
// our thread.

while(loop) {
fromViewer.pump();
}
}

viewClosed(String id) {
loop = false;
}

buttonPushed(String id) {
System.out.println("Button pushed on node "+id);
}

buttonReleased(String id) {
System.out.println("Button released on node "+id);
}
}

最佳答案

刚刚解决了!我给他们的邮件组发了一封电子邮件。网站上的教程代码缺少一些信息。这三个功能需要公开无效,并且必须添加其他“导入”:

import org.graphstream.ui.swingViewer.Viewer;
import org.graphstream.ui.swingViewer.ViewerListener;
import org.graphstream.ui.swingViewer.ViewerPipe;

关于graph - 在 Graphstream 中检索鼠标点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16671143/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com