Search in sources :

Example 1 with FxViewPanel

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();
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) FxViewPanel(org.graphstream.ui.fx_viewer.FxViewPanel) FxGraphRenderer(org.graphstream.ui.javafx.FxGraphRenderer) DorogovtsevMendesGenerator(org.graphstream.algorithm.generator.DorogovtsevMendesGenerator) Scene(javafx.scene.Scene) MultiGraph(org.graphstream.graph.implementations.MultiGraph)

Example 2 with FxViewPanel

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();
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) Graph(org.graphstream.graph.Graph) MultiGraph(org.graphstream.graph.implementations.MultiGraph) FxViewPanel(org.graphstream.ui.fx_viewer.FxViewPanel) Scene(javafx.scene.Scene) MultiGraph(org.graphstream.graph.implementations.MultiGraph)

Example 3 with FxViewPanel

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);
        }
    });
}
Also used : ThreadProxyPipe(org.graphstream.stream.thread.ThreadProxyPipe) FileSourceDGS(org.graphstream.stream.file.FileSourceDGS) FxViewPanel(org.graphstream.ui.fx_viewer.FxViewPanel) IOException(java.io.IOException) Scene(javafx.scene.Scene) MultiGraph(org.graphstream.graph.implementations.MultiGraph) FxViewer(org.graphstream.ui.fx_viewer.FxViewer) MultiGraph(org.graphstream.graph.implementations.MultiGraph) Graph(org.graphstream.graph.Graph) WindowEvent(javafx.stage.WindowEvent) Stage(javafx.stage.Stage)

Aggregations

Scene (javafx.scene.Scene)3 MultiGraph (org.graphstream.graph.implementations.MultiGraph)3 FxViewPanel (org.graphstream.ui.fx_viewer.FxViewPanel)3 FxViewer (org.graphstream.ui.fx_viewer.FxViewer)3 Graph (org.graphstream.graph.Graph)2 IOException (java.io.IOException)1 Stage (javafx.stage.Stage)1 WindowEvent (javafx.stage.WindowEvent)1 DorogovtsevMendesGenerator (org.graphstream.algorithm.generator.DorogovtsevMendesGenerator)1 FileSourceDGS (org.graphstream.stream.file.FileSourceDGS)1 ThreadProxyPipe (org.graphstream.stream.thread.ThreadProxyPipe)1 FxGraphRenderer (org.graphstream.ui.javafx.FxGraphRenderer)1