comparing open source java graph drawing frameworks(JUNG and Prefuse) for drawing network topology

后端 未结 5 1854
一整个雨季
一整个雨季 2021-01-31 09:18

which of the open source Java graph drawing frameworks to use for a network diagram with the following requirements? The graph will have less than 1000 nodes.

1) has par

5条回答
  •  一生所求
    2021-01-31 10:22

    I like @holygeek's answer. Here is my implementation to the solution for 2 (both directed and undirected edges), for Prefuse:

    public class MyRenderFactory implements RendererFactory
    {
        private NodeRenderer nodeRenderer = new NodeRenderer();
        private EdgeRenderer defaultEdgeRenderer = new EdgeRenderer();
        private EdgeRenderer undirectedEdgeRenderer = new EdgeRenderer(EdgeRenderer.EdgeType.LINE, EdgeRenderer.EdgeArrowType.NONE);
    
        public static String directedness = "myEdgeDirectedness";
    
        public enum EdgeDirected
        {
            directed, undirected;
    
            public static EdgeDirected fromIsDirected(boolean isDirected)
            {
                if (isDirected)
                {
                    return directed;
                }
                return undirected;
            }
        }
    
        @Override
        public Renderer getRenderer(VisualItem visualItem)
        {
            if (visualItem instanceof EdgeItem)
            {
                if (visualItem.get(directedness).equals(PrefuseGraphConverter.EdgeDirected.undirected))
                {
                    return undirectedEdgeRenderer;
                }
                return defaultEdgeRenderer;
            }
            return nodeRenderer;
        }
    }
    

    ...elsewhere, where the graph is created...

    MyRenderFactory.EdgeDirected directedness =
            MyRenderFactory.EdgeDirected.fromIsDirected(myEdge.isDirected());
    prefuseEdge.set(MyRenderFactory.directedness, directedness);
    

提交回复
热议问题