use of org.graphstream.ui.fx_viewer.FxViewPanel in project gs-ui-javafx by graphstream.
the class AllFxTest method start.
public void start(Stage primaryStage) throws Exception {
MultiGraph g = new MultiGraph("mg");
FxViewer v = new FxViewer(g, FxViewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
g.setAttribute("ui.antialias");
g.setAttribute("ui.quality");
g.setAttribute("ui.stylesheet", styleSheet);
v.enableAutoLayout();
FxViewPanel panel = (FxViewPanel) v.addDefaultView(false, new FxGraphRenderer());
gen.addSink(g);
gen.begin();
for (int i = 0; i < 100; i++) gen.nextEvents();
gen.end();
gen.removeSink(g);
Scene scene = new Scene(panel, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
use of org.graphstream.ui.fx_viewer.FxViewPanel in project gs-ui-javafx by graphstream.
the class DemoAllInFx method start.
@Override
public void start(Stage primaryStage) throws Exception {
Graph graph = new MultiGraph("mg");
FxViewer viewer = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
graph.addNode("A");
graph.addNode("B");
graph.addNode("C");
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.quality");
graph.setAttribute("ui.stylesheet", styleSheet);
graph.getNode("A").setAttribute("xyz", -1, 0, 0);
graph.getNode("B").setAttribute("xyz", 1, 0, 0);
graph.getNode("C").setAttribute("xyz", 0, 1, 0);
// On ins�re la vue principale du viewer dans la JFrame.
FxViewPanel v = (FxViewPanel) viewer.addDefaultView(false);
Scene scene = new Scene(v, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
use of org.graphstream.ui.fx_viewer.FxViewPanel 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