<Swing Dev> [13] RFR JDK-8213535:Windows HiDPI html lightweight tooltips are truncated
Prasanta Sadhukhan
prasanta.sadhukhan at oracle.com
Mon Apr 6 12:07:08 UTC 2020
On 06-Apr-20 12:26 PM, Sergey Bylokhov wrote:
> On 4/5/20 11:08 pm, Prasanta Sadhukhan wrote:
>>
>> On 05-Apr-20 10:29 AM, Sergey Bylokhov wrote:
>>> On 4/2/20 8:59 pm, Prasanta Sadhukhan wrote:
>>>
>>>>> If we GC is correct in reset/pack step, but the View calculate
>>>>> wrong size(and update it only after "graphicsConfiguration"
>>>>> property change) means that we calculate the size of the View
>>>>> using wrong GC, why?
>>>>
>>>> It's not the size of View, it's the preferredSize that is wrong.
>>>> This is because tip's GC is null before the tip is shown, so View's
>>>> span is calculated accordingly. Only when View isupdated when
>>>> "graphicsConfiguration" is fired, then Tooltip GC is updated and
>>>> preferredSpan is calculated correctly.
>>>>
>>>> It's to be remembered that the issue happens only when html text is
>>>> shown in ToolTip. If normal text is shown , there is no issue. I
>>>> guess if it's a question of wrong GC during popup reset/pack, then
>>>> it will cause problem during normal text rendering also, no?
>>>
>>> If GC of the tip is null before showing then can we use default
>>> screen GC by default? Same as in the java.awt.Window.initGC().
>>
>> I tried but SwingUtilities.windowForComponent(tip) returns null so
>> there is no "Window" parent associated with tooltip so initGC()
>> cannot be called on tip, as I see.
>>
>> Also, tip GC is null for normal text too, where it works. Only
>> difference between normal and html text is in calculation of
>> getPreferredSize/MaximumSize/MinimumSize where the size is updated
>> based on updated span calculation, so I have used updated
>> preferredSize in my fix.
>
> The normal text may work because the text and font metrics produce the
> "correct" size which is not changed on the scaled screen, while the
> HTML produce different size depending on the font metrics. Note that
> you should not call Window.initGC() but use the similar logic
> somewhere in the code which initialize/show tip.
I tried similar logic in ToolTipManager when the tip is created but to
no effect. Even though BasicHTML.updateRenderer() is called but
preferredSize is not updated, since JTooltip width/height was coming as
0x0 in BasicToolTipUI#propertyChange()
tip = insideComponent.createToolTip();
tip.setTipText(toolTipText);
+
+ System.out.println("default gc " + gc.getDefaultTransform());
+ System.out.println("insideComponent GC " +
insideComponent.getGraphicsConfiguration().getDefaultTransform());
+ GraphicsConfiguration oldConfig =
tip.getGraphicsConfiguration();
+ System.out.println("tip oldgc " +
tip.getGraphicsConfiguration());
+ GraphicsConfiguration newConfig =
tip.getGraphicsConfiguration();
+ if (newConfig == null) {
+ newConfig =
GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice().getDefaultConfiguration();
+ }
+ System.out.println("newgc " + newConfig);
+ if (newConfig != null) System.out.println(" transform " +
newConfig.getDefaultTransform());
+ tip.firePropertyChange("graphicsConfiguration", oldConfig,
newConfig);
+
+
size = tip.getPreferredSize();
+ System.out.println("tip preferredsize " + size);
if(preferredLocation != null) {
location = toFind;
>
>
More information about the swing-dev
mailing list