You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Chunrong Lai (JIRA)" <ji...@apache.org> on 2007/09/16 18:01:32 UTC

[jira] Created: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

[classlib][awt] GetRenderingHint returns Null by default
--------------------------------------------------------

                 Key: HARMONY-4799
                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
             Project: Harmony
          Issue Type: Sub-task
          Components: Classlib
         Environment: Win32 + Linux32
            Reporter: Chunrong Lai



 Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.

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

public class TestMenu extends JFrame { 
 JMenuBar myMenu = new JMenuBar(); 
 CubeMenu mFile = new CubeMenu(); 
 JMenuItem miClose = new JMenuItem(); 

 public TestMenu() { 
  this.setJMenuBar(myMenu); 
  mFile.setText("File"); 
  myMenu.add(mFile); 
  miClose.setText("Close"); 
  mFile.add(miClose); 
  miClose.addActionListener(new ActionListener() { 
   public void actionPerformed(ActionEvent e) { 
    dispose(); 
    System.exit(0); 
   } 
  }); 
  this.setTitle("JAVA"); 
  this.setSize(new Dimension(400, 300)); 
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
  this.show(); 
 } 

 public static void main(String[] args) { 
  TestMenu testmenu = new TestMenu(); 
 } 
} 

class CubeMenu extends JMenu { 
 protected final void paintComponent(Graphics g) { 
  Graphics2D graphics = (Graphics2D) g; 
  Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
  if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
  graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
  super.paintComponent(graphics); 
  graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
 } 
} 



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Andrey Pavlenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrey Pavlenko updated HARMONY-4799:
-------------------------------------

    Attachment: HARMONY-4799-Graphics2DTest.patch
                HARMONY-4799-CommonGraphics2D.patch

Chunrong, I've added 3 default properties to the rendering hints table. Could you please try this patch?

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530395 ] 

Chunrong Lai commented on HARMONY-4799:
---------------------------------------


 The patch does fix the reproducer but does not really fix the issue.
 The set DEFAULT_RENDERING_HINTS may be clear some time later, for example, by setRenderingHints, so we may still meet same NullPointerException.

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530438 ] 

Chunrong Lai commented on HARMONY-4799:
---------------------------------------


 Firstly I want to say that the patch does eliminate most of the exceptions.
 Secondly I want to say sometimes I can still see the exceptions.
  Thirdly I want to say I see following code in CommonGraphics2D.java and think the clear() may remove the whole DEFAULT_RENDERING_HINTS in this.hints().

    protected RenderingHints hints = new RenderingHints(DEFAULT_RENDERING_HINTS);

    public void setRenderingHints(Map<?,?> hints) {
        this.hints.clear();
        this.hints.putAll(hints);
    }

 If I am wrong please correct me.

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Andrey Pavlenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12528734 ] 

Andrey Pavlenko commented on HARMONY-4799:
------------------------------------------

Verified

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko closed HARMONY-4799.
------------------------------------


> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko resolved HARMONY-4799.
--------------------------------------

    Resolution: Fixed

The patch has been applied.
Please verify.

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Andrey Pavlenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530399 ] 

Andrey Pavlenko commented on HARMONY-4799:
------------------------------------------

Chunrung, the map DEFAULT_RENDERING_HINTS could not be modified with setRenderingHints. For assurance I could make the map DEFAULT_RENDERING_HINTS unmodifiable, but I don't see where it could be modified. 

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530439 ] 

Alexey Petrenko commented on HARMONY-4799:
------------------------------------------

Hm... Good catch...
Looks like we need additional pacth.

Thanks, Chunrong.

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Andrey Pavlenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530456 ] 

Andrey Pavlenko commented on HARMONY-4799:
------------------------------------------

I've just checked on RI - setRenderingHints() does not clear old hints, but Harmony does. I think there was misunderstanding of the spec:

---cut---
Replaces the values of all preferences for the rendering algorithms with the specified hints. The existing values for all rendering hints are discarded and the new set of known hints and values are initialized from the specified Map object. ...
---cut---

