This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Centering Text on image

 
Divya Guttikonda
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using com.mullassery.imaging.Imaging package in my java program.I am overlaying a text on the image.But what i need is to center the text when overlaying.It can span to any number of lines so the problem is i cant specify the x and y co-ordinates.Does anybody know if there is any existing functionality to center the text.Please help.
 
Joe Ess
Bartender
Pie
Posts: 9257
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never heard of it.
Using the J2SE packages, I've used Graphics to get the size of an image, then the FontMetrics class to determine the size of the string. Subtract the string size from the size of the image and divide by two. Of course, doing multiple lines requires some more calculations, but the information is all there in those two classes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic