United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4179437 : drawOval to offscreen image results in lumpy circles

Details
Type:
Bug
Submit Date:
1998-10-07
Status:
Closed
Updated Date:
1999-04-09
Project Name:
JDK
Resolved Date:
1999-04-09
Component:
client-libs
OS:
solaris_2.6,windows_nt
Sub-Component:
2d
CPU:
x86,sparc
Priority:
P4
Resolution:
Duplicate
Affected Versions:
1.2.0
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Relates:

Sub Tasks

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
                                     
1998-10-07



Hardware and Software, Engineered to Work Together