As the below test demonstrates "The existing values for all rendering hints are discarded " means that the rendering hints should be reset to default, but not cleared! I'll open a new JIRA for this issue and create a patch for setRenderingHints().

Chunrong, thanks!

Here is the test:

        Frame f = new Frame() {
			public void paint(Graphics g) {
				Graphics2D g2d = (Graphics2D) g;

				System.out
						.println(g2d
								.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING));
				System.out
						.println(g2d
								.getRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION));

				g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
						RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
				g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
						RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
				System.out
						.println(g2d
								.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING));
				System.out
						.println(g2d
								.getRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION));

				g2d.setRenderingHints(Collections.EMPTY_MAP);
				System.out
						.println(g2d
								.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING));
				System.out
						.println(g2d
								.getRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION));
			}
		};

		f.setSize(100, 100);
		f.setVisible(true);

Output:
Default antialiasing text mode
null
Nonantialiased text mode
Default alpha blending methods
Default antialiasing text mode
null


> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Andrey Pavlenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533649 ] 

Andrey Pavlenko commented on HARMONY-4799:
------------------------------------------

Chunrong, could you please take a look at the fix of HARMONY-4920? Is the fix sufficient?

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Andrey Pavlenko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12528276 ] 

Andrey Pavlenko commented on HARMONY-4799:
------------------------------------------

Chunrong, why do you think getRenderingHint() should not return null? For example, RI also returns null for RenderingHints.KEY_ALPHA_INTERPOLATION. I think your example is not quite correct because, as I think, applications should check that the value is valid before calling setRenderingHint().

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12528281 ] 

Chunrong Lai commented on HARMONY-4799:
---------------------------------------


 I am also OK with the approach that askes every application to check the RenderingHint before set back, while just keep Harmony as it is.
 But please note there are tons of legacy code doing actions of getRenderingHint-Drawing with another RenderingHint-Set back the RenderingHint, at least for KEY_TEXT_ANTIALIASING. (So you see RI pass this reproducer without problem)
 It is not strong enough to change the legacy applications based on our not-so-strong argument. 

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko reassigned HARMONY-4799:
----------------------------------------

    Assignee: Alexey Petrenko

> [classlib][awt] GetRenderingHint returns Null by default
> --------------------------------------------------------
>
>                 Key: HARMONY-4799
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4799
>             Project: Harmony
>          Issue Type: Sub-task
>          Components: Classlib
>         Environment: Win32 + Linux32
>            Reporter: Chunrong Lai
>            Assignee: Alexey Petrenko
>         Attachments: HARMONY-4799-CommonGraphics2D.patch, HARMONY-4799-Graphics2DTest.patch
>
>
>  Below is the simple reproducer.  Such codes are common to do customized-redrawing of components.
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> public class TestMenu extends JFrame { 
>  JMenuBar myMenu = new JMenuBar(); 
>  CubeMenu mFile = new CubeMenu(); 
>  JMenuItem miClose = new JMenuItem(); 
>  public TestMenu() { 
>   this.setJMenuBar(myMenu); 
>   mFile.setText("File"); 
>   myMenu.add(mFile); 
>   miClose.setText("Close"); 
>   mFile.add(miClose); 
>   miClose.addActionListener(new ActionListener() { 
>    public void actionPerformed(ActionEvent e) { 
>     dispose(); 
>     System.exit(0); 
>    } 
>   }); 
>   this.setTitle("JAVA"); 
>   this.setSize(new Dimension(400, 300)); 
>   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
>   this.show(); 
>  } 
>  public static void main(String[] args) { 
>   TestMenu testmenu = new TestMenu(); 
>  } 
> } 
> class CubeMenu extends JMenu { 
>  protected final void paintComponent(Graphics g) { 
>   Graphics2D graphics = (Graphics2D) g; 
>   Object oldHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); 
>   if (oldHint == null) System.out.println("Will have IllegalArgumentException in later setRenderingHint");
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 
>   super.paintComponent(graphics); 
>   graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHint); 
>  } 
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.