Search in sources :

Example 1 with Node

use of org.graphstream.graph.Node in project abstools by abstools.

the class MyGMLWriter method writeAll.

public synchronized void writeAll(Graph g, File file) throws FileNotFoundException {
    pw = new PrintWriter(new FileOutputStream(file));
    pw.println("Creator " + escape("ABS Graph Writer"));
    pw.println("graph [");
    for (Node n : g.getNodeSet()) {
        writeNode(n);
    }
    for (Edge e : g.getEdgeSet()) {
        writeEdge(e);
    }
    pw.println("]");
    pw.close();
    pw = null;
}
Also used : FileOutputStream(java.io.FileOutputStream) Node(org.graphstream.graph.Node) Edge(org.graphstream.graph.Edge) PrintWriter(java.io.PrintWriter)

Example 2 with Node

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

the class DefaultCamera method checkVisibility.

/**
 * Process each node to check if it is in the actual view port, and mark
 * invisible nodes. This method allows for fast node, sprite and edge
 * visibility checking when drawing. This must be called before each
 * rendering (if the view port changed).
 */
public void checkVisibility(GraphicGraph graph) {
    double X = metrics.viewport[0];
    double Y = metrics.viewport[1];
    double W = metrics.viewport[2];
    double H = metrics.viewport[3];
    nodeInvisible.clear();
    for (Node node : graph) {
        boolean visible = isNodeIn((GraphicNode) node, X, Y, X + W, Y + H) && (!((GraphicNode) node).hidden) && ((GraphicNode) node).positionned;
        if (!visible)
            nodeInvisible.add(node.getId());
    }
}
Also used : GraphicNode(org.graphstream.ui.graphicGraph.GraphicNode) Node(org.graphstream.graph.Node) GraphicNode(org.graphstream.ui.graphicGraph.GraphicNode)

Example 3 with Node

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

the class MovingNodeSprite method move.

public void move() {
    double p = getZ() + speed;
    if (p < 0 || p > 360) {
        p = 0f;
    }
    Node node = (Node) getAttachment();
    if (node != null) {
        setPosition(units, off, 0, p);
    }
}
Also used : Node(org.graphstream.graph.Node)

Example 4 with Node

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

the class TutorialDiagrams method diagram1b.

public Scene diagram1b(String title, String styleSheet) {
    MultiGraph graph = new MultiGraph(title);
    Scene s = diagram(graph, styleSheet, title, 500, 370);
    Node G = graph.addNode("Graph");
    Node V = graph.addNode("Viewer");
    Node B1 = graph.addNode("bidon1");
    Node B2 = graph.addNode("bidon2");
    graph.addEdge("G->bidon1", "Graph", "bidon1", true);
    graph.addEdge("bidon1->V", "bidon1", "Viewer", true);
    graph.addEdge("V->bidon2", "Viewer", "bidon2", true);
    graph.addEdge("bidon2->G", "bidon2", "Graph", true);
    G.setAttribute("xyz", new double[] { 0, 0, 0 });
    B1.setAttribute("xyz", new double[] { 0, 0.5, 0 });
    V.setAttribute("xyz", new double[] { 1, 0.5, 0 });
    B2.setAttribute("xyz", new double[] { 1, 0, 0 });
    G.setAttribute("ui.label", "Graph");
    V.setAttribute("ui.label", "Viewer");
    B1.setAttribute("ui.class", "invisible");
    B2.setAttribute("ui.class", "invisible");
    return s;
}
Also used : Node(org.graphstream.graph.Node) Scene(javafx.scene.Scene) MultiGraph(org.graphstream.graph.implementations.MultiGraph)

Example 5 with Node

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

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