Class GraphicalUtility



  • public final class GraphicalUtility
    extends Object
    The Class GraphicalUtility.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Font getFont​(String aText, int aWidth, String aFontName, int aFontStyle)
      Tries to determine the font size for the given font name and font style for the given text to fit into the given width (pixels).
      static int toAlpha​(int aRgbValue)
      Retrieves the alpha portion of the provided RGB value.
      static int toBlue​(int aRgbValue)
      Retrieves the blue portion of the provided RGB value.
      static int toGray​(int aRgbValue)
      Converts the given RGB value to a gray scale value by averaging the red, green and blue portions of the RGB value.
      static int toGreen​(int aRgbValue)
      Retrieves the green portion of the provided RGB value.
      static int toRed​(int aRgbValue)
      Retrieves the red portion of the provided RGB value.
      static int toRgb​(int aAlpha, int aRed, int aGreen, int aBlue)
      Combines the alpha, red, green and blue values to an RGB value.
    • Method Detail

      • toGray

        public static int toGray​(int aRgbValue)
        Converts the given RGB value to a gray scale value by averaging the red, green and blue portions of the RGB value.
        Parameters:
        aRgbValue - The RGB value to be converted to a grays scale value.
        Returns:
        The gray scale value from the RGB value.
      • toRgb

        public static int toRgb​(int aAlpha,
                                int aRed,
                                int aGreen,
                                int aBlue)
        Combines the alpha, red, green and blue values to an RGB value.
        Parameters:
        aAlpha - The alpha value to use.
        aRed - The red value to use.
        aGreen - The green value to use.
        aBlue - The blue value to use.
        Returns:
        The according RGB value from the alpha, red, green and blue values.
      • toAlpha

        public static int toAlpha​(int aRgbValue)
        Retrieves the alpha portion of the provided RGB value.
        Parameters:
        aRgbValue - The RGB value from which to retrieve the alpha portion.
        Returns:
        The alpha portion from the according RGB value.
      • toRed

        public static int toRed​(int aRgbValue)
        Retrieves the red portion of the provided RGB value.
        Parameters:
        aRgbValue - The RGB value from which to retrieve the red portion.
        Returns:
        The red portion from the according RGB value.
      • toGreen

        public static int toGreen​(int aRgbValue)
        Retrieves the green portion of the provided RGB value.
        Parameters:
        aRgbValue - The RGB value from which to retrieve the green portion.
        Returns:
        The green portion from the according RGB value.
      • toBlue

        public static int toBlue​(int aRgbValue)
        Retrieves the blue portion of the provided RGB value.
        Parameters:
        aRgbValue - The RGB value from which to retrieve the blue portion.
        Returns:
        The blue portion from the according RGB value.
      • getFont

        public static Font getFont​(String aText,
                                   int aWidth,
                                   String aFontName,
                                   int aFontStyle)
        Tries to determine the font size for the given font name and font style for the given text to fit into the given width (pixels). In case the font size cannot be detected to make the given text fit exactly into the given width, then the biggest font size is used with which the text still fits into the given width. The width of the text will not exceed the given width.
        Parameters:
        aText - The text to fit into the given (pixel) width.
        aWidth - The (pixel) width into which the given text is to fit.
        aFontName - The font name to use for determining the correct font size.
        aFontStyle - The font style to be used
        Returns:
        the font