Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JGraphX - auto organise of cells and bidirectional edges

I am using JGraphX java library to visualise a graph model and overall it seems quite good. However, I am encountering 2 small problems.

1) Is there any possible way of having the nodes spread out in an automatic way and not defining explicity the location of where they are to be placed?

2) In the case where I have 2 edges (one from A to B, and one from B to A), is there any possible way where the user can select on of them only?

Thanks!

like image 483
aseychell Avatar asked Apr 09 '11 06:04

aseychell


1 Answers

Ok I think i managed to find a solution to my question. I discovered the mxParallelEdgeLayout which makes both the edges visible. I am still looking for a good layout to display my graphs but there seems a number of these which might be enough to be used. A combination of the mxHierarchicalLayout and the mxParallelEdgeLayout seems to suite my purpose.

Example:

final mxGraphComponent graphComponent = new mxGraphComponent(trafficGraphVisual);
pnlGraphVisual.add(graphComponent, BorderLayout.CENTER);
new mxHierarchicalLayout(trafficGraphVisual).execute(trafficGraphVisual.getDefaultParent());
new mxParallelEdgeLayout(trafficGraphVisual).execute(trafficGraphVisual.getDefaultParent());
like image 106
aseychell Avatar answered Oct 22 '22 16:10

aseychell