On 11/8/2016 4:39 PM, Sergey Bylokhov wrote:

On 02.11.16 10:48, Semyon Sadetsky wrote:
On 11/1/2016 10:44 PM, Sergey Bylokhov wrote:
On 28.10.16 12:35, Semyon Sadetsky wrote:
Probably this clipping should be done in the
 633             paintText(ss, g, tabPlacement, font, metrics,
634 tabIndex, clippedTitle, textRect, isSelected);
?
It should be designed in the same way as in basic class. Currently the
BasicTabbedPaneUI#paintText() receives pre-clipped text to paint and the
clipping is executed in the paintTab().
It seems that currently this method contradicts its specification and
skips the w/h of the passed bounds(in this case "textRect").
I don't see any mentions of text clipping in this spec.

SynthGraphicsUtils.java
     * @param bounds Bounds of the text to be drawn.h
     * @param mnemonicIndex Index to draw string at.
     */
    public void paintText(SynthContext ss, Graphics g, String text,
                          Rectangle bounds, int mnemonicIndex) {
....

The textRect variable which is calculated in the changed method and
passed to paintText() is "Bounds of the text to be drawn". The method
violates its specification and ignores w/h of these bounds. So the
text is painted outside of the Tab.
Anyway it doesn't say do clip.

The bounds to which the text should be drawn mean that the "paint" should not draw outside of this area(this area should be used as a clip). This bug is also affects the Icons in tabpain which also ignore these bounds and paints outside of the tab area.
Anyway this is not related to the text clipping. To take these bounds into account Graphics.setClip() may be used. And SynthGraphicsUtils#paintText(SynthContext ss, Graphics g, String Rectangle bounds, int mnemonicIndex) cannot do text clip, because it is also called from SynthGraphicsUtils#paintText(SynthContext ss, Graphics g, String Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex, int textOffset) which does clip as well. So, the text will be clipped twice. In all other L&Fs this is solved in the same way. There is no need to change anything here with fixing a minor problem. It just doesn't make any sense.

Adding clipping to this method would be a mistake because in this case
the text may be clipped twice.


On 21.10.16 15:12, Semyon Sadetsky wrote:
Hello,

Please review fix for JDK9:

bug: https://bugs.openjdk.java.net/browse/JDK-8075918

webrev: http://cr.openjdk.java.net/~ssadetsky/8075918/webrev.00/

Title text clipping capability is added to the Synth L&F's tabbed pane
UI to fix the issue.










Reply via email to