Search in sources :

Example 1 with ViewerPipe

use of org.graphstream.ui.view.ViewerPipe 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 2 with ViewerPipe

use of org.graphstream.ui.view.ViewerPipe in project gs-ui-javafx by graphstream.

the class TestFreePlane method run.

private void run(String[] args) {
    MultiGraph graph = new MultiGraph("g1");
    FxViewer 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 root = graph.addNode("root");
    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");
    Node F = graph.addNode("F");
    Node G = graph.addNode("G");
    Node H = graph.addNode("H");
    graph.addEdge("rA", "root", "A");
    graph.addEdge("rB", "root", "B");
    graph.addEdge("rC", "root", "C");
    graph.addEdge("rD", "root", "D");
    graph.addEdge("rE", "root", "E");
    graph.addEdge("AF", "A", "F");
    graph.addEdge("CG", "C", "G");
    graph.addEdge("DH", "D", "H");
    root.setAttribute("xyz", new double[] { 0, 0, 0 });
    A.setAttribute("xyz", new double[] { 1, 1, 0 });
    B.setAttribute("xyz", new double[] { 1, 0, 0 });
    C.setAttribute("xyz", new double[] { -1, 1, 0 });
    D.setAttribute("xyz", new double[] { -1, 0, 0 });
    E.setAttribute("xyz", new double[] { -1, -1, 0 });
    F.setAttribute("xyz", new double[] { 2, 1.2, 0 });
    G.setAttribute("xyz", new double[] { -2, 1.2, 0 });
    H.setAttribute("xyz", new double[] { -2, -.5, 0 });
    root.setAttribute("label", "Idea");
    A.setAttribute("label", "Topic1");
    B.setAttribute("label", "Topic2");
    C.setAttribute("label", "Topic3");
    D.setAttribute("label", "Topic4");
    E.setAttribute("label", "Topic5");
    F.setAttribute("label", "SubTopic1");
    G.setAttribute("label", "SubTopic2");
    H.setAttribute("label", "Very Long Sub Topic ...");
    while (loop) {
        pipeIn.pump();
        sleep(10);
    }
    System.out.println("bye bye");
    System.exit(0);
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) FxGraphRenderer(org.graphstream.ui.javafx.FxGraphRenderer) Node(org.graphstream.graph.Node) FxDefaultView(org.graphstream.ui.fx_viewer.FxDefaultView) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Example 3 with ViewerPipe

use of org.graphstream.ui.view.ViewerPipe in project gs-ui-javafx by graphstream.

the class BTest method run.

