harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r446643 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt: Graphics.java Graphics2D.java
Date Fri, 15 Sep 2006 15:53:06 GMT
Author: hindessm
Date: Fri Sep 15 08:53:05 2006
New Revision: 446643

URL: http://svn.apache.org/viewvc?view=rev&rev=446643
Log:
Applied patch from "[#HARMONY-1453] [classlib][awt] Incorrect behavior of
methods Graphics.draw3DRect and Graphics.fill3DRect".

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics.java?view=diff&rev=446643&r1=446642&r2=446643
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics.java
Fri Sep 15 08:53:05 2006
@@ -39,24 +39,29 @@
     }
 
     public void draw3DRect(int x, int y, int width, int height, boolean raised) {
-        Color colorUp = getColor();
-        Color colorDown = colorUp.darker();
+        // Note: lighter/darker colors should be used to draw 3d rect.
+        // The resulting rect is (width+1)x(height+1). Stroke and paint attributes of
+        // the Graphics2D should be reset to the default values.
+        // fillRect is used instead of drawLine to bypass stroke
+        // reset/set and rasterization.
 
-        int []xpoints1 = {x, x, x+width+1};
-        int []ypoints1 = {y+width+1, y, y};
-        int []xpoints2 = {x+width+1, x+width+1, x};
-        int []ypoints2 = {y, y+width+1, y+width+1};
+        Color color = getColor();
+        Color colorUp, colorDown;
         if (raised) {
-            drawPolyline(xpoints1, ypoints1, 3);
-            setColor(colorDown);
-            drawPolyline(xpoints2, ypoints2, 3);
-            setColor(colorUp);
+            colorUp = color.brighter();
+            colorDown = color.darker();
         } else {
-            drawPolyline(xpoints2, ypoints2, 3);
-            setColor(colorDown);
-            drawPolyline(xpoints1, ypoints1, 3);
-            setColor(colorUp);
+            colorUp = color.darker();
+            colorDown = color.brighter();
         }
+
+        setColor(colorUp);
+        fillRect(x, y, width, 1);
+        fillRect(x, y+1, 1, height);
+
+        setColor(colorDown);
+        fillRect(x+width, y, 1, height);
+        fillRect(x+1, y+height, width, 1);
     }
 
     public void drawBytes(byte[] bytes, int off, int len, int x, int y) {
@@ -79,22 +84,35 @@
     }
 
     public void fill3DRect(int x, int y, int width, int height, boolean raised) {
-        Color colorUp = getColor();
-        Color colorDown = colorUp.darker();
+        // Note: lighter/darker colors should be used to draw 3d rect.
+        // The resulting rect is (width)x(height), same as fillRect.
+        // Stroke and paint attributes of the Graphics2D should be reset
+        // to the default values. fillRect is used instead of drawLine to
+        // bypass stroke reset/set and line rasterization.
 
-        int []xpoints = {x+width+1, x+width+1, x};
-        int []ypoints = {y, y+width+1, y+width+1};
+        Color color = getColor();
+        Color colorUp, colorDown;
         if (raised) {
-            fillRect(x, y, width, height);
-            setColor(colorDown);
-            drawPolyline(xpoints, ypoints, 3);
-            setColor(colorUp);
+            colorUp = color.brighter();
+            colorDown = color.darker();
+            setColor(color);
         } else {
-            setColor(colorDown);
-            fillRect(x, y, width, height);
+            colorUp = color.darker();
+            colorDown = color.brighter();
             setColor(colorUp);
-            drawPolyline(xpoints, ypoints, 3);
         }
+
+        width--;
+        height--;
+        fillRect(x+1, y+1, width-1, height-1);
+
+        setColor(colorUp);
+        fillRect(x, y, width, 1);
+        fillRect(x, y+1, 1, height);
+
+        setColor(colorDown);
+        fillRect(x+width, y, 1, height);
+        fillRect(x+1, y+height, width, 1);
     }
 
     public void fillPolygon(Polygon p) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java?view=diff&rev=446643&r1=446642&r2=446643
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java
Fri Sep 15 08:53:05 2006
@@ -114,4 +114,22 @@
 
     @Override
     public abstract void translate(int x, int y);
+
+    public void fill3DRect(int x, int y, int width, int height, boolean raised) {
+        // According to the spec, color should be used instead of paint,
+        // so Graphics.fill3DRect resets paint and
+        // it should be restored after the call
+        Paint savedPaint = getPaint();
+        super.fill3DRect(x, y, width, height, raised);
+        setPaint(savedPaint);
+    }
+
+    public void draw3DRect(int x, int y, int width, int height, boolean raised) {
+        // According to the spec, color should be used instead of paint,
+        // so Graphics.draw3DRect resets paint and
+        // it should be restored after the call
+        Paint savedPaint = getPaint();
+        super.draw3DRect(x, y, width, height, raised);
+        setPaint(savedPaint);
+    }
 }



Mime
View raw message