Package org.sm.smtools.swing.util
Class JLabelBox
java.lang.Object
org.sm.smtools.swing.util.JLabelBox
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
FieldsModifier and TypeFieldDescriptionstatic final int
A position offset from the viewport boundary. -
Method Summary
Modifier and TypeMethodDescriptionstatic Rectangle
drawLabel
(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, String text) Draws a single line of text inside a coloured box.static Rectangle
drawLabel
(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, String[] text) Draws multiple lines of text inside a coloured box.static Rectangle
drawLabelCentered
(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, String text) Draws a single line of text inside a coloured box with its position centred.static Rectangle
drawLabelCentered
(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, String[] text) Draws multiple lines of text inside a coloured box with its position centred.
-
Field Details
-
kViewportOffset
public static final int kViewportOffsetA position offset from the viewport boundary.- See Also:
-
-
Method Details
-
drawLabel
public static Rectangle drawLabel(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, 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 Rectangle drawLabel(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, 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 Rectangle drawLabelCentered(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, 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 Rectangle drawLabelCentered(Graphics2D g2D, Color textColor, Color backgroundColor, Color borderColor, double transparency, int posX, int posY, int textInset, Rectangle viewportBounds, 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
-