Search in sources :

Example 1 with Edge

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

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

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

the class MyGMLWriter method addEdge.

@Override
public synchronized void addEdge(ObjectView source, ObjectView target, boolean cog) {
    String edgeName = getID(source) + "-" + getID(target);
    Edge e = graph.getEdge(edgeName);
    if (e == null || (!cog && e.getAttribute("kind").equals("cog"))) {
        e = graph.addEdge(edgeName, getID(source), getID(target), true);
        e.addAttribute("count", 1);
        if (cog) {
            e.addAttribute("ui.class", "cog");
            e.addAttribute("kind", "cog");
            e.addAttribute("weight", 5);
        } else {
            e.addAttribute("ui.class", "usage");
            e.addAttribute("kind", "usage");
            e.addAttribute("weight", 1);
        }
    } else {
        int c = (Integer) e.getAttribute("count");
        e.setAttribute("count", c + 1);
        System.out.println("Count = " + (c + 1));
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Edge(org.graphstream.graph.Edge)

Example 4 with Edge

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

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

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