Re: Review Request of 8146321: [macosx] JInternalFrame frame icon in wrong position on Mac L&F if icon is not ImageIcon

2016-02-03 Thread Avik Niyogi
Hi All,
Please review the code changes made as per the inputs provided:
http://cr.openjdk.java.net/~aniyogi/8146321/webrev.05/ 


With Regards,
Avik Niyogi

> On 03-Feb-2016, at 7:38 pm, Alexandr Scherbatiy 
>  wrote:
> 
> On 2/3/2016 12:47 AM, Avik Niyogi wrote:
>> Hi All,
>> Please review the code changes made as per the inputs provided:
>> http://cr.openjdk.java.net/~aniyogi/8146321/webrev.04 
>>   326 
>> g2.translate(0, 0);
>   The translation to the zero vector leaves the coordinate system the same.
> 
>   327 float xScaleFactor = (float) sMaxIconWidth / 
> icon.getIconWidth();
>   It is better to use double values because the graphics transform methods 
> use them.
> 
>   332 g2.scale(scaleFactorAspectRatio, scaleFactorAspectRatio);
>   333 g2.translate(x / scaleFactorAspectRatio, y / 
> scaleFactorAspectRatio);
>   Is it possible to use the translation first and the scale the second? I 
> this case where no need to re-scale translation coordinates.
> 
>   Thanks,
>   Alexandr.
> 
>> 
>> With Regards,
>> Avik Niyogi
>>> On 02-Feb-2016, at 5:55 pm, Alexandr Scherbatiy 
>>> mailto:alexandr.scherba...@oracle.com>> 
>>> wrote:
>>> 
>>> On 2/2/2016 3:41 AM, Avik Niyogi wrote:
 Hi Alexander,
 
> On 02-Feb-2016, at 3:44 pm, Alexandr Scherbatiy < 
> alexandr.scherba...@oracle.com 
> > wrote:
> 
> On 2/2/2016 1:50 AM, Avik Niyogi wrote:
>> Hi All,
>> Please review the code changes made as per the inputs provided:
>> cr.openjdk.java.net/~aniyogi/8146321/webrev.03 
>> 
>  -  Will it work with custom implementation of the Icon interface which 
> just draws an image?
>   For example:
>  --
>  public class DukeIcon implements Icon {
> 
> private BufferedImage dukeImage;
> 
> public DukeIcon() throws IOException {
> dukeImage = ImageIO.read(new File(""));
> }
> 
> @Override
> public void paintIcon(Component c, Graphics g, int x, int y) {
> g.drawImage(dukeImage, x, y, c);
> }
> 
> @Override
> public int getIconWidth() {
> return dukeImage.getWidth();
> }
> 
> @Override
> public int getIconHeight() {
> return dukeImage.getHeight();
> }
> }
 
 This is a limitation for custom Icons because they will need to use toe 
 drawImage with appropriate implementation.
 To fix that will be a major change and may need change in the 
 implementation of drawImage method.
>>> 
>>>   It looks like the code below from the fix doesn't work for the ImageIcon 
>>> because x and y are now scaled. Is it possible to apply some other 
>>> transformations (may be some translations) to the graphics to draw the 
>>> image at the right position?
>>> ---
>>>  334 g2.scale((float) sMaxIconWidth / icon.getIconWidth(),
>>>  335 (float) sMaxIconWidth / icon.getIconHeight());
>>>  336 icon.paintIcon(frame, g2, x, y);
>>> ---
> --
> 
> - "(icon != null && (icon instanceof Icon))"
>   Could the check to null also be omitted here?
>   In other words, are the "(icon != null && (icon instanceof Icon))" and 
> "(icon instanceof Icon)" checks return the same result?
> 
 If we remove the check, the cases where custom ImageIcon have no images 
 will fail.
