- From: Yoann Pigné <yoann.pigne AT gmail.com>
- To: graphstream-users AT litislab.fr, robinson.ged+graphstream AT gmail.com
- Subject: Re: Accessing the event when using nextEvents
- Date: Mon, 31 Mar 2014 10:48:45 +0200
Hi,
You need a "sink" to receive events coming from the FileSource object. Create
one with a new class that implements the Sink interface
(org.graphstream.stream.Sink) or by extending the more convenient SinkAdapter
class (org.graphstream.stream.SinkAdapter). 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 :
@Override
public void nodeAdded(String sourceId, long timeId, String nodeId) {
// do something here as a "node add" event was just received
}
};
myFileSource.addSink(mySink);
myFileSource.begin("myFile.dgs");
while(myFileSource.nextEvents()){
// do whatever
}
```
++
Yoann
On Mar 31, 2014, at 7:18 AM,
<robinson.ged+graphstream AT gmail.com>
<robinson.ged+graphstream AT gmail.com>
wrote:
>
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.