Question

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. 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);
Was it helpful?

Solution

You need to set the FILLCOLOR for edges:

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. (Though, I had to change the data file.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top