harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r584812 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java test/api/java/common/java/awt/Graphics2DTest.java
Date Mon, 15 Oct 2007 16:10:10 GMT
Author: ayza
Date: Mon Oct 15 09:10:09 2007
New Revision: 584812

URL: http://svn.apache.org/viewvc?rev=584812&view=rev
Log:
The patch from HARMONY-4920 ([classlib][awt] Graphics2D.setRenderingHints() does not restore
defaults) was applied.

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/Graphics2DTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java?rev=584812&r1=584811&r2=584812&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
Mon Oct 15 09:10:09 2007
@@ -55,6 +55,7 @@
 import java.awt.image.WritableRaster;
 import java.awt.image.renderable.RenderableImage;
 import java.text.AttributedCharacterIterator;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -129,13 +130,16 @@
 	private static final Map<RenderingHints.Key, Object> DEFAULT_RENDERING_HINTS;
 
 	static {
-		DEFAULT_RENDERING_HINTS = new HashMap<RenderingHints.Key, Object>();
-		DEFAULT_RENDERING_HINTS.put(RenderingHints.KEY_TEXT_ANTIALIASING,
+		final Map<RenderingHints.Key, Object> m = new HashMap<RenderingHints.Key, Object>();
+
+		m.put(RenderingHints.KEY_TEXT_ANTIALIASING,
 				RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
-		DEFAULT_RENDERING_HINTS.put(RenderingHints.KEY_ANTIALIASING,
+		m.put(RenderingHints.KEY_ANTIALIASING,
 				RenderingHints.VALUE_ANTIALIAS_OFF);
-		DEFAULT_RENDERING_HINTS.put(RenderingHints.KEY_STROKE_CONTROL,
+		m.put(RenderingHints.KEY_STROKE_CONTROL,
 				RenderingHints.VALUE_STROKE_DEFAULT);
+
+		DEFAULT_RENDERING_HINTS = Collections.unmodifiableMap(m);
 	}
 	
     protected Surface dstSurf = null;
@@ -966,6 +970,7 @@
     @Override
     public void setRenderingHints(Map<?,?> hints) {
         this.hints.clear();
+        this.hints.putAll(DEFAULT_RENDERING_HINTS);
         this.hints.putAll(hints);
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/Graphics2DTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/Graphics2DTest.java?rev=584812&r1=584811&r2=584812&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/Graphics2DTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/Graphics2DTest.java
Mon Oct 15 09:10:09 2007
@@ -18,6 +18,8 @@
 package java.awt;
 
 import java.awt.image.BufferedImage;
+import java.util.HashMap;
+import java.util.Map;
 
 import junit.framework.TestCase;
 
@@ -68,5 +70,27 @@
 				RenderingHints.VALUE_ANTIALIAS_OFF);
 		assertEquals(g2d.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL),
 				RenderingHints.VALUE_STROKE_DEFAULT);
+	}
+    
+    public void testSetRenderingHint() {
+		// Regression test for HARMONY-4920
+		final Graphics2D g2d = (Graphics2D) frame.getGraphics();
+		final Map<RenderingHints.Key, Object> m = new HashMap<RenderingHints.Key, Object>();
+
+		m.put(RenderingHints.KEY_ALPHA_INTERPOLATION,
+				RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+		m.put(RenderingHints.KEY_TEXT_ANTIALIASING,
+				RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
+
+		g2d.setRenderingHints(m);
+
+		assertEquals(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY, g2d
+				.getRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION));
+		assertEquals(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF, g2d
+				.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING));
+		assertEquals(RenderingHints.VALUE_ANTIALIAS_OFF, g2d
+				.getRenderingHint(RenderingHints.KEY_ANTIALIASING));
+		assertEquals(RenderingHints.VALUE_STROKE_DEFAULT, g2d
+				.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL));
 	}
 }



Mime
View raw message