Question

I use Jung to draw graphs. Below is a simple graph with tree layout that looks fine. All renderers and transformers are default.

alt text http://czuk.eu/stackoverflow/ballon_layout_default_size.png

Now, I have changed the default size of the nodes to 100px by setting a custom VertexShapeTransformer. The problem is that the nodes started to overlap. Here you can see how it looks:

alt text http://czuk.eu/stackoverflow/ballon_layout_size_100px.png

Is it possible to get rid of the vertex overlapping? Is it a matter of layout or some kind of shape transformation?

Thank you in advance for any suggestions :-)

Was it helpful?

Solution

After not so long investigation I found out that there are two static attributes responsible for setting the minimum distances between vertexes. These are TreeLayout.DEFAULT_DISTX and TreeLayout.DEFAULT_DISTY. Unfortunately, those attributes define a fixed minimum distance between vertexes but do not consider the real size of each vertex that may differ. The setting is valid for the TreeLayout and the BalloonLayout that extends the TreeLayout.

I also tries other layout but I could not find an analogical solution. This issue is for another question ;-)

OTHER TIPS

When you create a TreeLayout you can specify the TreeLayout.DEFAULT_DISTX and TreeLayout.DEFAULT_DISTY in the constructor:

TreeLayout treeLayout = new TreeLayout<String,Integer>(graph,100,100);

Perhaps you need to put a greater distance between the nodes? You started with a certain distance with a certain size nodes. When you increased the size of the node you reduced the space between them, to compensate extra distance needs to be put between the nodes to keep them from overlapping.

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