harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrey Pavlenko (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-4799) [classlib][awt] GetRenderingHint returns Null by default
Date Wed, 26 Sep 2007 14:48:50 GMT

    [ 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.


Mime
View raw message