Class JGraphics

java.lang.Object
org.sm.smtools.swing.util.JGraphics

public final class JGraphics extends Object
The JGraphics class provides static methodes for changing fonts, colors, ...

Note that this class cannot be subclassed!

Version:
22/08/2019
Author:
Sven Maerivoet
  • Method Details

    • getFontSize

      public static int getFontSize(Graphics2D g2D)
      Helper method to return the current font size.
      Parameters:
      g2D - a handle to the Graphics2D object
      Returns:
      the current font size
    • setFontSize

      public static void setFontSize(Graphics2D g2D, int fontSize)
      Helper method to set the current font size.
      Parameters:
      g2D - a handle to the Graphics2D object
      fontSize - the new font size
    • getFontHeight

      public static int getFontHeight(Graphics2D g2D)
      Helper method to return the current font's height.
      Parameters:
      g2D - a handle to the Graphics2D object
      Returns:
      the current font height
    • setFontMonospaced

      public static void setFontMonospaced(Graphics2D g2D)
      Helper method to set the font to monospaced.
      Parameters:
      g2D - a handle to the Graphics2D object
    • setFontBold

      public static void setFontBold(Graphics2D g2D)
      Helper method to set the font style to bold.
      Parameters:
      g2D - a handle to the Graphics2D object
    • setFontItalic

      public static void setFontItalic(Graphics2D g2D)
      Helper method to set the font style to italic.
      Parameters:
      g2D - a handle to the Graphics2D object
    • setFontBoldItalic

      public static void setFontBoldItalic(Graphics2D g2D)
      Helper method to set the font style to bold and italic.
      Parameters:
      g2D - a handle to the Graphics2D object
    • setColor

      public static void setColor(Graphics g2D, Color color, double transparency)
      Sets a color by also taking a specified transparency into account.
      Parameters:
      g2D - a handle to the Graphics2D object
      color - the color to use
      transparency - the transparency to use (between 0.0 and 1.0)