>>> 
>>> The provided example  should work with the check: "(icon instanceof 
>>> Icon)" in the same way as with the check "(icon != null && (icon instanceof 
>>> Icon))" because the used icon is not null and it implements Icon interface, 
>>> should not it?
>>> 
>>>  Thanks,
>>>  Alexandr.
>>> 
 Example:
 
 
 import java.awt.*;
 import javax.swing.*;
 
 public class JInternalFrameBug {
 
public static void main(String[] args) {
   SwingUtilities.invokeLater(
 new Runnable() {
public void run() {
   try {
  
 UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel"); }
   catch(Exception e) {
  System.out.println("This is not a Mac.");
  return;
   }
   JFrame f = new JFrame();
   f.setSize(500, 500);
   JDesktopPane dtp = new JDesktopPane();
   JInternalFrame jif = new JInternalFrame();
   jif.setTitle("Test");
   jif.setFrameIcon(
 new ImageIcon() {

Review Request for 8062946 : Transparent JDialog will lose transparency upon iconify/deiconify sequence.

2016-02-03 Thread Prem Balakrishnan
Hi ,

Sorry my mistake. 

Bug id in subject corrected 8062946.

 

Regards,
Prem

 

From: Alexandr Scherbatiy 
Sent: Wednesday, February 03, 2016 8:44 PM
To: Prem Balakrishnan; Ambarish Rapte; Semyon Sadetsky; Sergey Bylokhov; Rajeev 
Chamyal; swing-dev@openjdk.java.net; awt-...@openjdk.java.net
Subject: Re: Review Request for 8062846 : Transparent JDialog will lose 
transparency upon iconify/deiconify sequence.

 


I just notice that the bug number in the subject 8062846 points to the 
different issue.

Could you resend the same fix the the correct bug id in the subject?

Thanks,
Alexandr.

On 2/2/2016 3:00 AM, Prem Balakrishnan wrote:

Hi Ambarish,

 

Updated test .

Webrev: http://cr.openjdk.java.net/~arapte/prem/8062946/webrev.01/

 

Regards,
Prem

 

 

From: Ambarish Rapte 
Sent: Tuesday, February 02, 2016 2:47 PM
To: Alexander Scherbatiy; Prem Balakrishnan; Semyon Sadetsky; Sergey Bylokhov; 
Rajeev Chamyal; HYPERLINK 
"mailto:swing-dev@openjdk.java.net"swing-dev@openjdk.java.net; HYPERLINK 
"mailto:awt-...@openjdk.java.net"awt-...@openjdk.java.net
Subject: RE: Review Request for 8062846 : Transparent JDialog will lose 
transparency upon iconify/deiconify sequence.

 

Hi Prem,

The test passes without including the fix.

The test should fail without fix, and should pass with fix.

 

Thanks,

Ambarish

 

From: Alexandr Scherbatiy 
Sent: Monday, February 01, 2016 5:15 PM
To: Prem Balakrishnan; Semyon Sadetsky; Sergey Bylokhov; Ambarish Rapte; Rajeev 
Chamyal; HYPERLINK 
"mailto:swing-dev@openjdk.java.net"swing-dev@openjdk.java.net; HYPERLINK 
"mailto:awt-...@openjdk.java.net"awt-...@openjdk.java.net
Subject: Re: Review Request for 8062846 : Transparent JDialog will lose 
transparency upon iconify/deiconify sequence.

 


  The fix looks good to me.

  Thanks,
  Alexandr.

On 1/28/2016 9:45 PM, Prem Balakrishnan wrote:

Hi,

Please review fix for JDK9,

Bug: https://bugs.openjdk.java.net/browse/JDK-8062946 

Webrev: HYPERLINK 
"http://cr.openjdk.java.net/%7Earapte/prem/8062946/webrev.00/"http://cr.openjdk.java.net/~arapte/prem/8062946/webrev.00/

 

Issue:

Transparent JDialog will lose transparency upon iconify/deiconify sequence.

 

Cause:

Regression: due to 6780496: Javaw process taking up 80-90 percent of CPU time!

https://bugs.openjdk.java.net/browse/JDK-6780496 

Intentionally when JDialog is iconified transparency is disabled, 

And transparency is not enabled when JDialog is deiconified.

 

Fix:

Transparency is enabled when JDialog is deiconified.

 

Regards,
Prem

 

 


Re: Review Request of 8146321: [macosx] JInternalFrame frame icon in wrong position on Mac L&F if icon is not ImageIcon

2016-02-03 Thread Sergey Bylokhov

On 02.02.16 15:25, Alexandr Scherbatiy wrote:

 The provided example  should work with the check: "(icon instanceof
Icon)" in the same way as with the check "(icon != null && (icon
instanceof Icon))" because the used icon is not null and it implements
Icon interface, should not it?


Note that "icon instanceof Icon" in "(icon != null && (icon instanceof 
Icon))" is unnecessary because icon is Icon already. Only null check is 
necessary.


--
Best regards, Sergey.


Re: Review Request for 8062846 : Transparent JDialog will lose transparency upon iconify/deiconify sequence.

2016-02-03 Thread Alexandr Scherbatiy


I just notice that the bug number in the subject 8062846 points to the 
different issue.


Could you resend the same fix the the correct bug id in the subject?

Thanks,
Alexandr.

On 2/2/2016 3:00 AM, Prem Balakrishnan wrote:


Hi Ambarish,

Updated test .

Webrev: http://cr.openjdk.java.net/~arapte/prem/8062946/webrev.01/ 



Regards,
Prem

*From:*Ambarish Rapte
*Sent:* Tuesday, February 02, 2016 2:47 PM
*To:* Alexander Scherbatiy; Prem Balakrishnan; Semyon Sadetsky; Sergey 
Bylokhov; Rajeev Chamyal; swing-dev@openjdk.java.net; 
awt-...@openjdk.java.net
*Subject:* RE: Review Request for 8062846 : Transparent JDialog will 
lose transparency upon iconify/deiconify sequence.


Hi Prem,

The test passes without including the fix.

The test should fail without fix, and should pass with fix.

Thanks,

Ambarish

*From:*Alexandr Scherbatiy
*Sent:* Monday, February 01, 2016 5:15 PM
*To:* Prem Balakrishnan; Semyon Sadetsky; Sergey Bylokhov; Ambarish 
Rapte; Rajeev Chamyal; swing-dev@openjdk.java.net 
; awt-...@openjdk.java.net 

*Subject:* Re: Review Request for 8062846 : Transparent JDialog will 
lose transparency upon iconify/deiconify sequence.



  The fix looks good to me.

  Thanks,
  Alexandr.

On 1/28/2016 9:45 PM, Prem Balakrishnan wrote:

Hi*,*

Please review fix for JDK9,

*Bug: *https://bugs.openjdk.java.net/browse/JDK-8062946**

*Webrev:
*http://cr.openjdk.java.net/~arapte/prem/8062946/webrev.00/


Issue:

Transparent JDialog will lose transparency upon iconify/deiconify
sequence.

*Cause:*

Regression: due to 6780496: Javaw process taking up 80-90 percent
of CPU time!

https://bugs.openjdk.java.net/browse/JDK-6780496

Intentionally when JDialog is iconified transparency is disabled,

And transparency is not enabled when JDialog is deiconified.

*Fix:*

Transparency is enabled when JDialog is deiconified.

Regards,
Prem





Re: Review Request of 8146321: [macosx] JInternalFrame frame icon in wrong position on Mac L&F if icon is not ImageIcon

2016-02-03 Thread Alexandr Scherbatiy

On 2/3/2016 12:47 AM, Avik Niyogi wrote:

Hi All,
Please review the code changes made as per the inputs provided:
http://cr.openjdk.java.net/~aniyogi/8146321/webrev.04 


  326 g2.translate(0, 0);
  The translation to the zero vector leaves the coordinate system the same.

  327 float xScaleFactor = (float) sMaxIconWidth / 
icon.getIconWidth();
  It is better to use double values because the graphics transform 
methods use them.


  332 g2.scale(scaleFactorAspectRatio, scaleFactorAspectRatio);
  333 g2.translate(x / scaleFactorAspectRatio, y / 
scaleFactorAspectRatio);
  Is it possible to use the translation first and the scale the second? 
I this case where no need to re-scale translation coordinates.


  Thanks,
  Alexandr.



With Regards,
Avik Niyogi
On 02-Feb-2016, at 5:55 pm, Alexandr Scherbatiy 
> wrote:


On 2/2/2016 3:41 AM, Avik Niyogi wrote:

Hi Alexander,

On 02-Feb-2016, at 3:44 pm, Alexandr Scherbatiy 
> wrote:


On 2/2/2016 1:50 AM, Avik Niyogi wrote:

Hi All,
Please review the code changes made as per the inputs provided:
cr.openjdk.java.net/~aniyogi/8146321/webrev.03 



 -  Will it work with custom implementation of the Icon interface 
which just draws an image?

  For example:
 --
 public class DukeIcon implements Icon {

private BufferedImage dukeImage;

public DukeIcon() throws IOException {
dukeImage = ImageIO.read(new File(""));
}

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.drawImage(dukeImage, x, y, c);
}

@Override
public int getIconWidth() {
return dukeImage.getWidth();
}

@Override
public int getIconHeight() {
return dukeImage.getHeight();
}
}


This is a limitation for custom Icons because they will need to use 
toe drawImage with appropriate implementation.
To fix that will be a major change and may need change in the 
implementation of drawImage method.


  It looks like the code below from the fix doesn't work for the 
ImageIcon because x and y are now scaled. Is it possible to apply 
some other transformations (may be some translations) to the graphics 
to draw the image at the right position?

---
 334 g2.scale((float) sMaxIconWidth / 
icon.getIconWidth(),
 335 (float) sMaxIconWidth / 
icon.getIconHeight());

 336 icon.paintIcon(frame, g2, x, y);
---

--

- "(icon != null && (icon instanceof Icon))"
  Could the check to null also be omitted here?
  In other words, are the "(icon != null && (icon instanceof 
Icon))" and "(icon instanceof Icon)" checks return the same result?


If we remove the check, the cases where custom ImageIcon have no 
images will fail.


The provided example  should work with the check: "(icon 
instanceof Icon)" in the same way as with the check "(icon != null && 
(icon instanceof Icon))" because the used icon is not null and it 
implements Icon interface, should not it?


 Thanks,
 Alexandr.


Example:


import java.awt.*;
import javax.swing.*;

public class JInternalFrameBug {

   public static void main(String[] args) {
  SwingUtilities.invokeLater(
new Runnable() {
   public void run() {
  try {
 UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel"); }
  catch(Exception e) {
 System.out.println("This is not a Mac.");
 return;
  }
  JFrame f = new JFrame();
  f.setSize(500, 500);
  JDesktopPane dtp = new JDesktopPane();
  JInternalFrame jif = new JInternalFrame();
jif.setTitle("Test");
  jif.setFrameIcon(
new ImageIcon() {
   public int getIconWidth() {
  return 16;
   }
   public int getIconHeight() {
  return 16;
   }
   public void paintIcon(Component c, 
Graphics g, int x, int y) {

g.setColor(java.awt.Color.green);
g.fillRect(x, y, 16, 16);
   }
});
  jif.setSize(400, 400);
jif.setVisible(true);
  dtp.add(jif);

f.getContentPane().setLayout(new BorderLayout());
f.getContentPane().add(dtp, "Center");
f.setVisible(true);
   }
});
   }
}


  Thanks,
  Alexandr.



With Regards,
Avik Niyogi
On 02-Feb-2016, at 3:02 pm, Alexandr Scherbatiy 
 wrote:


On 2/1/2016 11:25 PM, Avik Niyogi wrote:

Hi All,
Please review the code changes made as per inputs provided:
cr.openjdk.java.net/~aniyogi/8146321/webrev.02 
<

Re: Review Request for 8062846 : Transparent JDialog will lose transparency upon iconify/deiconify sequence.

2016-02-03 Thread Ambarish Rapte
Hi Prem,

Thanks for updating the test, Fix looks fine to me.

 

 

Thanks,

Ambarish

 

From: Prem Balakrishnan 
Sent: Tuesday, February 02, 2016 4:31 PM
To: Ambarish Rapte; Alexander Scherbatiy; Semyon Sadetsky; Sergey Bylokhov; 
Rajeev Chamyal; swing-dev@openjdk.java.net; awt-...@openjdk.java.net
Subject: RE: Review Request for 8062846 : Transparent JDialog will lose 
transparency upon iconify/deiconify sequence.

 

Hi Ambarish,

 

Updated test .

Webrev: http://cr.openjdk.java.net/~arapte/prem/8062946/webrev.01/

 

Regards,
Prem

 

 

From: Ambarish Rapte 
Sent: Tuesday, February 02, 2016 2:47 PM
To: Alexander Scherbatiy; Prem Balakrishnan; Semyon Sadetsky; Sergey Bylokhov; 
Rajeev Chamyal; HYPERLINK 
"mailto:swing-dev@openjdk.java.net"swing-dev@openjdk.java.net; HYPERLINK 
"mailto:awt-...@openjdk.java.net"awt-...@openjdk.java.net
Subject: RE: Review Request for 8062846 : Transparent JDialog will lose 
transparency upon iconify/deiconify sequence.

 

Hi Prem,

The test passes without including the fix.

The test should fail without fix, and should pass with fix.

 

Thanks,

Ambarish

 

From: Alexandr Scherbatiy 
Sent: Monday, February 01, 2016 5:15 PM
To: Prem Balakrishnan; Semyon Sadetsky; Sergey Bylokhov; Ambarish Rapte; Rajeev 
Chamyal; HYPERLINK 
"mailto:swing-dev@openjdk.java.net"swing-dev@openjdk.java.net; HYPERLINK 
"mailto:awt-...@openjdk.java.net"awt-...@openjdk.java.net
Subject: Re: Review Request for 8062846 : Transparent JDialog will lose 
transparency upon iconify/deiconify sequence.

 


  The fix looks good to me.

  Thanks,
  Alexandr.

On 1/28/2016 9:45 PM, Prem Balakrishnan wrote:

Hi,

Please review fix for JDK9,

Bug: https://bugs.openjdk.java.net/browse/JDK-8062946 

Webrev: HYPERLINK 
"http://cr.openjdk.java.net/%7Earapte/prem/8062946/webrev.00/"http://cr.openjdk.java.net/~arapte/prem/8062946/webrev.00/

 

Issue:

Transparent JDialog will lose transparency upon iconify/deiconify sequence.

 

Cause:

Regression: due to 6780496: Javaw process taking up 80-90 percent of CPU time!

https://bugs.openjdk.java.net/browse/JDK-6780496 

Intentionally when JDialog is iconified transparency is disabled, 

And transparency is not enabled when JDialog is deiconified.

 

Fix:

Transparency is enabled when JDialog is deiconified.

 

Regards,
Prem

 


Re: Review Request of 8146321: [macosx] JInternalFrame frame icon in wrong position on Mac L&F if icon is not ImageIcon

2016-02-03 Thread Avik Niyogi
Hi All,
Please review the code changes made as per the inputs provided:
http://cr.openjdk.java.net/~aniyogi/8146321/webrev.04 


With Regards,
Avik Niyogi
> On 02-Feb-2016, at 5:55 pm, Alexandr Scherbatiy 
>  wrote:
> 
> On 2/2/2016 3:41 AM, Avik Niyogi wrote:
>> Hi Alexander,
>> 
>>> On 02-Feb-2016, at 3:44 pm, Alexandr Scherbatiy 
>>> mailto:alexandr.scherba...@oracle.com>> 
>>> wrote:
>>> 
>>> On 2/2/2016 1:50 AM, Avik Niyogi wrote:
 Hi All,
 Please review the code changes made as per the inputs provided:
 cr.openjdk.java.net/~aniyogi/8146321/webrev.03 
 
>>>  -  Will it work with custom implementation of the Icon interface which 
>>> just draws an image?
>>>   For example:
>>>  --
>>>  public class DukeIcon implements Icon {
>>> 
>>> private BufferedImage dukeImage;
>>> 
>>> public DukeIcon() throws IOException {
>>> dukeImage = ImageIO.read(new File(""));
>>> }
>>> 
>>> @Override
>>> public void paintIcon(Component c, Graphics g, int x, int y) {
>>> g.drawImage(dukeImage, x, y, c);
>>> }
>>> 
>>> @Override
>>> public int getIconWidth() {
>>> return dukeImage.getWidth();
>>> }
>>> 
>>> @Override
>>> public int getIconHeight() {
>>> return dukeImage.getHeight();
>>> }
>>> }
>> 
>> This is a limitation for custom Icons because they will need to use toe 
>> drawImage with appropriate implementation.
>> To fix that will be a major change and may need change in the implementation 
>> of drawImage method.
> 
>   It looks like the code below from the fix doesn't work for the ImageIcon 
> because x and y are now scaled. Is it possible to apply some other 
> transformations (may be some translations) to the graphics to draw the image 
> at the right position?
> ---
>  334 g2.scale((float) sMaxIconWidth / icon.getIconWidth(),
>  335 (float) sMaxIconWidth / icon.getIconHeight());
>  336 icon.paintIcon(frame, g2, x, y);
> ---
>>> --
>>> 
>>> - "(icon != null && (icon instanceof Icon))"
>>>   Could the check to null also be omitted here?
>>>   In other words, are the "(icon != null && (icon instanceof Icon))" and 
>>> "(icon instanceof Icon)" checks return the same result?
>>> 
>> If we remove the check, the cases where custom ImageIcon have no images will 
>> fail.
> 
> The provided example  should work with the check: "(icon instanceof 
> Icon)" in the same way as with the check "(icon != null && (icon instanceof 
> Icon))" because the used icon is not null and it implements Icon interface, 
> should not it?
> 
>  Thanks,
>  Alexandr.
> 
>> Example:
>> 
>> 
>> import java.awt.*;
>> import javax.swing.*;
>> 
>> public class JInternalFrameBug {
>> 
>>public static void main(String[] args) {
>>   SwingUtilities.invokeLater(
>> new Runnable() {
>>public void run() {
>>   try {
>>  
>> UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel"); }
>>   catch(Exception e) {
>>  System.out.println("This is not a Mac.");
>>  return;
>>   }
>>   JFrame f = new JFrame();
>>   f.setSize(500, 500);
>>   JDesktopPane dtp = new JDesktopPane();
>>   JInternalFrame jif = new JInternalFrame();
>>   jif.setTitle("Test");
>>   jif.setFrameIcon(
>> new ImageIcon() {
>>public int getIconWidth() {
>>   return 16;
>>}
>>public int getIconHeight() {
>>   return 16;
>>}
>>public void paintIcon(Component c, Graphics g, 
>> int x, int y) {
>>   g.setColor(java.awt.Color.green);
>>   g.fillRect(x, y, 16, 16);
>>}
>> });
>>   jif.setSize(400, 400);
>>   jif.setVisible(true);
>>   dtp.add(jif);
>> 
>>   f.getContentPane().setLayout(new BorderLayout());
>>   f.getContentPane().add(dtp, "Center");
>>   f.setVisible(true);
>>}
>> });
>>}
>> }
>> 
>>>   Thanks,
>>>   Alexandr.
>>> 
 
 With Regards,
 Avik Niyogi
> On 02-Feb-2016, at 3:02 pm, Alexandr Scherbatiy < 
> alexandr.scherba...@oracle.com 
> > wrote:
> 
> On 2/1/2016 11:25 PM, Avik Niyogi wrote:
>> Hi All,
>> Please review the code changes made as per inputs provided: