Search in sources :

Example 1 with DorogovtsevMendesGenerator

use of org.graphstream.algorithm.generator.DorogovtsevMendesGenerator 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 DorogovtsevMendesGenerator

use of org.graphstream.algorithm.generator.DorogovtsevMendesGenerator in project gs-ui-javafx by graphstream.

the class ATest method run.

public void run(String[] args) {
    Graph graph = new MultiGraph("g1");
    Viewer viewer = graph.display(true);
    ViewerPipe pipeIn = viewer.newViewerPipe();
    DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
    pipeIn.addAttributeSink(graph);
    pipeIn.addViewerListener(this);
    pipeIn.pump();
    graph.setAttribute("ui.default.title", "Layout Test Fx");
    graph.setAttribute("ui.antialias");
    graph.setAttribute("ui.stylesheet", styleSheet);
    gen.addSink(graph);
    gen.setDirectedEdges(true, true);
    gen.begin();
    int i = 0;
    while (i < 100) {
        gen.nextEvents();
        i += 1;
    }
    gen.end();
    graph.forEach(n -> n.setAttribute("ui.label", "truc"));
    while (loop) {
        pipeIn.pump();
        sleep(10);
    }
    System.out.println("bye bye");
    System.exit(0);
}
Also used : Graph(org.graphstream.graph.Graph) MultiGraph(org.graphstream.graph.implementations.MultiGraph) Viewer(org.graphstream.ui.view.Viewer) DorogovtsevMendesGenerator(org.graphstream.algorithm.generator.DorogovtsevMendesGenerator) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Example 3 with DorogovtsevMendesGenerator

use of org.graphstream.algorithm.generator.DorogovtsevMendesGenerator 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();
}
Also used : ThreadProxyPipe(org.graphstream.stream.thread.ThreadProxyPipe) GridPane(javafx.scene.layout.GridPane) FxGraphRenderer(org.graphstream.ui.javafx.FxGraphRenderer) FxViewer(org.graphstream.ui.fx_viewer.FxViewer) Viewer(org.graphstream.ui.view.Viewer) DorogovtsevMendesGenerator(org.graphstream.algorithm.generator.DorogovtsevMendesGenerator) FxDefaultView(org.graphstream.ui.fx_viewer.FxDefaultView) Scene(javafx.scene.Scene) MultiGraph(org.graphstream.graph.implementations.MultiGraph) FxViewer(org.graphstream.ui.fx_viewer.FxViewer) WindowEvent(javafx.stage.WindowEvent) StackPane(javafx.scene.layout.StackPane)

Example 4 with DorogovtsevMendesGenerator

use of org.graphstream.algorithm.generator.DorogovtsevMendesGenerator in project gs-ui-javafx by graphstream.

the class TestRandomWalk method run.

private void run() {
    MultiGraph graph = new MultiGraph("random walk");
    DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
    RandomWalk rwalk = new RandomWalk();
    gen.addSink(graph);
    gen.begin();
    for (int i = 0; i < 400; i++) {
        gen.nextEvents();
    }
    gen.end();
    graph.setAttribute("ui.stylesheet", styleSheet);
    graph.setAttribute("ui.quality");
    graph.setAttribute("ui.antialias");
    graph.display();
    rwalk.setEntityCount(graph.getNodeCount() * 2);
    rwalk.setEvaporation(0.97);
    rwalk.setEntityMemory(40);
    rwalk.init(graph);
    for (int i = 0; i < 3000; i++) {
        rwalk.compute();
        if (i % 100 == 0) {
            System.err.println("step " + i);
            updateGraph(graph, rwalk);
        }
    // Thread.sleep(100)
    }
    rwalk.terminate();
    updateGraph(graph, rwalk);
    graph.setAttribute("ui.screenshot", "randomWalk.png");
}
Also used : DorogovtsevMendesGenerator(org.graphstream.algorithm.generator.DorogovtsevMendesGenerator) RandomWalk(org.graphstream.algorithm.randomWalk.RandomWalk) MultiGraph(org.graphstream.graph.implementations.MultiGraph)

Example 5 with DorogovtsevMendesGenerator

use of org.graphstream.algorithm.generator.DorogovtsevMendesGenerator in project gs-ui-javafx by graphstream.

the class TestSprite method run.

private void run() {
    graph = new MultiGraph("TestSprites");
    Viewer viewer = graph.display(true);
    ViewerPipe pipeIn = viewer.newViewerPipe();
    DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
    pipeIn.addAttributeSink(graph);
    pipeIn.addViewerListener(this);
    pipeIn.pump();
    System.out.println(NODE_COUNT + " nodes, " + SPRITE_COUNT + " sprites%n");
    graph.setAttribute("ui.default.title", "Layout Test");
    graph.setAttribute("ui.antialias");
    graph.setAttribute("ui.stylesheet", styleSheet);
    gen.addSink(graph);
    // gen.setDirectedEdges( true, true )
    gen.begin();
    int i = 0;
    while (i < NODE_COUNT) {
        gen.nextEvents();
        i += 1;
    }
    gen.end();
    sleep(1000);
    addSprites();
    while (loop) {
        pipeIn.pump();
        moveSprites();
        sleep(10);
    }
    System.out.println("bye bye");
    System.exit(0);
}
Also used : Viewer(org.graphstream.ui.view.Viewer) DorogovtsevMendesGenerator(org.graphstream.algorithm.generator.DorogovtsevMendesGenerator) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Aggregations

DorogovtsevMendesGenerator (org.graphstream.algorithm.generator.DorogovtsevMendesGenerator)5 MultiGraph (org.graphstream.graph.implementations.MultiGraph)5 Viewer (org.graphstream.ui.view.Viewer)3 Scene (javafx.scene.Scene)2 FxViewer (org.graphstream.ui.fx_viewer.FxViewer)2 FxGraphRenderer (org.graphstream.ui.javafx.FxGraphRenderer)2 ViewerPipe (org.graphstream.ui.view.ViewerPipe)2 GridPane (javafx.scene.layout.GridPane)1 StackPane (javafx.scene.layout.StackPane)1 WindowEvent (javafx.stage.WindowEvent)1 RandomWalk (org.graphstream.algorithm.randomWalk.RandomWalk)1 Graph (org.graphstream.graph.Graph)1 ThreadProxyPipe (org.graphstream.stream.thread.ThreadProxyPipe)1 FxDefaultView (org.graphstream.ui.fx_viewer.FxDefaultView)1 FxViewPanel (org.graphstream.ui.fx_viewer.FxViewPanel)1