-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
6
-
Cause Known
-
x86
-
windows_vista
FULL PRODUCT VERSION :
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows Vista 6.0.6000
A DESCRIPTION OF THE PROBLEM :
In some conditions, with JDK1.6, the drawing of a stroked shape using a transformed graphics does not fit anymore the pixels drawn using Graphics2D.fill of the same shape.
This seems a regression with respect to JDK1.5.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compare (visually is enough) the result of attached program when running with JDK1.5 versus JDK1.6. You should easily see white pixels between the stroke and the fill on the bottom part of the drawn curve.
Reproduced on Windows Vista using JDK1.5.0_13 and JDK1.6.0_03.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The drawing of the stroked shape should fit the pixels drawn by Graphics2D.fill of the same shape. This was the case in JDK1.5.
ACTUAL -
With JDK1.6 there are undrawn pixels between the drawing of the stroked shape and the pixels drawn by Graphics2D.fill of the same shape. In the attached example, this can be easily seen in the bottom part of the curve.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* Exhibits a regression in JDK1.6 with respect to JDK 1.5 concerning the
* drawing of shapes.
* Running this program with JDK1.5.0_14, the drawn pixels of the stroked
* Graphics2D.draw(shape) fit well the drawn pixels from Graphics2D.fill(Shape).
* This is no longer the case when running with JDK1.6.0_03: on the bottom
* of the curve, white pixels can be seen between the fill and the draw.
*/
public class TestDrawShape
{
public static final void main(String[] args)
{
JFrame frame = new JFrame("Test");
JPanel panel = new JPanel() {
@Override
public void paint(Graphics g)
{
GeneralPath path = new GeneralPath(PathIterator.WIND_NON_ZERO);
path.moveTo(4.4094186f, 47.798046f);
path.curveTo(4.4094186f, 47.377647f, 3.992393f, 47.03684f, 3.4778786f, 47.03684f);
path.curveTo(2.9633641f, 47.03684f, 2.5463383f, 47.3776f, 2.5463383f, 47.798046f);
path.curveTo(2.5463383f, 48.218395f, 2.963416f, 48.559254f, 3.4778786f, 48.559254f);
path.curveTo(3.9923408f, 48.559254f, 4.4094186f, 48.218445f, 4.4094186f, 47.798046f);
path.closePath();
draw(path, g);
}
private void draw(Shape shape, Graphics dst)
{
Graphics2D g = (Graphics2D)dst;
AffineTransform aft =
new AffineTransform(245.584756349729, 0.0, 0.0,
-267.5511380776864, -620.1139499239824, 13027.42158410122);
g.setTransform(aft);
// Fill the shape
Paint paint = Color.red; // fill color
g.setPaint(paint);
g.fill(shape);
// Stroke the shape
Stroke stroke = new BasicStroke(1.7589447E-4f);
paint = Color.black; // stroke color
g.setStroke(stroke);
g.setPaint(paint);
g.draw(shape);
}
};
frame.setSize(500, 500);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Switch on antialiasing or use (small) alpha-transparency. Any of these removes this effect.
Release Regression From : 5.0u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows Vista 6.0.6000
A DESCRIPTION OF THE PROBLEM :
In some conditions, with JDK1.6, the drawing of a stroked shape using a transformed graphics does not fit anymore the pixels drawn using Graphics2D.fill of the same shape.
This seems a regression with respect to JDK1.5.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compare (visually is enough) the result of attached program when running with JDK1.5 versus JDK1.6. You should easily see white pixels between the stroke and the fill on the bottom part of the drawn curve.
Reproduced on Windows Vista using JDK1.5.0_13 and JDK1.6.0_03.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The drawing of the stroked shape should fit the pixels drawn by Graphics2D.fill of the same shape. This was the case in JDK1.5.
ACTUAL -
With JDK1.6 there are undrawn pixels between the drawing of the stroked shape and the pixels drawn by Graphics2D.fill of the same shape. In the attached example, this can be easily seen in the bottom part of the curve.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* Exhibits a regression in JDK1.6 with respect to JDK 1.5 concerning the
* drawing of shapes.
* Running this program with JDK1.5.0_14, the drawn pixels of the stroked
* Graphics2D.draw(shape) fit well the drawn pixels from Graphics2D.fill(Shape).
* This is no longer the case when running with JDK1.6.0_03: on the bottom
* of the curve, white pixels can be seen between the fill and the draw.
*/
public class TestDrawShape
{
public static final void main(String[] args)
{
JFrame frame = new JFrame("Test");
JPanel panel = new JPanel() {
@Override
public void paint(Graphics g)
{
GeneralPath path = new GeneralPath(PathIterator.WIND_NON_ZERO);
path.moveTo(4.4094186f, 47.798046f);
path.curveTo(4.4094186f, 47.377647f, 3.992393f, 47.03684f, 3.4778786f, 47.03684f);
path.curveTo(2.9633641f, 47.03684f, 2.5463383f, 47.3776f, 2.5463383f, 47.798046f);
path.curveTo(2.5463383f, 48.218395f, 2.963416f, 48.559254f, 3.4778786f, 48.559254f);
path.curveTo(3.9923408f, 48.559254f, 4.4094186f, 48.218445f, 4.4094186f, 47.798046f);
path.closePath();
draw(path, g);
}
private void draw(Shape shape, Graphics dst)
{
Graphics2D g = (Graphics2D)dst;
AffineTransform aft =
new AffineTransform(245.584756349729, 0.0, 0.0,
-267.5511380776864, -620.1139499239824, 13027.42158410122);
g.setTransform(aft);
// Fill the shape
Paint paint = Color.red; // fill color
g.setPaint(paint);
g.fill(shape);
// Stroke the shape
Stroke stroke = new BasicStroke(1.7589447E-4f);
paint = Color.black; // stroke color
g.setStroke(stroke);
g.setPaint(paint);
g.draw(shape);
}
};
frame.setSize(500, 500);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Switch on antialiasing or use (small) alpha-transparency. Any of these removes this effect.
Release Regression From : 5.0u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.