1

I am investigating the use of GraphStream on Android using

api 'com.github.graphstream:gs-ui-android:2.0-alpha'
api 'com.github.graphstream:gs-core:2.0-alpha'

I have managed to construct and display my Graph fine,

However I cannot see how to listen for user interactions on the nodes within my graph.

I need to display a Dialog when any node is clicked on by the user and display the specific nodes information.

I've tried setting a Listener on the org.graphstream.ui.android_viewer.AndroidViewer, however I never received any callbacks

I can drag the displayed nodes around the screen so I know there are default listeners, how to I add my own listeners though?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Hector
  • 4,016
  • 21
  • 112
  • 211

1 Answers1

2

You can implement ViewerListener with the ViewerPipe like this :

ViewerPipe pipe = fragment.getViewer().newViewerPipe();

pipe.addAttributeSink( graph );
pipe.addViewerListener( this ); // this or any class which implements ViewerListener
pipe.pump();

You can get an exemple here : https://github.com/graphstream/gs-ui-android-test/blob/master/app/src/main/java/ui/graphstream/org/gs_ui_androidtestFull/Activity_TestArrows.java

And here to understand how ViewerPipe works : http://graphstream-project.org/doc/Tutorials/Graph-Visualisation/

H.Brahimi
  • 254
  • 1
  • 7