Class PixelConverter


  • public class PixelConverter
    extends Object
    PixelConverter performs various conversions from device-independent units (such as DLUs or characters) to pixels. It can be associated with a control or a font. In the case of a control, the font used by the control at the time the PixelConverter is created is used for the pixel calculations. In the case of a specific font, the supplied font is used for the calculations. The control and/or font must not be disposed at the time the PixelConverter is created.
    Since:
    3.5
    • Constructor Detail

      • PixelConverter

        public PixelConverter​(Control control)
        Create a PixelConverter which will convert device-independent units to pixels using the font of the specified control.
        Parameters:
        control - the control whose font should be used for pixel conversions. Note that the font used by the control at the time this constructor is called is the font that will be used for all calculations. If the font of the specified control is changed after this PixelConverter is created, then the conversions from this instance will not produce the desired effect.
      • PixelConverter

        public PixelConverter​(Font font)
        Create a PixelConverter which will convert device-independent units to pixels using the specified font.
        Parameters:
        font - the font that should be used for pixel conversions.
    • Method Detail

      • convertHeightInCharsToPixels

        public int convertHeightInCharsToPixels​(int chars)
        Returns the number of pixels corresponding to the height of the given number of characters.
        Parameters:
        chars - the number of characters
        Returns:
        the number of pixels
      • convertHorizontalDLUsToPixels

        public int convertHorizontalDLUsToPixels​(int dlus)
        Returns the number of pixels corresponding to the given number of horizontal dialog units.
        Parameters:
        dlus - the number of horizontal dialog units
        Returns:
        the number of pixels
      • convertVerticalDLUsToPixels

        public int convertVerticalDLUsToPixels​(int dlus)
        Returns the number of pixels corresponding to the given number of vertical dialog units.
        Parameters:
        dlus - the number of vertical dialog units
        Returns:
        the number of pixels
      • convertWidthInCharsToPixels

        public int convertWidthInCharsToPixels​(int chars)
        Returns the number of pixels corresponding to the width of the given number of characters.
        Parameters:
        chars - the number of characters
        Returns:
        the number of pixels