Reputation: 329
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?
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
Upvotes: 1
Views: 980
Reputation:
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
Upvotes: 2
Reputation: 329
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.
Upvotes: 0