Search in sources :

Example 6 with Node

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

the class TestSprite method chooseNextEdge.

public void chooseNextEdge() {
    Edge edge = (Edge) getAttachment();
    Node node = edge.getSourceNode();
    if (dir > 0)
        node = edge.getTargetNode();
    Edge next = randomEdge(node);
    double pos = 0;
    if (node == next.getSourceNode()) {
        dir = 0.01f;
        pos = 0;
    } else {
        dir = -0.01f;
        pos = 1;
    }
    attachToEdge(next.getId());
    setPosition(pos);
}
Also used : Node(org.graphstream.graph.Node) Edge(org.graphstream.graph.Edge)

Example 7 with Node

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

the class DemoViewerFxEdgeSelection method showSelection.

protected static void showSelection(Graph graph) {
    boolean selection = false;
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    for (Node node : graph) {
        if (node.hasAttribute("ui.selected")) {
            sb.append(String.format(" %s", node.getId()));
            selection = true;
        }
        if (node.hasAttribute("ui.clicked")) {
            System.err.printf("node %s clicked%n", node.getId());
        }
    }
    sb.append(" ]");
    if (selection)
        System.err.printf("selection = %s%n", sb.toString());
}
Also used : Node(org.graphstream.graph.Node)

Example 8 with Node

use of org.graphstream.graph.Node in project fmv by f-agu.

the class FilterGraphUI method createRootNode.

/**
 * @param inputProcessor
 * @param outputKey
 * @return
 */
private Node createRootNode(InputProcessor inputProcessor, OutputKey outputKey) {
    Node node = graph.addNode(filterNaming.generate(outputKey.getLabel()));
    node.addAttribute("ui.label", inputProcessor.getInput().toString());
    node.addAttribute("ui.class", "root");
    return node;
}
Also used : Node(org.graphstream.graph.Node)

Example 9 with Node

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

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

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