-
Bug
-
Resolution: Unresolved
-
P3
-
7u25, 7-pool, 8-pool, 9
-
windows_7
FULL PRODUCT VERSION :
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Running on VM.
Using VMware SVGA 3D Display Adapter
A DESCRIPTION OF THE PROBLEM :
RadialGradientPaint has severe drawing artifacts when painting shapes on a Graphics2D object with transform scale set to squash into an oval shape.
Only occurs when RadialGradientPaint.cycleMethod is set to REPEAT or REFLECT, and the radius is small enough that repetitions occur. The more repetitions, the worse the artifacts are. The closer to the outside of the shape, the worse the artifacts are. Artifacts tend to occur in a vertical line through the center of the circular gradient.
Problem may be related to a similar bug with RadialGradientPaint which results in ArrayIndexOutOfBounds errors being thrown.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Same as for the RadialGradientPaint ArrayIndexOutOfBounds Exception Bug:
override JPanel.paint()
set g2d.scale(<squashed tranform>)
create RadialGradientPaint(radius=(approx. 10px), CycleMethod=REFLECT)
fillRect(0,0, width, height)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Draw an oval shaped RadialGradientPaint
ACTUAL -
Draws a RadialGradientPaint, but with tearing, or, in many cases, throws ArrayIndexOutOfBounds Exception
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package testing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RadialGradientPaint;
import java.awt.Rectangle;
import java.awt.MultipleGradientPaint.CycleMethod;
import java.awt.geom.Point2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class Test
{
public Test()
{
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.add(new JPanel()
{
private Color startColor = Color.black;
private Color endColor = Color.white;
@Override
public void paint(Graphics g)
{
super.paint(g);
Graphics2D g2d = (Graphics2D)g;
Rectangle r = new Rectangle(0,0,getWidth(), getHeight());
float radius = Math.min(r.width, r.height)/2.0f;
Point2D.Double center = new Point2D.Double(r.x+r.width/2,r.y+r.height/2);
Point2D.Double focus = new Point2D.Double(center.x, center.y);
g2d.translate(center.x, center.y);
double aspect = (double)r.height/r.width;
g2d.scale(Math.max(1, 1/aspect), Math.max(1, aspect));
g2d.translate(-center.x, -center.y);
float frac = 10f;
RadialGradientPaint gPaint = new RadialGradientPaint(center, radius/frac, focus, new float[] {0, 1}, new Color[] {startColor, endColor}, CycleMethod.REFLECT);
g2d.setPaint(gPaint);
g2d.fillRect(r.x, r.y, r.width, r.height);
}
private static final long serialVersionUID = 1L;
}, BorderLayout.CENTER);
frame.setSize(100, 100);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new Test();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround can avoid the visual artifacts.
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Running on VM.
Using VMware SVGA 3D Display Adapter
A DESCRIPTION OF THE PROBLEM :
RadialGradientPaint has severe drawing artifacts when painting shapes on a Graphics2D object with transform scale set to squash into an oval shape.
Only occurs when RadialGradientPaint.cycleMethod is set to REPEAT or REFLECT, and the radius is small enough that repetitions occur. The more repetitions, the worse the artifacts are. The closer to the outside of the shape, the worse the artifacts are. Artifacts tend to occur in a vertical line through the center of the circular gradient.
Problem may be related to a similar bug with RadialGradientPaint which results in ArrayIndexOutOfBounds errors being thrown.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Same as for the RadialGradientPaint ArrayIndexOutOfBounds Exception Bug:
override JPanel.paint()
set g2d.scale(<squashed tranform>)
create RadialGradientPaint(radius=(approx. 10px), CycleMethod=REFLECT)
fillRect(0,0, width, height)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Draw an oval shaped RadialGradientPaint
ACTUAL -
Draws a RadialGradientPaint, but with tearing, or, in many cases, throws ArrayIndexOutOfBounds Exception
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package testing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RadialGradientPaint;
import java.awt.Rectangle;
import java.awt.MultipleGradientPaint.CycleMethod;
import java.awt.geom.Point2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class Test
{
public Test()
{
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.add(new JPanel()
{
private Color startColor = Color.black;
private Color endColor = Color.white;
@Override
public void paint(Graphics g)
{
super.paint(g);
Graphics2D g2d = (Graphics2D)g;
Rectangle r = new Rectangle(0,0,getWidth(), getHeight());
float radius = Math.min(r.width, r.height)/2.0f;
Point2D.Double center = new Point2D.Double(r.x+r.width/2,r.y+r.height/2);
Point2D.Double focus = new Point2D.Double(center.x, center.y);
g2d.translate(center.x, center.y);
double aspect = (double)r.height/r.width;
g2d.scale(Math.max(1, 1/aspect), Math.max(1, aspect));
g2d.translate(-center.x, -center.y);
float frac = 10f;
RadialGradientPaint gPaint = new RadialGradientPaint(center, radius/frac, focus, new float[] {0, 1}, new Color[] {startColor, endColor}, CycleMethod.REFLECT);
g2d.setPaint(gPaint);
g2d.fillRect(r.x, r.y, r.width, r.height);
}
private static final long serialVersionUID = 1L;
}, BorderLayout.CENTER);
frame.setSize(100, 100);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new Test();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround can avoid the visual artifacts.