Linefeed in Labels

Have jReality programming problems or questions? Post them here.
Post Reply
goetz
Posts: 12
Joined: Sun 7. Jun 2009, 09:48

Linefeed in Labels

Post by goetz » Wed 1. Jul 2009, 10:11

Hello,

is it somehow possible to create a new line in a label?
I mean something like this in your tutorial "Labels on Cubes":

Code: Select all

int n=ps.getNumPoints();
      String[] labels=new String[n];
      for (int i = 0; i<n; i++) labels[i] = "Test \n blabla \n TestTest ";
      ps.setVertexAttributes(Attribute.LABELS, StorageModel.STRING_ARRAY.createReadOnly(labels));
normally this creates:

Code: Select all

Test
blabla
TestTest
But inside a label it creates:

Code: Select all

Test blabla TestTest
Getting this in the label:

Code: Select all

String separator = System.getProperty("line.Separator");
this didn't work either.

Thanks for your support!

Goetz

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Linefeed in Labels

Post by gunn » Wed 1. Jul 2009, 12:00

This is a feature which has been mentioned before by others, so I took a look at the way that the label images are created. Since it wasn't too difficult, I added a new method in de.jreality.backends.labels.LabelUtility to allow multiline labels to be converted to images. I've also added a tutorial de.jreality.tutorial.app.MultilineLabelExample, if you want to directly generate multi-line labels for use as texture maps.

This support has also been added to the LABELS attribute attached to a geometry, as in the original posting. The newline character '\n' in a label is now respected when generating the images for the label.

Update from svn for this new feature to be available.
jReality core developer

goetz
Posts: 12
Joined: Sun 7. Jun 2009, 09:48

Re: Linefeed in Labels

Post by goetz » Wed 1. Jul 2009, 13:02

works perfect! Thank you.

Post Reply