Search code examples
javasizejungvertices

Java Jung Set Size of Circle to the Width of its String (label)


I started working with java jung. I got a few problems due to the lack of good tutorials. I think i need a few timeto get into it.

Well my problem is:

I created a network with vertices (circles) which are labeled with text (strings). my problem is to fit the size (width) of the circles to the string.

I wanted to set it dynamically but dont know how to iterate through the vertices.


Solution

  • The solution for anyone who has the same question:

    FontMetrics fm = vv.getFontMetrics(vv.getFont());
    int width = fm.stringWidth(i);
    

    vv is the VisualizationViewer