Search in sources :

Example 11 with Node

use of org.graphstream.graph.Node 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)

Example 12 with Node

use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.

the class TestPies method run.

private void run() {
    System.setProperty("org.graphstream.ui", "org.graphstream.ui.javafx.util.Display");
    SingleGraph g = new SingleGraph("test");
    Node A = g.addNode("A");
    Node B = g.addNode("B");
    g.addEdge("AB", "A", "B");
    SpriteManager sm = new SpriteManager(g);
    Sprite pie = sm.addSprite("pie");
    g.setAttribute("ui.antialias");
    pie.setAttribute("ui.style", "shape: pie-chart; fill-color: #F00, #0F0, #00F; size: 30px;");
    // g.addAttribute("ui.stylesheet", "sprite { shape: pie-chart; fill-color: #F00, #0F0, #00F; size: 30px; } node {fill-color: red; }")
    double[] values = new double[3];
    values[0] = 0.3333;
    values[1] = 0.3333;
    values[2] = 0.3333;
    pie.setAttribute("ui.pie-values", values);
    pie.attachToEdge("AB");
    pie.setPosition(0.5);
    g.display();
    double[] values2 = new double[3];
    values2[0] = 0.1;
    values2[1] = 0.3;
    values2[2] = 0.6;
    boolean on = true;
    while (true) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (on) {
            values[0] = 0.1;
            values[1] = 0.3;
            values[2] = 0.6;
            A.setAttribute("ui.pie-values", new double[] { 1.0 });
            A.setAttribute("ui.style", "shape:pie-chart; fill-color:red;");
        } else {
            values[0] = 0.3;
            values[1] = 0.3;
            values[2] = 0.3;
            A.setAttribute("ui.pie-values", new double[] { 1.0 });
            A.setAttribute("ui.style", "shape:pie-chart; fill-color:blue;");
        }
        pie.setAttribute("ui.pie-values", values);
        // pie.addAttribute("ui.pie-values", if(on) values else values2)
        on = !on;
    }
}
Also used : Sprite(org.graphstream.ui.spriteManager.Sprite) Node(org.graphstream.graph.Node) SingleGraph(org.graphstream.graph.implementations.SingleGraph) SpriteManager(org.graphstream.ui.spriteManager.SpriteManager)

Example 13 with Node

use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.

the class TestPolys method run.

private void run() {
    System.setProperty("org.graphstream.ui", "org.graphstream.ui.javafx.util.Display");
    SingleGraph g = new SingleGraph("Polys");
    Node A = g.addNode("A");
    Node B = g.addNode("B");
    Node C = g.addNode("C");
    Node D = g.addNode("D");
    A.setAttribute("xyz", new double[] { 1, 1, 0 });
    B.setAttribute("xyz", new double[] { 1, -1, 0 });
    C.setAttribute("xyz", new double[] { -1, -1, 0 });
    D.setAttribute("xyz", new double[] { -1, 1, 0 });
    A.setAttribute("ui.label", "A");
    B.setAttribute("ui.label", "B");
    C.setAttribute("ui.label", "C");
    D.setAttribute("ui.label", "D");
    Edge AB = g.addEdge("AB", "A", "B");
    Edge BC = g.addEdge("BC", "B", "C");
    Edge CD = g.addEdge("CD", "C", "D");
    Edge DA = g.addEdge("DA", "D", "A");
    AB.setAttribute("ui.points", new double[] { 1, 1, 0, 1.25, 0.5, 0, 0.75, -0.5, 0, 1, -1, 0 });
    BC.setAttribute("ui.points", new double[] { 1, -1, 0, 0.5, -0.5, 0, -0.5, -0.25, 0, -1, -1, 0 });
    CD.setAttribute("ui.points", new double[] { -1, -1, 0, -0.40, -0.5, 0, -1.70, 0.5, 0, -1, 1, 0 });
    // DA.setAttribute("ui.points", new double[]{-1, 1, 0,
    // -0.5, 0.75, 0,
    // 0.5, 0.25, 0,
    // 1, 1, 0});
    g.setAttribute("ui.stylesheet", styleSheet);
    g.setAttribute("ui.antialias");
    g.display(false);
}
Also used : Node(org.graphstream.graph.Node) SingleGraph(org.graphstream.graph.implementations.SingleGraph) Edge(org.graphstream.graph.Edge)

Example 14 with Node

use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.

the class TestShapeDecor method start.

