Reduce text length to fit cell width in a smart manner

Posted by Andrei Ciobanu on Stack Overflow See other posts from Stack Overflow or by Andrei Ciobanu
Published on 2010-06-09T10:37:11Z Indexed on 2010/06/09 11:02 UTC
Read the original article Hit count: 150

Filed under:
|
|

Hello,

I am in project where we are building a simple web calendar using Java EE technologies.

We define a table where every row is an employee, and every column represents an hour interval. The table width and column widths are adjustable. In every cell we have a text retrieved from a database, indicating what the employee is doing / should do in that time interval.

The problem is that sometimes the text in cells is getting bigger than the actual cell. My task is to make the text more "readable" by reducing it's length in a "smart way" so that it can fit in the cell more "gracefully".

For example if initially in a cell I have: "Writing documents", after the resize I should retrieve: "Wrtng. dcmnts" or "Writ. docum." so that the text can fit well.

Is there a smart way to do it ? Or removing vocals / split the string in two is enough ?

© Stack Overflow or respective owner

Related posts about java

Related posts about algorithm