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 interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static List<AWTEventListener> static final StringClient property name for marking components covered by lightweight popups.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanReplaceChildBackgroundColor(Color background) static StringclipString(FontMetrics metrics, int availableWidth, String fullText) Clips string based on specified font metrics and available width (in pixels).static IcongetArrowIcon(AbstractButton button, int orientation) Returns the arrow icon.static IcongetArrowIcon(JComponent comp, BladeTransitionAwareIcon.TransitionAwareUIDelegate transitionAwareUIDelegate, int orientation) Returns the arrow icon.static List<AWTEventListener> static ColorgetBackgroundFill(RadianceSkin skin, RadianceThemingSlices.DecorationAreaType decorationAreaType) static BufferedImagegetBlankImage(double scale, int width, int height) Retrieves transparent image of specified dimension.static intstatic RadianceButtonShapergetButtonShaper(Component comp) Returns the button shaper of the specified button.static ClassLoaderReturns the class loader for loading the resource files.static intgetCloseButtonSize(JTabbedPane tabbedPane, int tabIndex) Returns the size of the close button for a tab in the specified tabbed pane.static doubleReturns the colorization factor for the specified component.static <T> TgetComboPopupPrototypeDisplayValue(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 intReturns the number of echo characters per each password character.static IcongetFilteredIcon(JComponent comp, Icon orig, ComponentState componentState, Color textColor, CoreColorTokenUtils.ContainerType inactiveContainerType) static IcongetFilteredIcon(JTabbedPane tab, Icon orig, ComponentState componentState, Color textColor, CoreColorTokenUtils.ContainerType inactiveContainerType) getFocusKind(Component component) Returns the focus ring kind of the specified component.static HashMapKeygetHashKey(Object... objects) Returns a hash key for the specified parameters.static ContainerGiven a component, returns the parent for computing theRadianceDecorationPainter.static StringgetHierarchy(Component comp) Returns the component hierarchy.static voidgetHierarchy(Component comp, StringBuffer buffer, int level) Computes the component hierarchy.static RadianceOutlinePainterReturns the highlight outline painter for the specified component.getIconFilterStrategy(JComponent component, ComponentState componentState) static floatReturns the global menu gutter fill alpha.static Pointstatic IcongetOriginalIcon(AbstractButton b, Icon defaultIcon) static RadianceOutlinePaintergetOutlinePainter(Component comp) Returns the outline painter for the specified component.static DimensiongetPlacementAwarePopupShift(boolean ltr, Dimension anchorDimension, Dimension popupDimension, Insets popupInsets, RadianceThemingSlices.PopupPlacementStrategy popupPlacementStrategy) static intgetPopupParentIndexOf(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 BufferedImagegetScaledIconImage(double scale, List<Image> imageList, int width, int height) ScansimageListfor 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 RadianceSkinReturns the skin of the specified component.static RadianceSurfacePaintergetSurfacePainter(Component comp) Returns the surface painter of the specified component.static TabCloseCallbackgetTabCloseCallback(JTabbedPane tabbedPane, int tabIndex) Returns the callback to be called upon tab closing (using the tab close button).static ColorgetTextBackgroundFill(Component component, ComponentState componentState) static JTextComponentstatic SwingRepaintCallbackgetTextComponentRepaintCallback(JTextComponent textComponent) static ColorgetTextSelectionBackground(Component component, ComponentState componentState) static ColorgetTextSelectionForeground(Component component, ComponentState componentState) static TitlePaneButtonsProvidergetTitlePaneButtonsProvider(JRootPane rootPane) static JComponentgetTitlePaneComponent(Window window) Returns the title pane of the specified top-level window.static floatgetToolbarButtonCornerRadius(JComponent button, float insets) Returns the corner radius of the specified toolbar button.static ComponentgetTopMostParentWithDecorationAreaType(Component comp, RadianceThemingSlices.DecorationAreaType type) static booleanhasCloseButton(JTabbedPane tabbedPane, int tabIndex) Checks whether the specified tab has a close button.static booleanhasFlatAppearance(Component comp, boolean defaultValue) Checks whether the specified component is flat.static booleanhasFlatAppearance(AbstractButton button) Computes whether the specified button has flat appearance.static booleanhasIcon(AbstractButton button) Checks whether the specified button has associated icon.static booleanhasNoMinSizeProperty(AbstractButton button) Checks whether the specified button should have minimal size.static booleanhasText(AbstractButton button) Checks whether the specified button has associated text.static booleanisComboBoxButton(AbstractButton button) Checks and answers if the specified button is in a combo box.static booleanisComponentNeverPainted(Component component) Checks whether the specified button never paints its background.static booleanstatic booleanChecks whether Radiance is the current look-and-feel.static booleanstatic booleanisRootPaneModified(JRootPane rootPane) Retrieves themodifiedstate for the specified root pane.static booleanisScrollBarButton(AbstractButton button) Checks and answers if the specified button is in a scroll bar.static booleanisTabModified(Component tabComponent) Retrieves themodifiedstate for the specified component in a tabbed pane.static booleanisToolBarButton(JComponent component) Checks and answers if the specified button is in a toolbar.static voidmakeNonOpaque(Component comp, Map<Component, Boolean> opacitySnapshot) Makes the specified component and all its descendants non-opaque.static voidmarkButtonAsFlat(AbstractButton button) Marks the specified button asflat.static voidpaintFocus1X(Graphics2D graphics1X, Component mainComp, Component focusedComp, TransitionAwareUI transitionAwareUI, double scaleFactor, Shape focusShape, Rectangle textRect, float extraPadding) static voidpaintFocus1X(Graphics2D graphics1X, Component mainComp, Component focusedComp, TransitionAwareUI transitionAwareUI, double scaleFactor, Shape focusShape, Rectangle textRect, Color focusColor, float extraPadding) static intplacementStrategyToOrientation(JComponent comp, RadianceThemingSlices.PopupPlacementStrategy popupPlacementStrategy) static voidregisterAWTEventListener(AWTEventListener awtEventListener) static voidrestoreOpaque(Component comp, Map<Component, Boolean> opacitySnapshot) Restores the opacity of the specified component and all its descendants.static voidStops all Radiance threads.static voidTests UI threading violations on creating the specified component.static voidTests UI threading violations on changing the state the specified component.static voidTests UI threading violations on closing the specified window.static booleantoAnimateCloseIconOfModifiedTab(JTabbedPane tabbedPane, int tabIndex) Checks whether the specified tab should show modified animation only on its close button.static booleantoShowExtraWidgets(Component component) Checks whether the specified component can show extra Radiance-specific UI elements.static voidtraceRadianceApiUsage(Component comp, String message) static voiduninstallMenu(JMenuItem menuItem) Uninstalls the specified menu item.static voidunregisterAWTEventListener(AWTEventListener awtEventListener) static void
-
Field Details
-
IS_COVERED_BY_LIGHTWEIGHT_POPUPS
-
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,
trueis returned, otherwisefalse.
-
hasText
Checks whether the specified button has associated text.- Parameters:
button- Button.- Returns:
- If the button has associated text,
trueis returned, otherwisefalse.
-
isComboBoxButton
Checks and answers if the specified button is in a combo box.- Parameters:
button- the button to check- Returns:
trueif in combo box,falseotherwise
-
isScrollBarButton
Checks and answers if the specified button is in a scroll bar.- Parameters:
button- the button to check- Returns:
trueif in scroll bar,falseotherwise
-
isToolBarButton
Checks and answers if the specified button is in a toolbar.- Parameters:
component- the button to check- Returns:
trueif in toolbar,falseotherwise
-
isComponentNeverPainted
Checks whether the specified button never paints its background.- Parameters:
component- Button.- Returns:
trueif the specified button never paints its background,falseotherwise.- 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:
-
getSurfacePainter
Returns the surface painter of the specified component.- Parameters:
comp- Component.- Returns:
- The surface painter of the specified component.
- See Also:
-
isTabModified
Retrieves themodifiedstate for the specified component in a tabbed pane.- Parameters:
tabComponent- The associated tab component.- Returns:
trueif the specified component in a tabbed pane is marked as modified,falseotherwise.- See Also:
-
isRootPaneModified
Retrieves themodifiedstate for the specified root pane.- Parameters:
rootPane- The root pane.- Returns:
trueif the specified root pane is marked as modified,falseotherwise.- See Also:
-
getTitlePaneButtonsProvider
-
hasCloseButton
Checks whether the specified tab has a close button.- Parameters:
tabbedPane- Tabbed pane.tabIndex- Tab index.- Returns:
trueif the specified tab has a close button,falseotherwise.
-
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:
trueif the specified tab should show modified animation only on its close button,falseotherwise.
-
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:
falseif the specified button should have minimal size,trueotherwise.- 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:
falseif the specified button is flat,trueotherwise.- See Also:
-
hasFlatAppearance
Computes whether the specified button has flat appearance.- Parameters:
button- Button.- Returns:
trueif the button has flat appearance,falseotherwise.
-
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:
trueif the specified component can show extra Radiance-specific UI elements,falseotherwise.- 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, CoreColorTokenUtils.ContainerType inactiveContainerType) -
getFilteredIcon
public static Icon getFilteredIcon(JTabbedPane tab, Icon orig, ComponentState componentState, Color textColor, CoreColorTokenUtils.ContainerType inactiveContainerType) -
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.
-
paintFocus1X
public static void paintFocus1X(Graphics2D graphics1X, Component mainComp, Component focusedComp, TransitionAwareUI transitionAwareUI, double scaleFactor, Shape focusShape, Rectangle textRect, float extraPadding) -
paintFocus1X
public static void paintFocus1X(Graphics2D graphics1X, Component mainComp, Component focusedComp, TransitionAwareUI transitionAwareUI, double scaleFactor, Shape focusShape, Rectangle textRect, Color focusColor, float extraPadding) -
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.
-
getOutlinePainter
Returns the outline painter for the specified component.- Parameters:
comp- Component.- Returns:
- Outline painter for the specified component.
- See Also:
-
getHighlightOutlinePainter
Returns the highlight outline painter for the specified component.- Parameters:
comp- Component.- Returns:
- Highlight outline painter for the specified component.
- See Also:
-
getHierarchy
-
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) ScansimageListfor 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:
trueif Radiance is the current look-and-feel,falseotherwise.
-
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
-