Package org.sm.smtools.swing.util
Class JGraphics
java.lang.Object
org.sm.smtools.swing.util.JGraphics
public final class JGraphics
extends java.lang.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 Summary
Modifier and Type Method Description static int
getFontHeight(java.awt.Graphics2D g2D)
Helper method to return the current font's height.static int
getFontSize(java.awt.Graphics2D g2D)
Helper method to return the current font size.static void
setColor(java.awt.Graphics g2D, java.awt.Color color, double transparency)
Sets a color by also taking a specified transparency into account.static void
setFontBold(java.awt.Graphics2D g2D)
Helper method to set the font style to bold.static void
setFontBoldItalic(java.awt.Graphics2D g2D)
Helper method to set the font style to bold and italic.static void
setFontItalic(java.awt.Graphics2D g2D)
Helper method to set the font style to italic.static void
setFontMonospaced(java.awt.Graphics2D g2D)
Helper method to set the font to monospaced.static void
setFontSize(java.awt.Graphics2D g2D, int fontSize)
Helper method to set the current font size.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
getFontSize
public static int getFontSize(java.awt.Graphics2D g2D)Helper method to return the current font size.- Parameters:
g2D
- a handle to theGraphics2D
object- Returns:
- the current font size
-
setFontSize
public static void setFontSize(java.awt.Graphics2D g2D, int fontSize)Helper method to set the current font size.- Parameters:
g2D
- a handle to theGraphics2D
objectfontSize
- the new font size
-
getFontHeight
public static int getFontHeight(java.awt.Graphics2D g2D)Helper method to return the current font's height.- Parameters:
g2D
- a handle to theGraphics2D
object- Returns:
- the current font height
-
setFontMonospaced
public static void setFontMonospaced(java.awt.Graphics2D g2D)Helper method to set the font to monospaced.- Parameters:
g2D
- a handle to theGraphics2D
object
-
setFontBold
public static void setFontBold(java.awt.Graphics2D g2D)Helper method to set the font style to bold.- Parameters:
g2D
- a handle to theGraphics2D
object
-
setFontItalic
public static void setFontItalic(java.awt.Graphics2D g2D)Helper method to set the font style to italic.- Parameters:
g2D
- a handle to theGraphics2D
object
-
setFontBoldItalic
public static void setFontBoldItalic(java.awt.Graphics2D g2D)Helper method to set the font style to bold and italic.- Parameters:
g2D
- a handle to theGraphics2D
object
-
setColor
public static void setColor(java.awt.Graphics g2D, java.awt.Color color, double transparency)Sets a color by also taking a specified transparency into account.- Parameters:
g2D
- a handle to theGraphics2D
objectcolor
- the color to usetransparency
- the transparency to use (between 0.0 and 1.0)
-