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

Rotated text is drawn to the opposite direction on Mac OS X

XMLWordPrintable

    • 2d
    • os_x

      FULL PRODUCT VERSION :
      java version " 1.7.0_13 "
      Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
      Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.7.5

      A DESCRIPTION OF THE PROBLEM :
      Rotated String is drawn to the opposite direction on Mac OS X.
      When we rotate graphics by g.rotate(-Math.PI / 2) and g.drawString( " ABC " ), " B " should be drawn upper " A " . But " B " is drawn under " A " . " C " is drawn under the " B " .

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the program to test
      2. Check the shown window.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      90 degrees rotated " ABC123 " should be shown.
      ACTUAL -
      Rotated " 321CBA " is shown at the wrong position.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Font;
      import java.awt.Graphics;
      import java.awt.Graphics2D;

      import javax.swing.JFrame;
      import javax.swing.SwingUtilities;

      public class RotatedStringFrame extends JFrame {
      @Override
      public void paint(Graphics g) {
      Graphics2D g2 = (Graphics2D) g;
      g2.setFont(new Font(Font.SERIF, Font.PLAIN, 24));
      g2.rotate(-Math.PI / 2.0);
      g2.drawString( " ABC123 " , -200.0f, 40.0f);
      }

      public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
      RotatedStringFrame frame = new RotatedStringFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(200, 400);
      frame.setVisible(true);
      }
      });
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      We can avoid this bug by using drawString(AttributedStringIterator) instead of drawString(String).

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: