xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank Walter" <Frank.Wal...@gmx.net>
Subject Implementation of Autowrapping of Tooltips
Date Thu, 19 Feb 2004 14:23:26 GMT
Hi,

I implemented autowrapping for tooltip texts, i.e. modified the method
batik.swing.JSVGCanvas.CanvasUserAgent.toFormattedHTML
such that it is possible to break lines at a certain threshold. So that the
formatting is not messed up, the code is attached separately.

Basically, the method which autowraps is a greedy algorithm with the
following properties:
--- for each word, it checks whether it would still fit in the line, and if
not, it breaks before the word.
--- if there should be a word which happens to be longer than the line size,
we put this word in a separate line which is as long as the word size (this
should happen very rarely if the line size is chosen appropriately; 50
characters seemed okay to me).

I know that hardcoding the line length of 50 characters right in the method
is not a good idea, but as I am not sure of how Batik handles such kind of
parameters, I left it there. If you should include it within the official
release at some time, which you should feel free to do if you want, I would
suggest putting the lengh definition somewhere with other variables of the type.

I tested the method with several test cases and I tried to comment the code
well. Should there be any questions, feel free to ask.  Of course, I am also
open for comments. Even with big, big SVG files (~2MB) with lots of shapes I
did not notice any performance drawback.

Regards,

Frank

-- 
GMX ProMail (250 MB Mailbox, 50 FreeSMS, Virenschutz, 2,99 EUR/Monat...)
jetzt 3 Monate GRATIS + 3x DER SPIEGEL +++ http://www.gmx.net/derspiegel +++
Mime
View raw message