Package org.sm.smtools.swing.util
Class JLabelBox
java.lang.Object
org.sm.smtools.swing.util.JLabelBox
public final class JLabelBox
extends java.lang.Object
The
JLabelBox
class provides static methodes for drawing labels in boxes.
Note that this class cannot be subclassed!
- Version:
- 08/03/2020
- Author:
- Sven Maerivoet
-
Field Summary
Fields Modifier and Type Field Description static int
kViewportOffset
A position offset from the viewport boundary. -
Method Summary
Modifier and Type Method Description static java.awt.Rectangle
drawLabel(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String text)
Draws a single line of text inside a coloured box.static java.awt.Rectangle
drawLabel(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String[] text)
Draws multiple lines of text inside a coloured box.static java.awt.Rectangle
drawLabelCentered(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String text)
Draws a single line of text inside a coloured box with its position centred.static java.awt.Rectangle
drawLabelCentered(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String[] text)
Draws multiple lines of text inside a coloured box with its position centred.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
kViewportOffset
public static final int kViewportOffsetA position offset from the viewport boundary.- See Also:
- Constant Field Values
-
-
Method Details
-
drawLabel
public static java.awt.Rectangle drawLabel(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String[] text)Draws multiple lines of text inside a coloured box.- Parameters:
g2D
- a handle to theGraphics2D
objecttextColor
- the text colourbackgroundColor
- the background colourborderColor
- the border colourtransparency
- the background and border colours' transparency (0.0 is fully opaque, 1.0 is fully transparent)posX
- the left position of the boxposY
- the top position of the boxtextInset
- the inside single-margin between the text and any of the surrounding box's sidesviewportBounds
- the bounds of the viewport in which the label box should fit (it is ignored if the parameter isnull
)text
- the label text (specified as new String[] {"String 1","String 2"})- Returns:
- a
Rectangle
containing optionally modified (x,y) coordinates to make the label box fit inside the viewport
-
drawLabel
public static java.awt.Rectangle drawLabel(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String text)Draws a single line of text inside a coloured box.- Parameters:
g2D
- a handle to theGraphics2D
objecttextColor
- the text colourbackgroundColor
- the background colourborderColor
- the border colourtransparency
- the background and border colours' transparency (0.0 is fully opaque, 1.0 is fully transparent)posX
- the left position of the boxposY
- the top position of the boxtextInset
- the inside single-margin between the text and any of the surrounding box's sidesviewportBounds
- the bounds of the viewport in which the label box should fit (it is ignored if the parameter isnull
)text
- the label text- Returns:
- a
Rectangle
containing optionally modified (x,y) coordinates to make the label box fit inside the viewport
-
drawLabelCentered
public static java.awt.Rectangle drawLabelCentered(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String[] text)Draws multiple lines of text inside a coloured box with its position centred.- Parameters:
g2D
- a handle to theGraphics2D
objecttextColor
- the text colourbackgroundColor
- the background colourborderColor
- the border colourtransparency
- the background and border colours' transparency (0.0 is fully opaque, 1.0 is fully transparent)posX
- the left position of the boxposY
- the top position of the boxtextInset
- the inside single-margin between the text and any of the surrounding box's sidesviewportBounds
- the bounds of the viewport in which the label box should fit (it is ignored if the parameter isnull
)text
- the label text- Returns:
- a
Rectangle
containing optionally modified (x,y) coordinates to make the label box fit inside the viewport
-
drawLabelCentered
public static java.awt.Rectangle drawLabelCentered(java.awt.Graphics2D g2D, java.awt.Color textColor, java.awt.Color backgroundColor, java.awt.Color borderColor, double transparency, int posX, int posY, int textInset, java.awt.Rectangle viewportBounds, java.lang.String text)Draws a single line of text inside a coloured box with its position centred.- Parameters:
g2D
- a handle to theGraphics2D
objecttextColor
- the text colourbackgroundColor
- the background colourborderColor
- the border colourtransparency
- the background and border colours' transparency (0.0 is fully opaque, 1.0 is fully transparent)posX
- the left position of the boxposY
- the top position of the boxtextInset
- the inside single-margin between the text and any of the surrounding box's sidesviewportBounds
- the bounds of the viewport in which the label box should fit (it is ignored if the parameter isnull
)text
- the label text- Returns:
- a
Rectangle
containing optionally modified (x,y) coordinates to make the label box fit inside the viewport
-