GraphStream Users

Archives de la liste Aide

Re: Mouse events in graphstream

Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT>
  • To: graphstream-users AT
  • Subject: Re: Mouse events in graphstream
  • Date: Fri, 16 Sep 2011 09:50:05 +0200

Hi Stephen and welcome,

Viewer is composed of View and these views are JPanel,
so you can use classic method of swing with them !

Here is an example to add a MouseListener to a View :


import org.graphstream.ui.swingViewer.View;
import org.graphstream.ui.swingViewer.Viewer;

Graph g = ...;


Viewer v  = new Viewer(g, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
View   vi = v.addDefaultView(true);
vi.addMouseListener(new MyMouseListener());


Hope this helps.


2011/9/16 Stephen Ficklin <spficklin AT>

I'm trying to use graphstream to visualize a large network.  I can successfully read in the network, display it and zoom in and out using the wheel on my mouse.  To zoom I use the java.awt.event.MouseWheelListener class.  I'd like to allow panning side to side or up and down by clicking and holding the mouse button and dragging, but I can't seem to make this work.  Is there a way in graphstream to capture mouse events in the view?  I see that I can do this using the ViewerListener, but the buttonPushed or buttonReleased only works when  I click a node in the graph.  I'd like panning to work regardless of where the user clicks in the view.


Guilhelm Savin
PhD Student of Computer Science

Archives gérées par MHonArc 2.6.16.

Top of page