Search in sources :

Example 6 with Edge

use of org.graphstream.graph.Edge 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 7 with Edge

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

the class MovingEdgeSprite method move.

public void move() {
    double p = getX();
    p += speed;
    if (p < 0 || p > 1) {
        Edge edge = null;
        if (getAttachment() instanceof Edge)
            edge = (Edge) getAttachment();
        if (edge != null) {
            Node node = edge.getSourceNode();
            if (p > 1)
                node = edge.getTargetNode();
            Edge other = randomOutEdge(node);
            if (other == null) {
                System.err.println("node " + node.getId() + " out=" + node.getOutDegree() + " null !!");
            }
            if (node.getOutDegree() > 1) {
                while (other.equals(edge)) other = randomOutEdge(node);
            }
            attachToEdge(other.getId());
            if (node.equals(other.getSourceNode())) {
                setPosition(units, 0, off, 0);
                speed = SPEED;
            } else {
                setPosition(units, 1, off, 0);
                speed = -SPEED;
            }
        }
    } else {
        setPosition(units, p, off, 0);
    }
}
Also used : Node(org.graphstream.graph.Node) Edge(org.graphstream.graph.Edge)

Example 8 with Edge

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

Example 9 with Edge

use of org.graphstream.graph.Edge 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 10 with Edge

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

Aggregations

Edge (org.graphstream.graph.Edge)11 Node (org.graphstream.graph.Node)10 MultiGraph (org.graphstream.graph.implementations.MultiGraph)4 FxDefaultView (org.graphstream.ui.fx_viewer.FxDefaultView)3 FxViewer (org.graphstream.ui.fx_viewer.FxViewer)3 FxGraphRenderer (org.graphstream.ui.javafx.FxGraphRenderer)3 Viewer (org.graphstream.ui.view.Viewer)3 ViewerPipe (org.graphstream.ui.view.ViewerPipe)3 Scene (javafx.scene.Scene)2 FileOutputStream (java.io.FileOutputStream)1 PrintWriter (java.io.PrintWriter)1 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 WindowEvent (javafx.stage.WindowEvent)1 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)1 In (org.fagu.fmv.ffmpeg.filter.FilterComplexBase.In)1 FilterInput (org.fagu.fmv.ffmpeg.filter.FilterInput)1 IOKey (org.fagu.fmv.ffmpeg.filter.IOKey)1 OutputKey (org.fagu.fmv.ffmpeg.filter.OutputKey)1 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)1