public void run() {
    try {
        MultiGraph graph = new MultiGraph("TestSize");
        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");
        Node F = graph.addNode("F");
        Edge AB = graph.addEdge("AB", "A", "B", true);
        Edge BC = graph.addEdge("BC", "B", "C", true);
        Edge CD = graph.addEdge("CD", "C", "D", true);
        Edge DA = graph.addEdge("DA", "D", "A", true);
        Edge BB = graph.addEdge("BB", "B", "B", true);
        Edge DE = graph.addEdge("DE", "D", "E", true);
        Edge DF = graph.addEdge("DF", "D", "F", true);
        Edge CF = graph.addEdge("CF", "C", "F", true);
        A.setAttribute("xyz", new double[] { 0, 1, 0 });
        B.setAttribute("xyz", new double[] { 1, 0.8, 0 });
        C.setAttribute("xyz", new double[] { 0.8, 0, 0 });
        D.setAttribute("xyz", new double[] { 0, 0, 0 });
        E.setAttribute("xyz", new double[] { 0.5, 0.5, 0 });
        F.setAttribute("xyz", new double[] { 0.5, 0.25, 0 });
        A.setAttribute("label", "A");
        B.setAttribute("label", "Long label ...");
        C.setAttribute("label", "C");
        D.setAttribute("label", "A long label ...");
        E.setAttribute("label", "Another very long label");
        F.setAttribute("label", "F");
        double size = 20f;
        double sizeInc = 1f;
        while (loop) {
            pipeIn.pump();
            sleep(40);
            A.setAttribute("ui.size", size);
            size += sizeInc;
            if (size > 50) {
                sizeInc = -1f;
                size = 50f;
            } else if (size < 20) {
                sizeInc = 1f;
                size = 20f;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println("bye bye");
    System.exit(0);
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) FxGraphRenderer(org.graphstream.ui.javafx.FxGraphRenderer) Node(org.graphstream.graph.Node) FxViewer(org.graphstream.ui.fx_viewer.FxViewer) Viewer(org.graphstream.ui.view.Viewer) FxDefaultView(org.graphstream.ui.fx_viewer.FxDefaultView) Edge(org.graphstream.graph.Edge) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Example 4 with ViewerPipe

use of org.graphstream.ui.view.ViewerPipe in project gs-ui-javafx by graphstream.

the class DemoViewerFxEdgeSelection method main.

public static void main(String[] args) {
    System.setProperty("org.graphstream.ui", "org.graphstream.ui.javafx.util.Display");
    Graph graph = new MultiGraph("main graph");
    viewPanel = (FxViewPanel) graph.display(true).getDefaultView();
    FxViewer view = (FxViewer) viewPanel.getViewer();
    view.getDefaultView().setMouseManager(new FxMouseManager(EnumSet.of(InteractiveElement.EDGE, InteractiveElement.NODE, InteractiveElement.SPRITE)));
    ViewerPipe pipe = view.newViewerPipe();
    // graph.setAttribute( "ui.quality" );
    graph.setAttribute("ui.antialias");
    pipe.addViewerListener(new DemoViewerFxEdgeSelection());
    for (String nodeId : new String[] { "A", "B", "C" }) {
        Node node = graph.addNode(nodeId);
        node.setAttribute("ui.label", nodeId);
    }
    graph.addEdge("AB", "A", "B", true);
    graph.addEdge("BC", "B", "C", true);
    graph.addEdge("CA", "C", "A", true);
    graph.setAttribute("ui.stylesheet", styleSheet);
    float color = 0;
    float dir = 0.01f;
    while (loop) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        pipe.pump();
        color += dir;
        if (color > 1) {
            color = 1;
            dir = -dir;
        } else if (color < 0) {
            color = 0;
            dir = -dir;
        }
        showSelection(graph);
    }
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) Graph(org.graphstream.graph.Graph) MultiGraph(org.graphstream.graph.implementations.MultiGraph) FxMouseManager(org.graphstream.ui.fx_viewer.util.FxMouseManager) Node(org.graphstream.graph.Node) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Example 5 with ViewerPipe

use of org.graphstream.ui.view.ViewerPipe in project gs-ui-javafx by graphstream.

the class TestIcons method run.

private void run(String[] args) {
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_1.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_2.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_3.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_4.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_5.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_6.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_7.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_8.png").toString());
    iconAnim.add(ImageCache.class.getClassLoader().getResource("org/graphstream/ui/viewer_fx/test/data/icon_9.png").toString());
    MultiGraph graph = new MultiGraph("Icons ...");
    FxViewer 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");
    graph.addEdge("AB", "A", "B");
    graph.addEdge("BC", "B", "C");
    graph.addEdge("CD", "C", "D");
    graph.addEdge("DA", "D", "A");
    A.setAttribute("xyz", new double[] { 0.0, 1.0, 0 });
    B.setAttribute("xyz", new double[] { 3.2, 1.5, 0 });
    C.setAttribute("xyz", new double[] { 0.2, 0.0, 0 });
    D.setAttribute("xyz", new double[] { 3.0, -0.5, 0 });
    A.setAttribute("label", "Topic1");
    B.setAttribute("label", "Topic2");
    C.setAttribute("label", "Topic3");
    D.setAttribute("label", "Topic4");
    A.setAttribute("ui.icon", iconAnim.get(0));
    int i = 0;
    while (loop) {
        pipeIn.pump();
        sleep(60);
        if (i >= 9)
            i = 0;
        else if (i < 0)
            i = 8;
        A.setAttribute("ui.icon", iconAnim.get(i));
        if (direction)
            i++;
        else
            i--;
    }
    System.out.println("bye bye");
    System.exit(0);
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) FxGraphRenderer(org.graphstream.ui.javafx.FxGraphRenderer) Node(org.graphstream.graph.Node) ImageCache(org.graphstream.ui.javafx.util.ImageCache) FxDefaultView(org.graphstream.ui.fx_viewer.FxDefaultView) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Aggregations

ViewerPipe (org.graphstream.ui.view.ViewerPipe)11 MultiGraph (org.graphstream.graph.implementations.MultiGraph)10 Node (org.graphstream.graph.Node)9 FxViewer (org.graphstream.ui.fx_viewer.FxViewer)9 FxDefaultView (org.graphstream.ui.fx_viewer.FxDefaultView)8 FxGraphRenderer (org.graphstream.ui.javafx.FxGraphRenderer)8 Viewer (org.graphstream.ui.view.Viewer)8 Edge (org.graphstream.graph.Edge)3 SpriteManager (org.graphstream.ui.spriteManager.SpriteManager)3 Scene (javafx.scene.Scene)2 WindowEvent (javafx.stage.WindowEvent)2 DorogovtsevMendesGenerator (org.graphstream.algorithm.generator.DorogovtsevMendesGenerator)2 Graph (org.graphstream.graph.Graph)2 Point3 (org.graphstream.ui.geom.Point3)2 Random (java.util.Random)1 IdAlreadyInUseException (org.graphstream.graph.IdAlreadyInUseException)1 SingleGraph (org.graphstream.graph.implementations.SingleGraph)1 FxMouseManager (org.graphstream.ui.fx_viewer.util.FxMouseManager)1 ImageCache (org.graphstream.ui.javafx.util.ImageCache)1 Sprite (org.graphstream.ui.spriteManager.Sprite)1