Class Util


  • public class Util
    extends Object
    Author:
    Will Braynen
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • drawVerticalString

        public static void drawVerticalString​(Graphics g,
                                              String text,
                                              Font font,
                                              int x,
                                              int y)
        Draws a string vertically, turned 90 degrees counter-clockwise. Read carefully what the x and y coordinates means; chances are that if you draw to (x,y) = (0,0), you won't see anything.
        Parameters:
        g - the graphics context on which to draw
        text - the string to draw
        font - the font to use
        x - the x coordinate where you want to place the baseline of the text.
        y - the y coordinate where you want to place the first letter of the text.
      • maxStringPixelWidth

        public static int maxStringPixelWidth​(String[] strings,
                                              FontMetrics fm)
        Parameters:
        strings - an array of strings whose pixels widths to compare
        fm - FontMetrics object for the Component or Graphics.
        Returns:
        the largest pixel width of a string in the strings array.
      • stringPixelWidth

        public static int stringPixelWidth​(String text,
                                           FontMetrics fm)
        Parameters:
        text - the string whose pixel width is to be measured
        fm - FontMetrics object for the Component or Graphics.
        Returns:
        the pixel width of the string for the specified font.