public void start(Stage primaryStage) throws Exception {
    MultiGraph graph = new MultiGraph("Shape Decor");
    Viewer viewer = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
    ViewerPipe pipeIn = viewer.newViewerPipe();
    FxDefaultView view = (FxDefaultView) viewer.addView("view1", new FxGraphRenderer());
    view.resize(500, 430);
    Scene scene = new Scene(view, 500, 430, true, SceneAntialiasing.DISABLED);
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {

        @Override
        public void handle(WindowEvent t) {
            Platform.exit();
            System.exit(0);
        }
    });
    primaryStage.show();
    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");
    Node G = graph.addNode("G");
    Node U = graph.addNode("U");
    Node V = graph.addNode("V");
    Node W = graph.addNode("W");
    Node X = graph.addNode("X");
    Node Y = graph.addNode("Y");
    Node Z = graph.addNode("Z");
    Node T = graph.addNode("T");
    graph.addNode("a");
    graph.addNode("b");
    graph.addNode("c");
    graph.addNode("d");
    graph.addNode("e");
    graph.addNode("f");
    graph.addNode("g");
    graph.addNode("u");
    graph.addNode("v");
    graph.addNode("w");
    graph.addNode("x");
    graph.addNode("y");
    graph.addNode("z");
    graph.addNode("t");
    graph.addNode("i");
    graph.addNode("j");
    Edge au = graph.addEdge("au", "a", "u");
    Edge bv = graph.addEdge("bv", "b", "v");
    Edge cw = graph.addEdge("cw", "c", "w");
    Edge dx = graph.addEdge("dx", "d", "x");
    Edge ey = graph.addEdge("ey", "e", "y");
    Edge fz = graph.addEdge("fz", "f", "z");
    Edge gt = graph.addEdge("gt", "g", "t");
    Edge ij = graph.addEdge("ij", "i", "j");
    Edge AU = graph.addEdge("AU", "A", "U");
    Edge BV = graph.addEdge("BV", "B", "V");
    Edge CW = graph.addEdge("CW", "C", "W");
    Edge DX = graph.addEdge("DX", "D", "X");
    Edge EY = graph.addEdge("EY", "E", "Y");
    Edge FZ = graph.addEdge("FZ", "F", "Z");
    Edge GT = graph.addEdge("GT", "G", "T");
    A.setAttribute("xyz", new double[] { 0, 6, 0 });
    B.setAttribute("xyz", new double[] { 0, 5, 0 });
    C.setAttribute("xyz", new double[] { 0, 4, 0 });
    D.setAttribute("xyz", new double[] { 0, 3, 0 });
    E.setAttribute("xyz", new double[] { 0, 2, 0 });
    F.setAttribute("xyz", new double[] { 0, 1, 0 });
    G.setAttribute("xyz", new double[] { 0, 0, 0 });
    U.setAttribute("xyz", new double[] { 3, 5, 0 });
    V.setAttribute("xyz", new double[] { 3, 4, 0 });
    W.setAttribute("xyz", new double[] { 3, 3, 0 });
    X.setAttribute("xyz", new double[] { 3, 2, 0 });
    Y.setAttribute("xyz", new double[] { 3, 1, 0 });
    Z.setAttribute("xyz", new double[] { 3, 0, 0 });
    T.setAttribute("xyz", new double[] { 3, -1, 0 });
    graph.getNode("a").setAttribute("xyz", new double[] { 6, 5, 0 });
    graph.getNode("b").setAttribute("xyz", new double[] { 6, 4, 0 });
    graph.getNode("c").setAttribute("xyz", new double[] { 6, 3, 0 });
    graph.getNode("d").setAttribute("xyz", new double[] { 6, 2, 0 });
    graph.getNode("e").setAttribute("xyz", new double[] { 6, 1, 0 });
    graph.getNode("f").setAttribute("xyz", new double[] { 6, 0, 0 });
    graph.getNode("g").setAttribute("xyz", new double[] { 6, -1, 0 });
    graph.getNode("u").setAttribute("xyz", new double[] { 9, 6, 0 });
    graph.getNode("v").setAttribute("xyz", new double[] { 9, 5, 0 });
    graph.getNode("w").setAttribute("xyz", new double[] { 9, 4, 0 });
    graph.getNode("x").setAttribute("xyz", new double[] { 9, 3, 0 });
    graph.getNode("y").setAttribute("xyz", new double[] { 9, 2, 0 });
    graph.getNode("z").setAttribute("xyz", new double[] { 9, 1, 0 });
    graph.getNode("t").setAttribute("xyz", new double[] { 9, 0, 0 });
    graph.getNode("i").setAttribute("xyz", new double[] { 3, 7, 0 });
    graph.getNode("j").setAttribute("xyz", new double[] { 6, 8, 0 });
    A.setAttribute("label", "Center");
    B.setAttribute("label", "AtLeft");
    C.setAttribute("label", "AtRight");
    D.setAttribute("label", "Left");
    E.setAttribute("label", "Right");
    F.setAttribute("label", "Under");
    G.setAttribute("label", "Above");
    U.setAttribute("label", "Center");
    V.setAttribute("label", "AtLeft");
    W.setAttribute("label", "AtRight");
    X.setAttribute("label", "Left");
    Y.setAttribute("label", "Right");
    Z.setAttribute("label", "Under");
    T.setAttribute("label", "Above");
    au.setAttribute("label", "Center");
    bv.setAttribute("label", "AtLeft");
    cw.setAttribute("label", "AtRight");
    dx.setAttribute("label", "Left");
    ey.setAttribute("label", "Right");
    fz.setAttribute("label", "Under");
    gt.setAttribute("label", "Above");
    ij.setAttribute("label", "Along");
    graph.setAttribute("ui.screenshot", "text_align.png");
    new Thread(new Runnable() {

        @Override
        public void run() {
            while (loop) {
                pipeIn.pump();
                sleep(40);
            }
            System.out.println("bye bye");
            System.exit(0);
        }
    }).start();
}
Also used : 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) Scene(javafx.scene.Scene) MultiGraph(org.graphstream.graph.implementations.MultiGraph) FxViewer(org.graphstream.ui.fx_viewer.FxViewer) WindowEvent(javafx.stage.WindowEvent) Edge(org.graphstream.graph.Edge) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Example 15 with Node

