use of org.graphstream.stream.thread.ThreadProxyPipe in project gs-ui-javafx by graphstream.
the class TestTwoViewersInOneFrame method start.
public void start(Stage primaryStage) throws Exception {
MultiGraph graph1 = new MultiGraph("g1");
MultiGraph graph2 = new MultiGraph("g2");
ThreadProxyPipe pipe1 = new ThreadProxyPipe();
pipe1.init(graph1);
ThreadProxyPipe pipe2 = new ThreadProxyPipe();
pipe2.init(graph2);
Viewer viewer1 = new FxViewer(pipe1);
Viewer viewer2 = new FxViewer(pipe2);
graph1.setAttribute("ui.quality");
graph2.setAttribute("ui.quality");
graph1.setAttribute("ui.antialias");
graph2.setAttribute("ui.antialias");
graph1.setAttribute("ui.stylesheet", styleSheet1);
graph2.setAttribute("ui.stylesheet", styleSheet2);
FxDefaultView view1 = new FxDefaultView(viewer1, "view1", new FxGraphRenderer());
FxDefaultView view2 = new FxDefaultView(viewer2, "view2", new FxGraphRenderer());
viewer1.addView(view1);
viewer2.addView(view2);
viewer1.enableAutoLayout();
viewer2.enableAutoLayout();
DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
gen.addSink(graph1);
gen.addSink(graph2);
gen.begin();
for (int i = 0; i < 100; i++) gen.nextEvents();
gen.end();
gen.removeSink(graph1);
gen.removeSink(graph2);
StackPane paneView1 = new StackPane();
// prevent UI shift issues
paneView1.getChildren().addAll(view1);
StackPane paneView2 = new StackPane();
// prevent UI shift issues
paneView2.getChildren().addAll(view2);
GridPane gridpane = new GridPane();
gridpane.add(paneView1, 1, 0);
gridpane.add(paneView2, 2, 0);
Scene scene = new Scene(gridpane, 800, 600, true, SceneAntialiasing.BALANCED);
primaryStage.setScene(scene);
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
primaryStage.show();
}
use of org.graphstream.stream.thread.ThreadProxyPipe in project gs-ui-javafx by graphstream.
the class DemoTwoGraphsInOneViewerFx method start.
@Override
public void start(Stage primaryStage) throws Exception {
Graph graph1 = new MultiGraph("g1");
Graph graph2 = new MultiGraph("g2");
FxViewer viewer1 = new FxViewer(new ThreadProxyPipe(graph1));
FxViewer viewer2 = new FxViewer(new ThreadProxyPipe(graph2));
graph1.setAttribute("ui.stylesheet", styleSheet1);
graph2.setAttribute("ui.stylesheet", styleSheet2);
// View view1 =
FxViewPanel view1 = (FxViewPanel) viewer1.addDefaultView(true);
FxViewPanel view2 = (FxViewPanel) viewer2.addDefaultView(true);
viewer1.enableAutoLayout();
viewer2.enableAutoLayout();
// view1.setBackLayerRenderer(view2);
FileSourceDGS dgs = new FileSourceDGS();
dgs.addSink(graph1);
try {
dgs.begin(getClass().getResourceAsStream(GRAPH));
for (int i = 0; i < 100 && dgs.nextEvents(); i++) ;
dgs.end();
} catch (IOException e1) {
e1.printStackTrace();
System.exit(1);
}
dgs.removeSink(graph1);
dgs.addSink(graph2);
try {
dgs.begin(getClass().getResourceAsStream(GRAPH));
for (int i = 0; i < 100 && dgs.nextEvents(); i++) ;
dgs.end();
} catch (IOException e1) {
e1.printStackTrace();
System.exit(1);
}
dgs.removeSink(graph2);
primaryStage.setScene(new Scene(view1));
primaryStage.show();
Stage secondStage = new Stage();
secondStage.setScene(new Scene(view2));
secondStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
secondStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent t) {
Platform.exit();
System.exit(0);
}
});
}
Aggregations