Search in sources :

Example 26 with Node

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

the class FilterGraphUI method createOrGetEdge.

/**
 * @param label
 * @param labeledFC
 * @param node
 * @return
 */
private Edge createOrGetEdge(Label label, FilterComplex labeledFC, Node node) {
    String edgeKey = getEdgeKey(label, labeledFC);
    Edge edge = graph.getEdge(edgeKey);
    if (edge == null) {
        Node inNode = createOrGetNode(labeledFC);
        edge = graph.addEdge(edgeKey, inNode, node);
        edge.addAttribute("ui.label", edgeKey);
    }
    return edge;
}
Also used : Node(org.graphstream.graph.Node) Edge(org.graphstream.graph.Edge)

Example 27 with Node

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

the class FilterGraphUI method addRoot.

// **************************************************
/**
 */
private void addRoot() {
    Map<InputProcessor, Node> inputProcessorNodeMap = new HashMap<>();
    operation.getInputProcessorStream().forEach(ip -> {
        for (OutputKey outputKey : ip.getOutputKeys()) {
            Node node = createRootNode(ip, outputKey);
            inputProcessorNodeMap.put(ip, node);
        }
    });
    for (FilterComplex rootFC : filterGraph.getRoots()) {
        Map<IOKey, In> inputMap = rootFC.getInputMap();
        if (!inputMap.isEmpty()) {
            for (Entry<IOKey, In> entry : inputMap.entrySet()) {
                FilterInput filterInput = entry.getValue().getFilterInput();
                if (filterInput instanceof InputProcessor) {
                    Node node = inputProcessorNodeMap.get(filterInput);
                    Edge edge = graph.addEdge(node.getId() + "-" + rootFC.toString(), createOrGetNode(rootFC), node);
                // edge.addAttribute("ui.label", values);
                }
            }
        }
    }
}
Also used : IOKey(org.fagu.fmv.ffmpeg.filter.IOKey) FilterComplex(org.fagu.fmv.ffmpeg.filter.FilterComplex) HashMap(java.util.HashMap) In(org.fagu.fmv.ffmpeg.filter.FilterComplexBase.In) Node(org.graphstream.graph.Node) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Edge(org.graphstream.graph.Edge) OutputKey(org.fagu.fmv.ffmpeg.filter.OutputKey)

Example 28 with Node

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

the class FilterGraphUI method createOrGetNode.

/**
 * @param filterComplex
 * @return
 */
private Node createOrGetNode(FilterComplex filterComplex) {
    String nodeKey = getNodeKey(filterComplex);
    Node node = graph.getNode(nodeKey);
    if (node == null) {
        node = graph.addNode(nodeKey);
        node.addAttribute("ui.label", nodeKey);
        Collection<Type> types = filterComplex.getTypes();
        String ccsStyle = null;
        if (types.contains(Type.AUDIO) && !types.contains(Type.VIDEO)) {
            ccsStyle = "audio";
        } else if (!types.contains(Type.AUDIO) && types.contains(Type.VIDEO)) {
            ccsStyle = "video";
        }
        if (ccsStyle != null) {
            node.setAttribute("ui.class", ccsStyle);
        }
    }
    return node;
}
Also used : Type(org.fagu.fmv.ffmpeg.operation.Type) Node(org.graphstream.graph.Node)

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