views:

54

answers:

6

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 ?

+1  A: 

Keep multiple versions of such strings that will be shown depending on container size.

luvieere
+1  A: 

To me "Wrtng. dcmnts" looks horrible (but that may be just me).

I could imagine using a mapping of longer to shorter versions, e.g.

"Writing" -> "Writ."
"Documents" -> "Doc."
"Writ." -> Wr."
"Doc." -> "D."

etc., then picking the right one depending on the cell size.

Alternatively, if you don't have a large number of word combinations, you can map the whole task names too:

"Writing Documents" -> "Writ. Doc."
"Writ. Doc." -> Wr. D."
Péter Török
The problem is I don't know what "text" is lying in a database. The words aren't fixed, it can be antything in the english language. I am trying to find just the right way.
Andrei Ciobanu
@Andrei, you could have the short version(s) right there in the DB as well.
Péter Török
+1  A: 

Perl has Lingua::EN::Squeeze, but that algoritm doesn't appear to produce terribly readable text; http://search.cpan.org/~jariaalto/Lingua-EN-Squeeze-2006.0704/Squeeze.pm

You could try SMS Speak; http://en.wikipedia.org/wiki/SMS_language

Braille uses some short word version; http://www.brl.org/intro/session09/short.html

Another option might to to make use of the CSS text-overflow declaration; http://www.quirksmode.org/css/textoverflow.html

In any event, you're likely to end up having to do some string or regular expression replacements prior to displaying to the user.

You might also want to consider using a "title" attribute, or similar, to allow the user to hover over the abbreviated text to get a popup with the original.

ptomli
+1  A: 

If you are not able to store abbreviations you're probably going to get stuck with some rules such as:

if the string is too long
  remove the two rightmost vowels and append a .
  do while the string is too long and there are any vowels left
     remove vowels one at a time from the right
  do while the string is too long
     remove a consonant from the right end of the rightmost word
     if the string is still too long
         remove a consonant from the last word but one
         ...

You get the picture, it's fiddly but not rocket science.

You could combine this with a set of rewrite rules for common words and for common groups of letters. For example:

customer -> custmr -> cust -> cst
ation -> tn

I suspect applying rules first, then an abbreviating algorithm will give more pleasing results.

High Performance Mark
+3  A: 

I'm adding another answer, as I provide a different approach: instead of using shortened versions of the words, when the full text does not fit, you could use trailing dots "..." to show that there is more text, and show the full version in a tooltip when hovering the cell:

Writin...

in the cell,

Writing documents

in the tooltip.

This way, your program will also behave well for international use, and space requirements for keeping multiple versions of the same strings disappear.

luvieere
+1  A: 

To me having variable abbreviations is not a nice thing at all - it can lead to ambiguity, which in turn can lead to wrong interpretations and wrong decisions.

Typical approach (from transaction descriptions in bookkeeping/financial systems) is to have facilities to build and maintain a dictionary of abbreviations. (This can also help with validating or transforming data input and not only for presentation of output).

Tooltips are a good solution anyhow you look at the problem (or some similar focus/detail UI functionality).

Also, you should have a uniform way of showing which cells have been cropped.

Unreason