JDK-4179437 : drawOval to offscreen image results in lumpy circles
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6,windows_nt
  • CPU: x86,sparc
  • Submitted: 1998-10-07
  • Updated: 1999-04-09
  • Resolved: 1999-04-09
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
The following code uses drawOval with increasing width/heights to draw circles. The first line of circles is drawn directly on screen, with the remaining lines created from an offscreen image. As you can see the first line of circles look quite good, while the remaining lines of circles look rather lumpy and distorted, especially for the smaller sizes. I ran this against 1.2fcs, build M.

import java.awt.*;
import java.awt.event.*;

public class OvalTest2 extends Container {
    public static final int       TOTAL = 30;
    public static final int       MAX_RAD = 24;

    public Dimension getPreferredSize() {
        return new Dimension(300, 100);
    }

    public Dimension getMinimumSize() {
        return getPreferredSize();
    }

    public Dimension getMaximumSize() {
        return getPreferredSize();
    }

    public void paint(Graphics g) {
	Dimension size = getSize();
        int maxY = size.height / TOTAL * TOTAL;

	// Create an image for all rows, but the first.
 	Image i = createImage(size.width, TOTAL);

        doDraw(i.getGraphics(), size.width);

	// Draw the first row.
	g.setColor(Color.white);
	g.fillRect(0, 0, size.width, size.height);
        doDraw(g, size.width);

	// Draw the remaining rows using the offscreen image.
	for (int counter = maxY; counter >= TOTAL; counter -= TOTAL) {
	    g.drawImage(i, 0, counter, null);
	}
    }

    public void doDraw(Graphics g, int width) {
	g.setColor(Color.white);
	g.fillRect(0, 0, width, 30);
        g.setFont(g.getFont());
	g.setColor(Color.black);
        int rad = 5;
	for (int counter = 0; counter < width; counter += rad + 4) {
            if (rad++ == MAX_RAD) {
                rad = 6;
            }
	    g.drawOval(counter, 0, rad, rad);
	}
    }

    public static void main(String[] args) {
        Frame f = new Frame("Oval test");
	final OvalTest2 ov = new OvalTest2();
	f.add(ov);
	f.addWindowListener(new WindowAdapter() {
	    public void windowClosing(WindowEvent we) {
		System.exit(0);
	    }
	});
        f.pack();
        f.show();
    }
}

Comments
EVALUATION Too late for FCS. jeannette.hung@Eng 1998-10-07
07-10-1998