public DemoLayoutAndViewer() {
boolean loop = true;
Graph graph = new MultiGraph("test");
Viewer viewer = new Viewer(new ThreadProxyPipe(graph));
ProxyPipe fromViewer = viewer.newThreadProxyOnGraphicGraph();
LinLog layout = new LinLog(false);
layout.configure(a, r, true, force);
graph.addAttribute("ui.antialias");
graph.addAttribute("ui.stylesheet", styleSheet);
fromViewer.addSink(graph);
viewer.addDefaultView(true);
graph.addSink(layout);
layout.addAttributeSink(graph);
FileSource dgs = GRAPH.endsWith(".gml") ? new FileSourceGML() : new FileSourceDGS();
dgs.addSink(graph);
try {
dgs.begin(getClass().getResourceAsStream(GRAPH));
for (int i = 0; i < 5000 && dgs.nextEvents(); i++) {
// fromViewer.pump();
// layout.compute();
// sleep(100);
}
dgs.end();
} catch (IOException e1) {
e1.printStackTrace();
System.exit(1);
}
System.out.println("Finished creating the graph.");
while (loop) {
fromViewer.pump();
if (graph.hasAttribute("ui.viewClosed")) {
loop = false;
} else {
//sleep(1000);
layout.compute();
findCommunities(graph, 1.3);
}
}
System.exit(0);