use of org.graphstream.ui.fx_viewer.FxDefaultView in project gs-ui-javafx by graphstream.
the class TestStars method run.
private void run() {
MultiGraph graph = new MultiGraph("TestSprites");
Viewer viewer = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
ViewerPipe pipeIn = viewer.newViewerPipe();
FxDefaultView view = (FxDefaultView) viewer.addView("view1", new FxGraphRenderer());
DefaultApplication.init(view, graph);
new Thread(() -> Application.launch(DefaultApplication.class)).start();
pipeIn.addAttributeSink(graph);
pipeIn.addViewerListener(this);
pipeIn.pump();
graph.setAttribute("ui.stylesheet", styleSheet);
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.quality");
Node A = graph.addNode("A");
Node B = graph.addNode("B");
Node C = graph.addNode("C");
Node D = graph.addNode("D");
Node E = graph.addNode("E");
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CD", "C", "D");
graph.addEdge("DA", "D", "A");
graph.addEdge("DE", "D", "E");
graph.addEdge("EB", "E", "B");
A.setAttribute("xyz", new double[] { 0, 1, 0 });
B.setAttribute("xyz", new double[] { 1.5, 1, 0 });
C.setAttribute("xyz", new double[] { 1, 0, 0 });
D.setAttribute("xyz", new double[] { 0, 0, 0 });
E.setAttribute("xyz", new double[] { 0.4, 0.6, 0 });
SpriteManager sman = new SpriteManager(graph);
sman.setSpriteFactory(new MySpriteFactory());
MySprite s1 = (MySprite) sman.addSprite("S1");
MySprite s2 = (MySprite) sman.addSprite("S2");
MySprite s3 = (MySprite) sman.addSprite("S3");
s1.attachToEdge("AB");
s2.attachToEdge("CD");
s3.attachToEdge("DA");
while (loop) {
pipeIn.pump();
s1.move();
s2.move();
s3.move();
sleep(10);
}
System.out.println("bye bye");
System.exit(0);
}
Aggregations