Search in sources :

Example 21 with Node

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

the class TutorialDiagrams method diagram1.

public Scene diagram1(String title, String styleSheet) {
    MultiGraph graph = new MultiGraph(title);
    Scene s = diagram(graph, styleSheet, title, 500, 250);
    Node G = graph.addNode("Graph");
    Node V = graph.addNode("Viewer");
    Edge E = graph.addEdge("G->V", "Graph", "Viewer", true);
    G.setAttribute("xyz", new double[] { 0, 0, 0 });
    V.setAttribute("xyz", new double[] { 1, 0, 0 });
    G.setAttribute("ui.label", "Graph");
    V.setAttribute("ui.label", "Viewer");
    return s;
}
Also used : Node(org.graphstream.graph.Node) Scene(javafx.scene.Scene) Edge(org.graphstream.graph.Edge) MultiGraph(org.graphstream.graph.implementations.MultiGraph)

Example 22 with Node

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

the class DemoViewerFxColorInterpolation method showSelection.

protected 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 23 with Node

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

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

the class MyGMLWriter method addObject.

@Override
public void addObject(final ObjectView o, final boolean COG) {
    super.addObject(o, COG);
    Node n = graph.addNode(getID(o));
    n.addAttribute("ui.label", getID(o));
    n.addAttribute("label", getLabel(o));
    n.addAttribute("cog", getID(getCOGOwner(o)));
    n.addAttribute("class", o.getClassName());
    if (COG) {
        n.addAttribute("layout.weight", 0.5f);
        n.addAttribute("ui.class", "cog");
        // n.addAttribute("ui.size", "25");
        n.addAttribute("Size", 20);
        n.addAttribute("Color", "[0,255,0]");
        n.addAttribute("kind", "cog");
    } else {
        n.addAttribute("layout.weight", 0.5f);
        n.addAttribute("ui.class", "obj");
        n.addAttribute("ui.size", "20");
        n.addAttribute("Size", 10);
        n.addAttribute("Color", "[255,0,0]");
        n.addAttribute("kind", "object");
    }
    if (o.equals("Main 1")) {
        n.addAttribute("ui.hide");
        System.out.println("YES");
    }
    if (!COG) {
        addEdge(o, getCOGOwner(o), true);
    }
}
Also used : Node(org.graphstream.graph.Node)

Example 25 with Node

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

the class FilterGraphUI method addTail.

/**
 */
private void addTail() {
    // TODO autoMap by outputProcessor
    AutoMap autoMap = operation.getAutoMap();
    Set<Label> labels = autoMap.find(operation);
    Node node = graph.addNode("output");
    node.addAttribute("ui.label", "output");
    node.addAttribute("ui.class", "root");
    for (Label label : labels) {
        // System.out.println(filterNaming.generate(label));
        Set<FilterComplex> fcs = filterGraph.getByOut(label);
        for (FilterComplex outFC : fcs) {
            Node inNode = createOrGetNode(outFC);
            graph.addEdge("output" + label, inNode, node);
        }
    }
}
Also used : FilterComplex(org.fagu.fmv.ffmpeg.filter.FilterComplex) Node(org.graphstream.graph.Node) Label(org.fagu.fmv.ffmpeg.filter.Label) AutoMap(org.fagu.fmv.ffmpeg.operation.AutoMap)

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