GraphStream Users

Archives de la liste Aide


Re: null pointer at source.addSink(graph);


Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT gmail.com>
  • To: graphstream-users AT litislab.fr, bgsrvey AT wordgraph.com
  • Subject: Re: null pointer at source.addSink(graph);
  • Date: Wed, 4 Jul 2012 22:22:55 +0200

Hi and welcome to GraphStream community.

Can you give me more informations :
- the stack trace of the exception
- the version of your GraphStream jar
- your java version and OS

I try your code and got no exception.

Regards.
Guilhelm

2012/7/4 <bgsrvey AT wordgraph.com>

First try with GraphStream.  I can't get over the hump of (FileSource) source
being null.

I will be grateful for any assistance.  gs looks like a great accomplishment!


public class Tutorial2 {
        public static void main(String args[]) {
                Graph graph = new SingleGraph("Tutorial2");
                String filePath = "tutorial2.dgs";
                System.out.println("ID:" + graph.getId());
                graph.display();

                graph.addAttribute("ui.antialias");
                try {
                        Thread.sleep(1000);
                        FileInputStream fstream = new
FileInputStream(filePath);
                        DataInputStream in = new DataInputStream(fstream);
                        BufferedReader br = new BufferedReader(new
InputStreamReader(in));
                        String strLine;
                        while ((strLine = br.readLine()) != null) {
                                System.out.println(strLine);
                        }
                        fstream.close();
                        FileSource source =
FileSourceFactory.sourceFor(filePath);
                        Thread.sleep(5000);
                        source.addSink(graph);
                        source.begin(filePath);
                        while (source.nextEvents());
                        source.end();
                } catch (InterruptedException ix) {
                        System.out.println("interrupted while waiting on
invokeAndWait()");
                } catch (IOException ioe) {
                        System.out.println("IOE");
                        ioe.printStackTrace();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}



--
Guilhelm Savin
PhD Student of Computer Science




Archives gérées par MHonArc 2.6.16.

Top of page