本文介绍了JGraphX中的无向图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在JGraphx中显示图表。
一切都很好,只要我使用有向图,
但是当我试图显示一个无向的时,它显示
指示。
I try to show graphs in JGraphx.Everything is fine as long as I use directed Graphs,but when I try to show an undirected one, its shownwith direction.
代码来自jgrapht的演示。
The code is from the demo of jgrapht.
是否可以将其显示为无向?
Is it possible to show it undirected?
谢谢
Torben
PS:抱歉我的英文不好
PS.: Sorry for my bad English
推荐答案
您可以将 mxGraphComponent
中边缘的样式设置为 NONE
:
You can set the style of the edges in the mxGraphComponent
to NONE
:
mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter);
mxGraphModel graphModel = (mxGraphModel)graphComponent.getGraph().getModel();
Collection<Object> cells = graphModel.getCells().values();
mxUtils.setCellStyles(graphComponent.getGraph().getModel(),
cells.toArray(), mxConstants.STYLE_ENDARROW, mxConstants.NONE);
//instead of getContentPane().add(new mxGraphComponent(jgxAdapter));
getContentPane().add(graphComponent);
这篇关于JGraphX中的无向图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!