[英]Drawing directed edges programmatically in Prefuse
I use the following code to display a graph: 我使用以下代码显示图表:
graph = new Graph(true);
vis = new Visualization();
vis.add(GRAPH, graph);
CustomLabelRenderer re = new CustomLabelRenderer();
re.setImageField(NODE_TYPE_IMAGE);
re.setImagePosition(Constants.TOP);
EdgeRenderer edgeRenderer = new EdgeRenderer(Constants.EDGE_TYPE_LINE, Constants.EDGE_ARROW_FORWARD);
edgeRenderer.setArrowType(Constants.EDGE_ARROW_FORWARD);
edgeRenderer.setArrowHeadSize(10, 10);
DefaultRendererFactory factory = new DefaultRendererFactory(re, edgeRenderer);
factory.add(new InGroupPredicate(EDGE_DECORATORS), new LabelRenderer(VisualItem.LABEL));
vis.setRendererFactory(factory);
As you can see instantiate the graph to use directed edges. 如您所见,实例化图形以使用有向边。 Afterwards I set the EdgeRenderer to use arrow heads. 然后我将EdgeRenderer设置为使用箭头。 However, I can't see any arrows on my edges, but just plain lines. 但是,我看不到边缘上的任何箭头,只是简单的线条。 What am I doing wrong? 我究竟做错了什么?
That's how I add edges: 这就是我添加边缘的方式:
graph.addEdge(node1, node2);
You need to set the FILLCOLOR
for edges: 您需要为边缘设置FILLCOLOR
:
filter.add(new ColorAction(edges, VisualItem.FILLCOLOR,
ColorLib.rgb(100,100,100));
I reproduce the problem with the RadialGraphView
demo and I did not need any changes to the source code except for this line. 我使用RadialGraphView
演示重现问题,除了这一行,我不需要对源代码进行任何更改。 (Though, I had to change the data file.) (虽然,我不得不更改数据文件。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.