Package org.pushingpixels.lafwidget
Class LafWidgetUtilities
java.lang.Object
org.pushingpixels.lafwidget.LafWidgetUtilities
Various utility functions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Name for the internal client property that marks a component as previewable. -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
Creates a compatible image (for efficient processing and drawing).static BufferedImage
createThumbnail
(BufferedImage image, int requestedThumbWidth) Creates a thumbnail of the specified width.static void
firePropertyChangeEvent
(JComponent component, String propertyName, Object oldValue, Object newValue) Fires the matching property change event on the specific component.static Composite
Returns the composite to use for painting the specified component.static Composite
getAlphaComposite
(Component c, float translucency) static Composite
getAlphaComposite
(Component c, float translucency, Graphics g) Returns the composite to use for painting the specified component.static Composite
Returns the composite to use for painting the specified component.static BufferedImage
getBlankImage
(int width, int height) Retrieves transparent image of specified dimension.static Icon
getHexaMarker
(int value) Returns small icon representation of the specified integer value.static Icon
Returns the current icon for the specified button.static ResourceBundle
getResourceBundle
(JComponent jcomp) Returns the resource bundle for the specified component.static Icon
getSearchIcon
(int dimension, boolean leftToRight) Returns search icon.static Icon
Returns a lock icon.static boolean
hasAutomaticDnDSupport
(JTree tree) Checks whether the specified tree component has automatic drag and drop support.static boolean
hasAutoScroll
(JScrollPane scrollPane) Checks whether the specified scroll pane supports auto scroll.static boolean
hasNoAnimations
(Component comp, AnimationFacet animationFacet) Checks whether the specified component has been configured (specifically or globally) to have no animations of the specific facet.static boolean
hasTextEditContextMenu
(JTextComponent textComp) Checks whether the specified text component has edit context menu property.static boolean
Checks whether the specified text component has "flip select on escape" property.static boolean
hasTextFocusSelectAllProperty
(JTextComponent textComp) Checks whether the specified text component has "select all on focus gain" property.static void
makePreviewable
(Component comp, Map<Component, Boolean> dbSnapshot) Makes the specified component and all its descendants previewable.static void
restorePreviewable
(Component comp, Map<Component, Boolean> dbSnapshot) Restores the regular (non-previewable) status of the specified component and all its descendants.static void
Tests UI threading violations on changing the state the specified component.static boolean
toIgnoreAnimations
(Component comp) static boolean
toIgnoreGlobalLocale
(JComponent jcomp) Checks whether the label lookup should use component-specific locale on the specified component.
-
Field Details
-
PREVIEW_MODE
Name for the internal client property that marks a component as previewable.- See Also:
-
-
Method Details
-
getBlankImage
Retrieves transparent image of specified dimension.- Parameters:
width
- Image width.height
- Image height.- Returns:
- Transparent image of specified dimension.
-
createCompatibleImage
Creates a compatible image (for efficient processing and drawing).- Parameters:
image
- The original image.- Returns:
- Compatible version of the original image.
-
createThumbnail
Creates a thumbnail of the specified width.- Parameters:
image
- The original image.requestedThumbWidth
- The width of the resulting thumbnail.- Returns:
- Thumbnail of the specified width.
-
getSearchIcon
Returns search icon.- Parameters:
dimension
- Icon dimension.leftToRight
- Indicates the orientation of the resulting icon.- Returns:
- Search icon.
-
getHexaMarker
Returns small icon representation of the specified integer value. The remainder of dividing the integer by 16 is translated to four circles arranged in 2*2 grid.- Parameters:
value
- Integer value to represent.- Returns:
- Icon representation of the specified integer value.
-
makePreviewable
Makes the specified component and all its descendants previewable.- Parameters:
comp
- Component.dbSnapshot
- The "snapshot" map that will contain the original double-buffer status of the specified component and all its descendants. Key isJComponent
, value isBoolean
.
-
restorePreviewable
Restores the regular (non-previewable) status of the specified component and all its descendants.- Parameters:
comp
- Component.dbSnapshot
- The "snapshot" map that contains the original double-buffer status of the specified component and all its descendants. Key isJComponent
, value isBoolean
.
-
getSmallLockIcon
Returns a lock icon.- Returns:
- Lock icon.
-
hasTextFocusSelectAllProperty
Checks whether the specified text component has "select all on focus gain" property.- Parameters:
textComp
- Text component.- Returns:
true
if the specified text component has "select all on focus gain" property,false
otherwise.
-
hasTextFlipSelectOnEscapeProperty
Checks whether the specified text component has "flip select on escape" property.- Parameters:
textComp
- Text component.- Returns:
true
if the specified text component has "flip select on escape" property,false
otherwise.
-
hasTextEditContextMenu
Checks whether the specified text component has edit context menu property.- Parameters:
textComp
- Text component.- Returns:
true
if the specified text component has edit context menu property,false
otherwise.
-
hasAutoScroll
Checks whether the specified scroll pane supports auto scroll.- Parameters:
scrollPane
- Scroll pane component.- Returns:
true
if the specified scroll pane supports auto scroll,false
otherwise.
-
hasAutomaticDnDSupport
Checks whether the specified tree component has automatic drag and drop support.- Parameters:
tree
- Tree component.- Returns:
true
if the specified text component has automatic drag and drop support,false
otherwise.
-
toIgnoreGlobalLocale
Checks whether the label lookup should use component-specific locale on the specified component.- Parameters:
jcomp
- Component.- Returns:
true
if the custom labels should be looked up based on the component locale as returned byComponent.getLocale()
,false
if the custom labels should be looked up based on the global locale as returned byLocale.getDefault()
.
-
getResourceBundle
Returns the resource bundle for the specified component.- Parameters:
jcomp
- Component.- Returns:
- Resource bundle for the specified component.
-
hasNoAnimations
Checks whether the specified component has been configured (specifically or globally) to have no animations of the specific facet. Can be used to cull unnecessary code in animation listeners on large tables and lists.- Parameters:
comp
- Component.animationFacet
- Animation facet.- Returns:
true
if the specified component has been configured (specifically or globally) to have no animations of the specific facet,false
otherwise.
-
getIcon
Returns the current icon for the specified button. This method is for internal use only.- Parameters:
b
- Button.- Returns:
- Icon for the specified button.
-
toIgnoreAnimations
-
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.
-
firePropertyChangeEvent
public static void firePropertyChangeEvent(JComponent component, String propertyName, Object oldValue, Object newValue) Fires the matching property change event on the specific component.- Parameters:
component
- Component.propertyName
- Property name.oldValue
- Old property value.newValue
- New property value.
-
getAlphaComposite
Returns the composite to use for painting the specified component. The result should be set on theGraphics2D
before any custom rendering is done. This method can be used by application painting code and by look-and-feel delegates.- Parameters:
c
- Component.translucency
- The translucency of the original painting.g
- The original graphics context.- Returns:
- The composite to use for painting the specified component.
-
getAlphaComposite
-
getAlphaComposite
Returns the composite to use for painting the specified component. The result should be set on theGraphics2D
before any custom rendering is done. This method can be used by application painting code and by look-and-feel delegates.- Parameters:
c
- Component.- Returns:
- The composite to use for painting the specified component.
-
getAlphaComposite
Returns the composite to use for painting the specified component. The result should be set on theGraphics2D
before any custom rendering is done. This method can be used by application painting code and by look-and-feel delegates.- Parameters:
c
- Component.- Returns:
- The composite to use for painting the specified component.
-