让 Graphstream 只渲染发生变化的部分

2024-04-17

我使用以下方法创建了一个表示特定区域路线图的图表Graphstream.

现在我想让蓝色节点看起来像在图表上移动,为此我在另一个线程上显示图表,并且每秒将不同的节点着色为蓝色,如下所示:

public void drawGraph(List<MyCustomNodeClass> nodes, List<MyCustomEdgeClass> edges){
    Graph graph = new MultiGraph("main graph");
    Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
    ViewerPipe pipeIn = viewer.newViewerPipe();
    viewer.addView("view1", new J2DGraphRenderer());

    pipeIn.addAttributeSink(graph);
    pipeIn.pump();

    nodes.forEach(node-> graph.addNode(node.getId()));

    edges.forEach(edge-> graph.getEdge(edge.getId(), edge.getSrc(), edge.getDest()));

    Node node = graph.getNode("start");

    while(true){
        pipeIn.pump();

        sleep(100);

        node.setAttribute("ui.style", "z-index: 1; size: 3px; fill-color: black;");

        node = node = node.getNeighborNodeIterator().next();;

        node.setAttribute("ui.style", "z-index: 2; size: 10px; fill-color: blue;");
    }
}
private void sleep(long seconds ) {
    try { Thread.sleep( seconds ) ; }
    catch (InterruptedException e) { e.printStackTrace(); }
}

正如标题所示,我的问题是图很大(15997条边,9084个节点),并且它使得它花费的时间GraphStream渲染图表的时间大于睡眠时间,因此“动画”效果不佳。

有没有办法制作GraphStream只渲染发生变化的对象(本例中只有 2 个节点)?


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

让 Graphstream 只渲染发生变化的部分 的相关文章

随机推荐