Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5012037

There appears to be rounding inconsistencies when drawing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.4.2
    • client-libs
    • 2d
    • b33
    • x86
    • windows_2000



      Name: gm110360 Date: 03/11/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      There appears to be rounding inconsistencies when drawing.

      When drawing text and it's bounding box depending on the translation the text may appear one pixel wide outside the bounding box.

      This might be due to bug 4522900.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect all the I's to be within their bounding boxes.
      ACTUAL -
      In the 2nd to left column, the bottom 2 rows have their I's appear slightly to the left of the bounding box. The problem wouldn't be too bad except for this is the normal size the font is getting used at.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.font.*;
      import javax.swing.*;

      public class QuickTest {
        public static void main(String s[]) {
          JFrame frame = new JFrame() {
            private void paintIcon(Graphics2D aContext, double aTranslationX, double aTranslationY, double aScale) {
              aContext.translate(aTranslationX, aTranslationY);
              aContext.scale(aScale, aScale);
              aContext.setFont(new Font("Monospaced", Font.BOLD, 10));
              TextLayout layout = new TextLayout("I", aContext.getFont(), aContext.getFontRenderContext());
              aContext.setColor(Color.RED);
              layout.draw(aContext, 0, 0);
              aContext.setColor(Color.BLACK);
              aContext.draw(layout.getBounds());
            }

            public void paint(Graphics aContext) {
              paintIcon((Graphics2D)aContext.create(), 50, 100, 0.5);
              paintIcon((Graphics2D)aContext.create(), 100, 100, 1);
              paintIcon((Graphics2D)aContext.create(), 150, 100, 2);
              paintIcon((Graphics2D)aContext.create(), 200, 100, 4);
              paintIcon((Graphics2D)aContext.create(), 250, 100, 8);
              paintIcon((Graphics2D)aContext.create(), 50.499, 200.499, 0.5);
              paintIcon((Graphics2D)aContext.create(), 100.499, 200.499, 1);
              paintIcon((Graphics2D)aContext.create(), 150.499, 200.499, 2);
              paintIcon((Graphics2D)aContext.create(), 200.499, 200.499, 4);
              paintIcon((Graphics2D)aContext.create(), 250.499, 200.499, 8);
              paintIcon((Graphics2D)aContext.create(), 50.501, 300.501, 0.5);
              paintIcon((Graphics2D)aContext.create(), 100.501, 300.501, 1);
              paintIcon((Graphics2D)aContext.create(), 150.501, 300.501, 2);
              paintIcon((Graphics2D)aContext.create(), 200.501, 300.501, 4);
              paintIcon((Graphics2D)aContext.create(), 250.501, 300.501, 8);
            }
          };
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(400, 400);
          frame.setVisible(true);
        }
      }
      ---------- END SOURCE ----------
      (Incident Review ID: 243014)
      ======================================================================

            dougfelt Doug Felt (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: