Class RadianceCoreUtilities
java.lang.Object
org.pushingpixels.radiance.theming.internal.utils.RadianceCoreUtilities
Various utility functions. This class is for internal use only.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static List
<AWTEventListener> static final String
Client property name for marking components covered by lightweight popups.static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canReplaceChildBackgroundColor
(Color background) static String
clipString
(FontMetrics metrics, int availableWidth, String fullText) Clips string based on specified font metrics and available width (in pixels).static Icon
getArrowIcon
(AbstractButton button, int orientation) Returns the arrow icon.static Icon
getArrowIcon
(JComponent comp, BladeTransitionAwareIcon.TransitionAwareUIDelegate transitionAwareUIDelegate, int orientation) Returns the arrow icon.static List
<AWTEventListener> static Color
getBackgroundFill
(RadianceSkin skin, RadianceThemingSlices.DecorationAreaType decorationAreaType) static BufferedImage
getBlankImage
(double scale, int width, int height) Retrieves transparent image of specified dimension.static RadianceBorderPainter
getBorderPainter
(Component comp) Returns the border painter for the specified component.static int
static RadianceButtonShaper
getButtonShaper
(Component comp) Returns the button shaper of the specified button.static ClassLoader
Returns the class loader for loading the resource files.static int
getCloseButtonSize
(JTabbedPane tabbedPane, int tabIndex) Returns the size of the close button for a tab in the specified tabbed pane.static double
Returns the colorization factor for the specified component.static <T> T
getComboPopupPrototypeDisplayValue
(JComboBox<T> combo) Returns the popup prototype display value for the specified combo box.getContentBorderKind
(JTabbedPane tabbedPane) Returns the content border kind of the specified tabbed pane.static int
Returns the number of echo characters per each password character.static RadianceFillPainter
getFillPainter
(Component comp) Returns the fill painter of the specified component.static Icon
getFilteredIcon
(JComponent comp, Icon orig, ComponentState componentState, Color textColor) static Icon
getFilteredIcon
(JTabbedPane tab, Icon orig, ComponentState componentState, Color textColor) getFocusKind
(Component component) Returns the focus ring kind of the specified component.static HashMapKey
getHashKey
(Object... objects) Returns a hash key for the specified parameters.static Container
Given a component, returns the parent for computing theRadianceDecorationPainter
.static String
getHierarchy
(Component comp) Returns the component hierarchy.static void
getHierarchy
(Component comp, StringBuffer buffer, int level) Computes the component hierarchy.static RadianceBorderPainter
Returns the highlight border painter for the specified component.getIconFilterStrategy
(JComponent component, ComponentState componentState) static float
Returns the global menu gutter fill alpha.static Point
static Icon
getOriginalIcon
(AbstractButton b, Icon defaultIcon) static Dimension
getPlacementAwarePopupShift
(boolean ltr, Dimension anchorDimension, Dimension popupDimension, Insets popupInsets, RadianceThemingSlices.PopupPlacementStrategy popupPlacementStrategy) static int
getPopupParentIndexOf
(Component comp, Component[] popups) Gets a component and a list of popups and returns the index of the popup that is a parent of the specified component.getPopupPlacementStrategy
(JComboBox combobox) Returns the popup placement strategy for the specified combobox.static BufferedImage
getScaledIconImage
(double scale, List<Image> imageList, int width, int height) ScansimageList
for best-looking image of specified dimensions.getSeparatorAppearance
(JSeparator separator) Returns the appearance for the specified separator.static Set
<RadianceThemingSlices.Side> getSides
(JComponent component, String propertyName) Returns the set of sides registered on the specified button.static RadianceSkin
Returns the skin of the specified component.static TabCloseCallback
getTabCloseCallback
(JTabbedPane tabbedPane, int tabIndex) Returns the callback to be called upon tab closing (using the tab close button).static Color
getTextBackgroundFill
(Component component, ComponentState componentState) static JTextComponent
static SwingRepaintCallback
getTextComponentRepaintCallback
(JTextComponent textComponent) static Color
getTextSelectionBackground
(Component component, ComponentState componentState) static Color
getTextSelectionForeground
(Component component, ComponentState componentState) static TitlePaneButtonsProvider
getTitlePaneButtonsProvider
(JRootPane rootPane) static JComponent
getTitlePaneComponent
(Window window) Returns the title pane of the specified top-level window.static float
getToolbarButtonCornerRadius
(JComponent button, float insets) Returns the corner radius of the specified toolbar button.static Component
getTopMostParentWithDecorationAreaType
(Component comp, RadianceThemingSlices.DecorationAreaType type) static boolean
hasCloseButton
(JTabbedPane tabbedPane, int tabIndex) Checks whether the specified tab has a close button.static boolean
hasFlatAppearance
(Component comp, boolean defaultValue) Checks whether the specified component is flat.static boolean
hasFlatAppearance
(AbstractButton button) Computes whether the specified button has flat appearance.static boolean
hasIcon
(AbstractButton button) Checks whether the specified button has associated icon.static boolean
hasNoMinSizeProperty
(AbstractButton button) Checks whether the specified button should have minimal size.static boolean
hasText
(AbstractButton button) Checks whether the specified button has associated text.static boolean
isComboBoxButton
(AbstractButton button) Checks and answers if the specified button is in a combo box.static boolean
isComponentNeverPainted
(Component component) Checks whether the specified button never paints its background.static boolean
static boolean
Checks whether Radiance is the current look-and-feel.static boolean
static boolean
isRootPaneModified
(JRootPane rootPane) Retrieves themodified
state for the specified root pane.static boolean
isScrollBarButton
(AbstractButton button) Checks and answers if the specified button is in a scroll bar.static boolean
isTabModified
(Component tabComponent) Retrieves themodified
state for the specified component in a tabbed pane.static boolean
isToolBarButton
(JComponent component) Checks and answers if the specified button is in a toolbar.static void
makeNonOpaque
(Component comp, Map<Component, Boolean> opacitySnapshot) Makes the specified component and all its descendants non-opaque.static void
markButtonAsFlat
(AbstractButton button) Marks the specified button asflat
.static void
paintFocus
(Graphics g, Component mainComp, Component focusedComp, TransitionAwareUI transitionAwareUI, double scaleFactor, Shape focusShape, Rectangle textRect, float maxAlphaCoef, float extraPadding) static void
paintFocus
(Graphics g, Component mainComp, Component focusedComp, TransitionAwareUI transitionAwareUI, double scaleFactor, Shape focusShape, Rectangle textRect, Color focusColor, float maxAlphaCoef, float extraPadding) static int
placementStrategyToOrientation
(JComponent comp, RadianceThemingSlices.PopupPlacementStrategy popupPlacementStrategy) static void
registerAWTEventListener
(AWTEventListener awtEventListener) static void
restoreOpaque
(Component comp, Map<Component, Boolean> opacitySnapshot) Restores the opacity of the specified component and all its descendants.static void
Stops all Radiance threads.static void
Tests UI threading violations on creating the specified component.static void
Tests UI threading violations on changing the state the specified component.static void
Tests UI threading violations on closing the specified window.static boolean
toAnimateCloseIconOfModifiedTab
(JTabbedPane tabbedPane, int tabIndex) Checks whether the specified tab should show modified animation only on its close button.static boolean
toShowExtraWidgets
(Component component) Checks whether the specified component can show extra Radiance-specific UI elements.static void
traceRadianceApiUsage
(Component comp, String message) static void
uninstallMenu
(JMenuItem menuItem) Uninstalls the specified menu item.static void
unregisterAWTEventListener
(AWTEventListener awtEventListener) static void
-
Field Details
-
IS_COVERED_BY_LIGHTWEIGHT_POPUPS
Client property name for marking components covered by lightweight popups. This is tracking the fix for issue 297. The client property value should be an instance ofBoolean
.- See Also:
-
TEXT_COMPONENT_AWARE
- See Also:
-
awtEventListeners
-
-
Constructor Details
-
RadianceCoreUtilities
private RadianceCoreUtilities()Private constructor. Is here to enforce using static methods only.
-
-
Method Details
-
clipString
Clips string based on specified font metrics and available width (in pixels). Returns the clipped string, which contains the beginning and the end of the input string separated by ellipses (...) in case the string is too long to fit into the specified width, and the original string otherwise.- Parameters:
metrics
- Font metrics.availableWidth
- Available width in pixels.fullText
- String to clip.- Returns:
- The clipped string, which contains the beginning and the end of the input string separated by ellipses (...) in case the string is too long to fit into the specified width, and the original string otherwise.
-
hasIcon
Checks whether the specified button has associated icon.- Parameters:
button
- Button.- Returns:
- If the button has associated icon,
true
is returned, otherwisefalse
.
-
hasText
Checks whether the specified button has associated text.- Parameters:
button
- Button.- Returns:
- If the button has associated text,
true
is returned, otherwisefalse
.
-
isComboBoxButton
Checks and answers if the specified button is in a combo box.- Parameters:
button
- the button to check- Returns:
true
if in combo box,false
otherwise
-
isScrollBarButton
Checks and answers if the specified button is in a scroll bar.- Parameters:
button
- the button to check- Returns:
true
if in scroll bar,false
otherwise
-
isToolBarButton
Checks and answers if the specified button is in a toolbar.- Parameters:
component
- the button to check- Returns:
true
if in toolbar,false
otherwise
-
isComponentNeverPainted
Checks whether the specified button never paints its background.- Parameters:
component
- Button.- Returns:
true
if the specified button never paints its background,false
otherwise.- See Also:
-
getFocusKind
Returns the focus ring kind of the specified component.- Parameters:
component
- Component.- Returns:
- The focus ring kind of the specified component.
-
getButtonShaper
Returns the button shaper of the specified button.- Parameters:
comp
- The button.- Returns:
- The button shaper of the specified button.
- See Also:
-
getFillPainter
Returns the fill painter of the specified component.- Parameters:
comp
- Component.- Returns:
- The fill painter of the specified component.
- See Also:
-
isTabModified
Retrieves themodified
state for the specified component in a tabbed pane.- Parameters:
tabComponent
- The associated tab component.- Returns:
true
if the specified component in a tabbed pane is marked as modified,false
otherwise.- See Also:
-
isRootPaneModified
Retrieves themodified
state for the specified root pane.- Parameters:
rootPane
- The root pane.- Returns:
true
if the specified root pane is marked as modified,false
otherwise.- See Also:
-
getTitlePaneButtonsProvider
-
hasCloseButton
Checks whether the specified tab has a close button.- Parameters:
tabbedPane
- Tabbed pane.tabIndex
- Tab index.- Returns:
true
if the specified tab has a close button,false
otherwise.
-
getCloseButtonSize
Returns the size of the close button for a tab in the specified tabbed pane.- Parameters:
tabbedPane
- Tabbed pane.tabIndex
- Tab index.- Returns:
- The size of the close button for a tab in the specified tabbed pane.
-
getContentBorderKind
public static RadianceThemingSlices.TabContentPaneBorderKind getContentBorderKind(JTabbedPane tabbedPane) Returns the content border kind of the specified tabbed pane.- Parameters:
tabbedPane
- Tabbed pane.- Returns:
- Content border kind of the specified tabbed pane.
- See Also:
-
toAnimateCloseIconOfModifiedTab
Checks whether the specified tab should show modified animation only on its close button.- Parameters:
tabbedPane
- Tabbed pane.tabIndex
- Tab index.- Returns:
true
if the specified tab should show modified animation only on its close button,false
otherwise.
-
getBlankImage
Retrieves transparent image of specified dimension.- Parameters:
width
- Image width.height
- Image height.- Returns:
- Transparent image of specified dimension.
-
hasNoMinSizeProperty
Checks whether the specified button should have minimal size.- Parameters:
button
- Button.- Returns:
false
if the specified button should have minimal size,true
otherwise.- See Also:
-
markButtonAsFlat
Marks the specified button asflat
. A flat button doesn't show its background unless selected, armed, pressed or (possibly) hovered over.- Parameters:
button
- Button to mark as flat.
-
hasFlatAppearance
Checks whether the specified component is flat.- Parameters:
comp
- Component.defaultValue
- The value to return.- Returns:
false
if the specified button is flat,true
otherwise.- See Also:
-
hasFlatAppearance
Computes whether the specified button has flat appearance.- Parameters:
button
- Button.- Returns:
true
if the button has flat appearance,false
otherwise.
-
getPopupPlacementStrategy
public static RadianceThemingSlices.PopupPlacementStrategy getPopupPlacementStrategy(JComboBox combobox) Returns the popup placement strategy for the specified combobox.- Parameters:
combobox
- Combobox.- Returns:
- The popup placement strategy for the specified combobox.
- See Also:
-
makeNonOpaque
Makes the specified component and all its descendants non-opaque.- Parameters:
comp
- Component.opacitySnapshot
- The "snapshot" map that will contain the original opacity status of the specified component and all its descendants.
-
restoreOpaque
Restores the opacity of the specified component and all its descendants.- Parameters:
comp
- Component.opacitySnapshot
- The "snapshot" map that contains the original opacity status of the specified component and all its descendants.
-
getActiveIconFilterStrategy
-
getEnabledIconFilterStrategy
public static RadianceThemingSlices.IconFilterStrategy getEnabledIconFilterStrategy(JComponent comp) -
getDisabledIconFilterStrategy
public static RadianceThemingSlices.IconFilterStrategy getDisabledIconFilterStrategy(JComponent comp) -
getTabCloseCallback
Returns the callback to be called upon tab closing (using the tab close button).- Parameters:
tabbedPane
- Tabbed pane.tabIndex
- Tab index.- Returns:
- Callback to be called upon tab closing (using the tab close button).
- See Also:
-
getComboPopupPrototypeDisplayValue
Returns the popup prototype display value for the specified combo box. This value is used to compute the width of the combo popup.- Parameters:
combo
- Combo box.- Returns:
- The popup prototype display value for the specified combo box.
-
getSides
Returns the set of sides registered on the specified button.- Parameters:
component
- Button.propertyName
- Client property name for retrieving the registered sides.- Returns:
- Set of sides registered on the specified button.
-
getToolbarButtonCornerRadius
Returns the corner radius of the specified toolbar button.- Parameters:
button
- Toolbar button.insets
- Button insets.- Returns:
- Corner radius of the specified toolbar button.
- See Also:
-
getEchoPerChar
Returns the number of echo characters per each password character.- Parameters:
jpf
- Password field.- Returns:
- The number of echo characters per each password character.
-
toShowExtraWidgets
Checks whether the specified component can show extra Radiance-specific UI elements.- Parameters:
component
- Component.- Returns:
true
if the specified component can show extra Radiance-specific UI elements,false
otherwise.- See Also:
-
getIconFilterStrategy
public static RadianceThemingSlices.IconFilterStrategy getIconFilterStrategy(JComponent component, ComponentState componentState) -
getFilteredIcon
public static Icon getFilteredIcon(JComponent comp, Icon orig, ComponentState componentState, Color textColor) -
getFilteredIcon
public static Icon getFilteredIcon(JTabbedPane tab, Icon orig, ComponentState componentState, Color textColor) -
getOriginalIcon
-
getMenuGutterFillAlpha
public static float getMenuGutterFillAlpha()Returns the global menu gutter fill alpha.- Returns:
- The global menu gutter fill alpha.
-
getSeparatorAppearance
public static RadianceThemingSlices.SeparatorAppearance getSeparatorAppearance(JSeparator separator) Returns the appearance for the specified separator.- Parameters:
separator
- Separator.- Returns:
- Its appearance.
- See Also:
-
getHeaderParent
Given a component, returns the parent for computing theRadianceDecorationPainter
.- Parameters:
c
- Component.- Returns:
- The parent for computing the
RadianceDecorationPainter
.
-
paintFocus
-
paintFocus
-
uninstallMenu
Uninstalls the specified menu item.- Parameters:
menuItem
- Menu item.
-
getClassLoaderForResources
Returns the class loader for loading the resource files. It is a fix by Dag Joar and Christian Schlichtherle for application running with -Xbootclasspath VM flag. In this case, using MyClass.class.getClassLoader() would return null, but the context class loader will function properly that classes will be properly loaded regardless of whether the lib is added to the system class path, the extension class path and regardless of the class loader architecture set up by some frameworks.- Returns:
- The class loader for loading the resource files.
-
isCoveredByLightweightPopups
-
getPopupParentIndexOf
Gets a component and a list of popups and returns the index of the popup that is a parent of the specified component. Is used to track issue 297 and prevent visual artifacts.- Parameters:
comp
- Component.popups
- List of popups.- Returns:
- Index of the popup which is component's parent if any, or the popup list length otherwise.
-
getBorderPainter
Returns the border painter for the specified component.- Parameters:
comp
- Component.- Returns:
- Border painter for the specified component.
- See Also:
-
getHighlightBorderPainter
Returns the highlight border painter for the specified component.- Parameters:
comp
- Component.- Returns:
- Highlight border painter for the specified component.
- See Also:
-
getHierarchy
Returns the component hierarchy.- Parameters:
comp
- Component.- Returns:
- Component hierarchy string.
-
getHierarchy
Computes the component hierarchy.- Parameters:
comp
- Component.buffer
- Hierarchy representation buffer.level
- Hierarchy level.
-
getArrowIcon
Returns the arrow icon.- Parameters:
button
- Button.orientation
- Arrow orientation.- Returns:
- Arrow icon.
-
getArrowIcon
public static Icon getArrowIcon(JComponent comp, BladeTransitionAwareIcon.TransitionAwareUIDelegate transitionAwareUIDelegate, int orientation) Returns the arrow icon.- Parameters:
comp
- Component.orientation
- Arrow orientation.- Returns:
- Arrow icon.
-
placementStrategyToOrientation
public static int placementStrategyToOrientation(JComponent comp, RadianceThemingSlices.PopupPlacementStrategy popupPlacementStrategy) -
getPlacementAwarePopupShift
public static Dimension getPlacementAwarePopupShift(boolean ltr, Dimension anchorDimension, Dimension popupDimension, Insets popupInsets, RadianceThemingSlices.PopupPlacementStrategy popupPlacementStrategy) -
getColorizationFactor
Returns the colorization factor for the specified component.- Parameters:
c
- Component.- Returns:
- The colorization factor for the specified component.
- See Also:
-
getSkin
Returns the skin of the specified component.- Parameters:
c
- Component.- Returns:
- The skin of the specified component.
-
getHashKey
Returns a hash key for the specified parameters.- Parameters:
objects
- Key components.- Returns:
- Hash key.
-
stopThreads
public static void stopThreads()Stops all Radiance threads. Improper use may result in UI artifacts and runtime exceptions. -
testComponentCreationThreadingViolation
Tests UI threading violations on creating the specified component.- Parameters:
comp
- Component.- Throws:
UiThreadingViolationException
- If the component is created off Event Dispatch Thread.
-
testComponentStateChangeThreadingViolation
Tests UI threading violations on changing the state the specified component.- Parameters:
comp
- Component.- Throws:
UiThreadingViolationException
- If the component is changing state off Event Dispatch Thread.
-
testWindowCloseThreadingViolation
Tests UI threading violations on closing the specified window.- Parameters:
w
- Window.- Throws:
UiThreadingViolationException
- If the window is closed off Event Dispatch Thread.
-
traceRadianceApiUsage
-
getScaledIconImage
public static BufferedImage getScaledIconImage(double scale, List<Image> imageList, int width, int height) ScansimageList
for best-looking image of specified dimensions. Image can be scaled and/or padded with transparency. -
canReplaceChildBackgroundColor
-
getTextComponentForTransitions
-
getTextComponentRepaintCallback
-
isOpaque
-
isCurrentLookAndFeel
public static boolean isCurrentLookAndFeel()Checks whether Radiance is the current look-and-feel. This method is for internal use only.- Returns:
true
if Radiance is the current look-and-feel,false
otherwise.
-
getButtonBarGravity
-
getTitlePaneComponent
Returns the title pane of the specified top-level window. -
updateActiveUi
public static void updateActiveUi() -
getOffsetInRootPaneCoords
-
getTopMostParentWithDecorationAreaType
public static Component getTopMostParentWithDecorationAreaType(Component comp, RadianceThemingSlices.DecorationAreaType type) -
registerAWTEventListener
-
unregisterAWTEventListener
-
getAwtEventListeners
-
getBackgroundFill
public static Color getBackgroundFill(RadianceSkin skin, RadianceThemingSlices.DecorationAreaType decorationAreaType) -
getTextBackgroundFill
-
getTextSelectionBackground
-
getTextSelectionForeground
-