Q: How to change arrow position or remove it from

2019-09-19 20:18发布

What the question states.I have many arrows connecting to one Node and it looks very cluttered on the graph. Any way to relocate the arrows towards the center or remove them ?

标签: java graph jung
2条回答
趁早两清
2楼-- · 2019-09-19 20:44

Changed the type of the graph From DirectedSparseMultigraph to SparseMultigraph and fixed the issue I was having.

查看更多
等我变得足够好
3楼-- · 2019-09-19 20:54

By default, directed edges are rendered with arrowheads on them so that you can see the direction of the edge.

If you don't want the arrowheads to be present at all:

visualizationViewer.getRenderContext().setEdgeArrowPredicate(false);

If you want the arrowheads to be present, but rendered in the middle of their respective edges instead of at their target:

visualizationViewer.getRenderer()
    .getEdgeRenderer()
    .setEdgeArrowRenderingSupport(
        new CenterEdgeArrowRenderingSupport<>());

If you want to use a different edge shape that shows the edge direction differently:

visualizationViewer
    .getRenderContext()
    .setEdgeShapeTransformer(EdgeShape.wedge(10));

Finally, if you don't want directed edges, then you can use an undirected graph. (The edges of SparseMultigraph are undirected by default.)

These capabilities are demonstrated in PluggableRendererDemo, which is one of the samples available as part of the JUNG distribution. Note that these APIs are accurate for JUNG 2.1.*, but some things will be changing for the upcoming 3.0 release.

查看更多
登录 后发表回答