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

Provide public API for text related methods in SwingUtilities2

XMLWordPrintable

    • b127
    • x86
    • other

      A DESCRIPTION OF THE REQUEST :
      SwingUtilities2 provides a number of methods and fields related to drawing and measuring text. These methods and fields are widely used in platform LAFs. They support text anti-aliasing and compatibility of rendering for printing and display. This functionality should be provided in a public API for use by third party LAFs in JDK9 and beyond.

      The relevant methods and fields are:

      drawString(JComponent, Graphics, String, int, int)
      drawStringUnderlineCharAt
      clipStringIfNecessary
      stringWidth
      getFontMetrics(JComponent, Graphics)
      AATextInfo.getAATextInfo
      AA_TEXT_PROPERTY_KEY

      These methods and fields support anti-aliasing features that perhaps could be duplicated using public APIs, but it would be a lot of work.

      These methods also use private APIs to obtain a Graphics2D from the Graphics object used in the printing APIs, so that text rendering when printing can be the same as on a display.

      The Aqua LAF does something similar with printer graphics in AquaPainter.getGraphics2D. The fact that it is not exactly the same should be investigated.

      These symbols are less widely used but should also be considered:

      COMPONENT_UI_PROPERTY_KEY
      BASICMENUITEMUI_MAX_TEXT_OFFSET

      This RFE should be have labels "modularization" and "jdkinternals".


      JUSTIFICATION :
      It should be possible to write custom LAFs that have the same abilities as platform LAFs. In JDK9, the internal APIs used by platform LAFs will no longer be available outside the JDK. Hence, public APIs are needed.


            alexsch Alexandr Scherbatiy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: