<Swing Dev> [9] Review request for 8132119 Provide public API for text related methods in SwingUtilities2
Phil Race
philip.race at oracle.com
Wed Sep 2 17:09:14 UTC 2015
I don't remember or know how Swing resolves this but the measurement ones
are not reliable since they do not take a Graphics context, so you cannot
measure the string properly. You need a FontRenderContext to measure.
So as it stands these APIs do not appear suitable to be made public as they
are not reliable.
Whilst I could look at the code, if I instead just look at the API, I am
scratching my
head over :-
public static void drawString(JComponent c, Graphics g, String text, int x, int y)
Here you provide the Graphics *and* the Component.
And it says the JComponent may be null.
So I am supposing that there is optional information that may be pulled from the
JComponent regarding rendering mode ?
drawStringUnderlineCharAt(..) probably needs to explain if the index is code point
or UTF16 char index and what happens if there is not 1:1 code point:glyph mapping.
Are we sure that (any of) these really ought/need to be public - particularly given the
resolution of https://bugs.openjdk.java.net/browse/JDK-6302464
-phil.
On 09/02/2015 08:28 AM, Alexander Scherbatiy wrote:
>
> Hello,
>
> Could you review the fix:
> bug: https://bugs.openjdk.java.net/browse/JDK-8132119
> webrev: http://cr.openjdk.java.net/~alexsch/8132119/webrev.00
>
> The suggested drawString, drawStringUnderlineCharAt,
> clipStringIfNecessary, and stringWidth methods are
> added to the javax.swing.text.Utilities class.
>
> Thanks,
> Alexandr.
>
More information about the swing-dev
mailing list