Package net.simplace.core.service
Class ComponentHelper
java.lang.Object
net.simplace.core.service.ComponentHelper
Helper for GUI components.
- Author:
- Andreas Enders
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
centerWindow
(Window aWindow) Centers the given window relative to its parent.static Color
combineColors
(Color aColor1, Color aColor2) Combines two different colors.static ImageIcon
combineIcons
(ImageIcon aIcon, int aIconX, int aIconY, ImageIcon aCoIcon, int aCoIconX, int aCoIconY) Combines the given icons.static ImageIcon
combineIcons
(ImageIcon aIcon, int aIconX, int aIconY, ImageIcon aCoIcon, int aCoIconX, int aCoIconY, boolean aFadeIcon) Combines the given icons.static Color
createColor
(String aColorString) Creates an RGB-Color from the given CSV-String e.g. "127,0,0"static ImageIcon
fadeIconColors
(ImageIcon aImageIcon) Brightens the given imagestatic JTextArea
findFirstJTextArea
(JComponent aComponent) Returns the first descendant component of type JTextArea.static void
fitColumnWidth
(JTable aTable, int aMaxWidth, boolean aResizable) Fits all columns in the table to perfect size.static int
fitColumnWidth
(JTable aTable, int aColumnIndex, int aMaxWidth, boolean aResizable) Fits the column to perfect size.static int
fitColumnWidth
(JTable aTable, int aColumnIndex, int aMinWidth, int aMaxWidth, boolean aResizable) Fits the column to perfect size.static TableColumn
Returns the column at the given model-column.static Component
getComponentByBounds
(Container aParent, int aX, int aY) Returns the component given by the bounds.static boolean
isAnchestor
(Component aComponent, Component aAnchestorComponent) Returns true if the first component is an anchestor of the second component.static boolean
isToolkitTrueColor
(Component aComponent) Checks if color depth is at least 24 bit.static void
setDefaultWindowBounds
(Window aWindow) Sets the default size and location of the given window.static void
setHeight
(JComponent aComponent, int aHeight) Sets the preferred height to a component.static Color
transformColor
(Color aColor, double aRelativeChangeValue) Returns a brighter/darker color based on relative RGB transformation.static Color
transformColor
(Color aColor, int aAbsoluteChangeValue) Returns a brighter/darker color based on absolute RGB transformation.
-
Method Details
-
isAnchestor
Returns true if the first component is an anchestor of the second component.- Parameters:
aComponent
-aAnchestorComponent
-- Returns:
- success
-
findFirstJTextArea
Returns the first descendant component of type JTextArea.- Parameters:
aComponent
-- Returns:
- the first descendant component of type JTextArea
-
getColumn
Returns the column at the given model-column. This will ignore the actual position of the column.- Parameters:
aTable
-aModelIndex
-- Returns:
- the column at the given model-column
-
fitColumnWidth
Fits all columns in the table to perfect size.- Parameters:
aTable
-aMaxWidth
-aResizable
-
-
fitColumnWidth
public static int fitColumnWidth(JTable aTable, int aColumnIndex, int aMaxWidth, boolean aResizable) Fits the column to perfect size.- Parameters:
aTable
-aColumnIndex
-aMaxWidth
-aResizable
-- Returns:
- column width
-
fitColumnWidth
public static int fitColumnWidth(JTable aTable, int aColumnIndex, int aMinWidth, int aMaxWidth, boolean aResizable) Fits the column to perfect size.- Parameters:
aTable
-aColumnIndex
-aMinWidth
-aMaxWidth
-aResizable
-- Returns:
- column width
-
transformColor
Returns a brighter/darker color based on absolute RGB transformation.- Parameters:
aColor
-aAbsoluteChangeValue
-- Returns:
- a brighter/darker color based on absolute RGB transformation
-
transformColor
Returns a brighter/darker color based on relative RGB transformation. value < 1.0 -> darker value = 1.0 -> same value > 1.0 -> brighter- Parameters:
aColor
-aRelativeChangeValue
-- Returns:
- a brighter/darker color based on relative RGB transformation
-
isToolkitTrueColor
Checks if color depth is at least 24 bit.- Parameters:
aComponent
-- Returns:
- true, if color depth is at least 24 bit
-
setDefaultWindowBounds
Sets the default size and location of the given window.- Parameters:
aWindow
-
-
getComponentByBounds
Returns the component given by the bounds.- Parameters:
aParent
-aX
-aY
-- Returns:
- the component given by the bounds
-
centerWindow
Centers the given window relative to its parent. If no parent is available, the window is centered on the screen.- Parameters:
aWindow
-
-
combineIcons
public static ImageIcon combineIcons(ImageIcon aIcon, int aIconX, int aIconY, ImageIcon aCoIcon, int aCoIconX, int aCoIconY) Combines the given icons.- Parameters:
aIcon
-aIconX
-aIconY
-aCoIcon
-aCoIconX
-aCoIconY
-- Returns:
- combined ImageIcon
-
combineIcons
public static ImageIcon combineIcons(ImageIcon aIcon, int aIconX, int aIconY, ImageIcon aCoIcon, int aCoIconX, int aCoIconY, boolean aFadeIcon) Combines the given icons.- Parameters:
aIcon
-aIconX
-aIconY
-aCoIcon
-aCoIconX
-aCoIconY
-aFadeIcon
-- Returns:
- combined ImageIcon
-
combineColors
Combines two different colors.- Parameters:
aColor1
-aColor2
-- Returns:
- combined Color
-
createColor
Creates an RGB-Color from the given CSV-String e.g. "127,0,0"- Parameters:
aColorString
-- Returns:
- an RGB-Color
-
setHeight
Sets the preferred height to a component.- Parameters:
aComponent
-aHeight
-
-
fadeIconColors
Brightens the given image- Parameters:
aImageIcon
-- Returns:
- brightened ImageIcon
-