harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Khaschansky (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1453) [classlib][awt] Incorrect behavior of methods Graphics.draw3DRect and Graphics.fill3DRect
Date Wed, 13 Sep 2006 11:02:22 GMT
[classlib][awt] Incorrect behavior of methods Graphics.draw3DRect and Graphics.fill3DRect

                 Key: HARMONY-1453
                 URL: http://issues.apache.org/jira/browse/HARMONY-1453
             Project: Harmony
          Issue Type: Bug
            Reporter: Oleg Khaschansky
            Priority: Minor

1. Methods Graphics.draw3DRect(int x, int y, int width, int height, boolean raised) and Graphics.fill3DRect(int
x, int y, int width, int height, boolean raised) use their width parameter instead of height
to draw the lines. This result in a quads instead of rectangles. 

2. Calling these methods will reset paint attribute of the graphics context. Harmony implementation
of these methods calls setColor method, which updates the paint attribute. This behavior is
illogical and differs from RI.

3. Rendering of lines and filled rectangles in these methods uses paint and stroke defined
in the Graphics2D. This behavior contradicts the spec for the Graphics2D class: "The draw3DRect
and fill3DRect methods were implemented in terms of the drawLine and fillRect methods in the
Graphics class which would predicate their behavior upon the current Stroke and Paint objects
in a Graphics2D context. This class overrides those implementations with versions that use
the current Color exclusively, overriding the current Paint and which uses fillRect to describe
the exact same behavior as the preexisting methods regardless of the setting of the current

4. If the rectangle is not raised then fill3Drect fills it with the incorrect color (behavior
differs from RI).

5. There are per-pixel differences between RI and harmony implementations.

I will attach a patch for this issue soon.

The following test reveals all this incorrect behavior:
====================== test.java ======================= 
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class test {
    public static void main(String[] args) {
        Frame f = new Frame("test");
        f.add( new Canvas(){
            public void paint(Graphics g) {
                Graphics2D g2 = (Graphics2D) g;
                g2.setStroke(new BasicStroke(5));
                g2.setPaint(new GradientPaint(0,0,Color.red,100,100,Color.blue, true));

                g2.fill3DRect(20, 20, g.getClipBounds().width-40, g.getClipBounds().height-40,
                g2.draw3DRect(10, 10, g.getClipBounds().width-20, g.getClipBounds().height-20,

                g2.fillRect(40, 40, g.getClipBounds().width-80, g.getClipBounds().height-80);

                int y1 = (g.getClipBounds().height / 30);
                int x1 = (g.getClipBounds().width / 20);
                g2.setTransform(AffineTransform.getScaleInstance(10, 10));

                g2.draw3DRect(x1, y1, 3, 3, false);
                g2.fill3DRect(x1, y1*2, 4, 4, false);
        f.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent we) {

        f.setSize(200, 300);

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message