Reputation: 157
I need my vertex label displayed entirely inside vertex bounds. I mean if my label is too long then part of it will be displayed outside the vertex box. Is there any way to automatically split label into multiple lines and make it fit the vertex bounds? This line breaks should be recalculated after vertex resize. Can i do it using styles? mxUtils.wordWrap() seems to be the way but i cannot figure out how to use it properly. Give me an example of using it please. Thanks for your answers
Upvotes: 0
Views: 1467
Reputation: 369
Another similar question: Calculate the display width of a string in Java
Abstract: Graphics.getFontMetrics + FontMetrics.stringWidth
From this, I suppose you could create a List<String>
and add the words of the text one at a time until you reach your max length, then add a new node to the list for the overflow. Finally, append each node in the List
to each other with a line break in between.
On another note, from what research I did, it seems jGraphX runs on swing. Swing now supports HTML. Here's a link to further info: http://docs.oracle.com/javase/tutorial/uiswing/components/html.html.
I will see if I can get a quick test coded up, but that must wait until I get home.
Upvotes: 1