-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
None
-
x86, sparc
-
solaris_2.6, windows_nt
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();
}
}
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();
}
}
- duplicates
-
JDK-4174905 Circle bullet doesn't look like a circle in UL Type="CIRCLE" html code
-
- Closed
-
-
JDK-4151279 Curves are not as pleasing as JDK 1.1 (affects ovals, arcs and roundrects)
-
- Resolved
-
- relates to
-
JDK-4193338 drawArc() to offscreen produces unsmooth arc
-
- Closed
-