Class StringPainter


  • public class StringPainter
    extends Object
    Provides utility methods to draw strings.
    • Method Detail

      • computeOptimalSize

        public static void computeOptimalSize​(String string,
                                              Font font,
                                              Size size)
        Computes the optimal size of a string.

        The given size is modified to set the optimal size.

        Parameters:
        string - the string.
        font - the font.
        size - the size to modify.
      • drawStringInArea

        public static void drawStringInArea​(GraphicsContext g,
                                            String string,
                                            Font font,
                                            int x,
                                            int y,
                                            int width,
                                            int height,
                                            int horizontalAlignment,
                                            int verticalAlignment)
        Draws a string aligned in a area.
        Parameters:
        g - the graphics context.
        string - the string.
        font - the font.
        x - the area x coordinate.
        y - the area y coordinate.
        width - the area width.
        height - the area height.
        horizontalAlignment - the horizontal alignment.
        verticalAlignment - the vertical alignment.
      • drawStringAtPoint

        public static void drawStringAtPoint​(GraphicsContext g,
                                             String string,
                                             Font font,
                                             int anchorX,
                                             int anchorY,
                                             int horizontalAlignment,
                                             int verticalAlignment)
        Draws a string aligned with an anchor point.
        Parameters:
        g - the graphics context.
        string - the string.
        font - the font.
        anchorX - the anchor point x coordinate.
        anchorY - the anchor point y coordinate.
        horizontalAlignment - the horizontal alignment.
        verticalAlignment - the vertical alignment.