Question

I've made a graph with StaticLayout and changed shapes\colors of vertices. I didn't transform anything related to edges. All edges are directed, but some of them miss arrows! How could that happen?

screenshot

Graph Visualization code:

    Layout<Object, String> layout = new StaticLayout<Object, String>(graphProvider.graphFor(market),new MarketVertexLayoutTransformer(market,panel.getMarketGraphPane().getSize() )) ;
    layout.setSize(panel.getMarketGraphPane().getSize());
    VisualizationViewer<Object,String> graphPanel = new VisualizationViewer<Object,String>(layout);
    graphPanel.getRenderContext().setVertexShapeTransformer(new MarketVertexShapeTransformer());
    graphPanel.getRenderContext().setVertexFillPaintTransformer(new MarketVertexColorTransformer());
    panel.getMarketGraphPane().add(graphPanel, BorderLayout.CENTER);
    panel.getMarketGraphPane().revalidate();

Graphs is

graph = new DirectedSparseGraph<Object, String>();

and Edges are created like that

   graph.addEdge(bundle.getGood()+"->"+transformation,bundle.getGood(),transformation);
   graph.addEdge(transformation+"->"+bundle.getGood(),transformation,bundle.getGood());

Thanks

Was it helpful?

Solution

The arrow placement is done by subdividing the edge until the far segment is enclosed in the vertex shape, then moving back one. If the far endpoint is not inside the vertex shape when the operation starts, there should be an exception thrown. You chose the correct solution, which is to center your vertex shapes on the origin before they are translated into place. Tom Nelson

OTHER TIPS

The problem is caused by EdgeRenderer. It gets confused if edges are connected to upper left corner of the vertex. When I changed my shapes from

CIRCLE(new Ellipse2D.Double(0,0,40,40)),
BOX(new Rectangle2D.Double(0,0,40,40));

to

CIRCLE(new Ellipse2D.Double(-20,-20,40,40)),
BOX(new Rectangle2D.Double(-20,-20,40,40));

Connection points moved to the center of vertices and from there EdgeRenderer does its magic without problems. However, I don't understand why changing frame position of a shape makes this difference. Would be glad if someone could explain this.

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