[ 
https://issues.apache.org/jira/browse/PIVOT-623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044906#comment-13044906
 ] 

Roger Whitcomb commented on PIVOT-623:
--------------------------------------

I have a label field that displays a server/machine/host name, which normally 
(maybe always) will not have any spaces.  On most systems the screen space 
available is sufficient, but on some (where the host includes the domain name 
or is simply a long name) there is not enough space, so I would like the text 
to wrap.  But, even if "wrapText" is true it won't wrap this text because there 
is no whitespace.  So, the intention is to be able to specify a list (one or 
more) of characters that can be used instead of whitespace to break the string 
for wrapping.  This is specified to the skin as a style (same as "wrapText").  
In my particular case, I have a "wrapChars" setting of ".-_/\\" which are the 
only possible punctuation that would be in my text.  

What the patch does is prescan the text to see if there is any whitespace, and 
if not, then if a "wrapChars" string is specified it will use those characters 
instead of whitespace to break.  The only other wrinkle is that is has to back 
up one char so that the non-whitespace wrapping character will still be 
displayed (on the subsequent line).

So, on my example, my label text is "roger-whitcombs-computer.local/MX".  
Without this change there is enough room for about "roger-whitcombs-compu" and 
then it disappears off the right edge.  With this change and the "wrapChars" 
setting above it displays as:
roger-whitcombs
-computer.local/MX

Is that a clear explanation?

I'm not wedded to this concept, but I was trying to figure out a sensible 
scheme for allowing a wrap in the absence of whitespace.  I thought of just 
using any punctuation, but there is not a single function in the Character 
class to figure this out and it was sort of messy to check all the possible 
Unicode punctuation attribute values.  So, this approach seemed simpler and a 
bit more flexible (you could break on selected punctuation, or even on certain 
alphabetic or numeric characters if that made sense in your application).

If it doesn't seem like something you want in Pivot, I can do the wrapping 
myself also in my app.  Just seemed nicer to leverage the calculations that 
were already being done in LabelSkin.

Thanks.

> ellipsis style on labels
> ------------------------
>
>                 Key: PIVOT-623
>                 URL: https://issues.apache.org/jira/browse/PIVOT-623
>             Project: Pivot
>          Issue Type: Wish
>          Components: wtk, wtk-terra
>            Reporter: Sandro Martini
>            Assignee: Sandro Martini
>            Priority: Minor
>             Fix For: 2.1
>
>         Attachments: label.diff
>
>
> Add an ellipsis style on labels (default off), to trim the drawn label if 
> it's too long in respect of the space assigned.
> Depending on the chosen style, ellipsis chars could go at end of the label, 
> at center, at start, etc ... 
> Could be useful in some cases to have also "strange" behaviors, like for URLs 
> or file paths where for example could be useful to trim some parts of the 
> string but near the end of the path, but keeping the filename part full (if 
> possible).
> Verify if enable user defined behaviors also (for example giving in a 
> sub-style attribute the full classname of a custom implementation, but maybe 
> this could be too complex or not in line with other parts in Pivot.
> Verify if add also a sub-style attribute to set a different char to use for 
> the ellipsis (instead of the default "...").

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to