-
Bug
-
Resolution: Unresolved
-
P4
-
7u40, 8, 9
-
x86
-
os_x
FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS Sierra 10.12.2
A DESCRIPTION OF THE PROBLEM :
Javadoc for java.awt.Graphics class declares that outlines of figures are drawn to the right and bottom of 'ideal' outline path. This doesn't happen when rendering happens on a Retina display - outlines seem to be centered on 'ideal' path instead.
The same problem is observed on Windows with latest Java 9 builds, when rendering to a HiDPI display with scale factor 2.
I believe, this is either a bug in the implementation, or in the documentation for java.awt.Graphics class.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample program given below on a macOS computer with Retina display.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Black border pixels completely enclose grey inner pixels.
ACTUAL -
At the right and at the bottom of the rectangle black pixels are rendered 'inside' grey pixels.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
public class RectangleTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame f = new JFrame();
f.add(new MyComponent());
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(200, 170);
f.setLocationRelativeTo(null);
f.setVisible(true);
});
}
private static class MyComponent extends JComponent {
@Override
protected void paintComponent(Graphics g) {
g.setColor(Color.gray);
g.fillRect(50, 50, 100, 50);
g.setColor(Color.black);
g.drawRect(50, 50, 99, 49);
}
}
}
---------- END SOURCE ----------
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS Sierra 10.12.2
A DESCRIPTION OF THE PROBLEM :
Javadoc for java.awt.Graphics class declares that outlines of figures are drawn to the right and bottom of 'ideal' outline path. This doesn't happen when rendering happens on a Retina display - outlines seem to be centered on 'ideal' path instead.
The same problem is observed on Windows with latest Java 9 builds, when rendering to a HiDPI display with scale factor 2.
I believe, this is either a bug in the implementation, or in the documentation for java.awt.Graphics class.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample program given below on a macOS computer with Retina display.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Black border pixels completely enclose grey inner pixels.
ACTUAL -
At the right and at the bottom of the rectangle black pixels are rendered 'inside' grey pixels.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
public class RectangleTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame f = new JFrame();
f.add(new MyComponent());
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(200, 170);
f.setLocationRelativeTo(null);
f.setVisible(true);
});
}
private static class MyComponent extends JComponent {
@Override
protected void paintComponent(Graphics g) {
g.setColor(Color.gray);
g.fillRect(50, 50, 100, 50);
g.setColor(Color.black);
g.drawRect(50, 50, 99, 49);
}
}
}
---------- END SOURCE ----------