GraphStream Users

Archives de la liste Aide

Re: Accessing the event when using nextEvents

Chronologique Discussions 
  • From: Yoann Pigné <yoann.pigne AT>
  • To: graphstream-users AT, robinson.ged+graphstream AT
  • Subject: Re: Accessing the event when using nextEvents
  • Date: Mon, 31 Mar 2014 10:48:45 +0200


You need a "sink" to receive events coming from the FileSource object. Create
one with a new class that implements the Sink interface
( or by extending the more convenient SinkAdapter
class ( It all depends on which events
you want to catch.

Once this sink is created you only need to register it against the filesink
object with "addSink()". Then your sink object gets called with appropriate
methods when events are fired.

One quick and dirty example with an anonymous class :

FileSource myFileSource = FileSourceFactory.sourceFor("myFile.dgs");

Sink mySink = new SinkAdapter(){

// Override any of the event methods of the Sink interface.
// nodeAdded for instance :
public void nodeAdded(String sourceId, long timeId, String nodeId) {
// do something here as a "node add" event was just received



// do whatever


On Mar 31, 2014, at 7:18 AM,
<robinson.ged+graphstream AT>

<robinson.ged+graphstream AT>

> First, thanks for GraphStream. It's a great library. just what I
> was looking
> for.
> I am reading a DGS file with a FileSource object and the nextEvents()
> method.
> It works just fine and the graph is produced and rendered.
> However after each nextEvents() method call I wouldl ike to get access to
> the
> event which has just been processed. I want to produce some output in a
> LayerRenderer which is based on the most recent event to occur.
> How can I get access in my own code to the graph events as they are
> processed
> by nextEvents() ?
> Thanks & Regards,
> Ged Robinson

Archives gérées par MHonArc 2.6.16.

Top of page