JDK-6966745 : Round joins/caps of scaled up lines have poor quality.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2010-07-05
  • Updated: 2012-03-20
  • Resolved: 2011-03-07
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (fedora-41.b18.fc13-x86_64)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
2.6.33.5-124.fc13.x86_64 #1 SMP Fri Jun 11 09:38:12 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
When a thin line is drawn with round joins or end caps, and with an affine transformation that magnifies, the end caps and joins don't look round at all.

This is because of how round end caps and joins are drawn in Pisces. A circle arc is drawn as many tiny lines, each with a length of approximately one pixel. The number of these lines is computed using the line width. The problem is that the effect of the transformation on the line width is not taken into account.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A round end cap is drawn at the ends of the white line (in the output image test.png)
ACTUAL -
The end cap looks triangular.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.imageio.*;

public class TestDBZ extends Frame {

    public static void main(String[] args) {
        BufferedImage bImg = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = (Graphics2D) bImg.getGraphics();

        g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f));//, new float[] {12f, 12f}, 0));

        g2d.scale(20, 20);
        g2d.drawLine(2, 2, 10, 10);
        try { ImageIO.write(bImg, "png", new java.io.File("test.png")); } catch (Exception e) {}
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Not much one can do, except not use transforms or round joins.