我正在调查 GraphStream 在 Android 上的使用
api 'com.github.graphstream:gs-ui-android:2.0-alpha'
api 'com.github.graphstream:gs-core:2.0-alpha'
我已经成功地构建并显示了我的图表,
但是我看不到如何在我的图表中的节点上监听用户交互。
我需要在用户点击任何节点时显示一个Dialog,并显示具体的节点信息。
我已经尝试在 org.graphstream.ui.android_viewer.AndroidViewer
上设置一个监听器,但是我从未收到任何回调
我可以在屏幕上拖动显示的节点,这样我就知道有默认的监听器,但是如何添加我自己的监听器呢?
最佳答案
您可以像这样使用 ViewerPipe 实现 ViewerListener:
ViewerPipe pipe = fragment.getViewer().newViewerPipe();
pipe.addAttributeSink( graph );
pipe.addViewerListener( this ); // this or any class which implements ViewerListener
pipe.pump();
在这里了解 ViewerPipe 的工作原理:http://graphstream-project.org/doc/Tutorials/Graph-Visualisation/
关于android - 如何检测用户与图形流的交互?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49943538/