use of org.graphstream.graph.Node in project gs-ui-javafx by graphstream.

the class TestSize method run.

private void run() {
    MultiGraph graph = new MultiGraph("Test Size");
    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");
    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);
    A.setAttribute("xyz", new double[] { 0, 1, 0 });
    B.setAttribute("xyz", new double[] { 1, 1, 0 });
    C.setAttribute("xyz", new double[] { 1, 0, 0 });
    D.setAttribute("xyz", new double[] { 0, 0, 0 });
    AB.setAttribute("ui.label", "AB");
    BC.setAttribute("ui.label", "A Long label ...");
    CD.setAttribute("ui.label", "CD");
    BB.setAttribute("ui.label", "BB");
    SpriteManager sm = new SpriteManager(graph);
    Sprite S1 = sm.addSprite("S1");
    S1.attachToNode("C");
    S1.setPosition(StyleConstants.Units.PX, 40, 45, 0);
    double size = 20f;
    double sizeInc = 1f;
    while (loop) {
        pipeIn.pump();
        sleep(40);
        A.setAttribute("ui.size", size);
        // A.setAttribute( "ui.size", "%spx".format( size ) )
        BC.setAttribute("ui.size", size);
        S1.setAttribute("ui.size", size);
        size += sizeInc;
        if (size > 50) {
            sizeInc = -1f;
            size = 50f;
        } else if (size < 20) {
            sizeInc = 1f;
            size = 20f;
        }
    }
    System.out.println("bye bye");
    System.exit(0);
}
Also used : FxViewer(org.graphstream.ui.fx_viewer.FxViewer) Sprite(org.graphstream.ui.spriteManager.Sprite) 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) SpriteManager(org.graphstream.ui.spriteManager.SpriteManager) MultiGraph(org.graphstream.graph.implementations.MultiGraph) ViewerPipe(org.graphstream.ui.view.ViewerPipe)

Aggregations

Node (org.graphstream.graph.Node)28 MultiGraph (org.graphstream.graph.implementations.MultiGraph)12 Edge (org.graphstream.graph.Edge)10 FxViewer (org.graphstream.ui.fx_viewer.FxViewer)9 ViewerPipe (org.graphstream.ui.view.ViewerPipe)9 FxDefaultView (org.graphstream.ui.fx_viewer.FxDefaultView)8 FxGraphRenderer (org.graphstream.ui.javafx.FxGraphRenderer)8 Scene (javafx.scene.Scene)6 Viewer (org.graphstream.ui.view.Viewer)6 SpriteManager (org.graphstream.ui.spriteManager.SpriteManager)4 SingleGraph (org.graphstream.graph.implementations.SingleGraph)3 WindowEvent (javafx.stage.WindowEvent)2 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)2 Point3 (org.graphstream.ui.geom.Point3)2 Sprite (org.graphstream.ui.spriteManager.Sprite)2 FileOutputStream (java.io.FileOutputStream)1 PrintWriter (java.io.PrintWriter)1 HashMap (java.util.HashMap)1 Random (java.util.Random)1 In (org.fagu.fmv.ffmpeg.filter.FilterComplexBase.In)1