org.jvnet.lafwidget
Class LafWidgetUtilities

java.lang.Object
  extended by org.jvnet.lafwidget.LafWidgetUtilities

public class LafWidgetUtilities
extends java.lang.Object

Various utility functions.

Author:
Kirill Grouchnikov, Romain Guy

Field Summary
static java.lang.String PREVIEW_MODE
          Name for the internal client property that marks a component as previewable.
 
Method Summary
static java.awt.image.BufferedImage createCompatibleImage(java.awt.image.BufferedImage image)
          Creates a compatible image (for efficient processing and drawing).
static java.awt.image.BufferedImage createThumbnail(java.awt.image.BufferedImage image, int requestedThumbWidth)
          Creates a thumbnail of the specified width.
static LafConstants.AnimationKind getAnimationKind(java.awt.Component component)
          Returns the animation kind of the specified component.
static java.awt.image.BufferedImage getBlankImage(int width, int height)
          Retrieves transparent image of specified dimension.
static javax.swing.Icon getHexaMarker(int value)
          Returns small icon representation of the specified integer value.
static javax.swing.Icon getIcon(javax.swing.AbstractButton b)
          Returns the current icon for the specified button.
static java.util.ResourceBundle getResourceBundle(javax.swing.JComponent jcomp)
          Returns the resource bundle for the specified component.
static javax.swing.Icon getSearchIcon(int dimension, boolean leftToRight)
          Returns search icon.
static javax.swing.Icon getSmallLockIcon()
          Returns a lock icon.
static boolean hasAutoCompletion(javax.swing.JComboBox combobox)
          Checks whether the specified combobox has auto-completion.
static boolean hasAutomaticDnDSupport(javax.swing.JTree tree)
          Checks whether the specified tree component has automatic drag and drop support.
static boolean hasNoFades(java.awt.Component comp, FadeKind fadeKind)
          Checks whether the specified fade kind has no animations on the specified component.
static boolean hasTextEditContextMenu(javax.swing.text.JTextComponent textComp)
          Checks whether the specified text component has edit context menu property.
static boolean hasTextFlipSelectOnEscapeProperty(javax.swing.text.JTextComponent textComp)
          Checks whether the specified text component has "flip select on escape" property.
static boolean hasTextFocusSelectAllProperty(javax.swing.text.JTextComponent textComp)
          Checks whether the specified text component has "select all on focus gain" property.
static boolean hasUseModelOnlyProperty(javax.swing.JComboBox combobox)
          Checks whether the specified combobox has "use model only" property.
static void makePreviewable(java.awt.Component comp, java.util.Map<java.awt.Component,java.lang.Boolean> dbSnapshot)
          Makes the specified component and all its descendants previewable.
static void restorePreviewable(java.awt.Component comp, java.util.Map<java.awt.Component,java.lang.Boolean> dbSnapshot)
          Restores the regular (non-previewable) status of the specified component and all its descendants.
static boolean toIgnoreGlobalLocale(javax.swing.JComponent jcomp)
          Checks whether the label lookup should use component-specific locale on the specified component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREVIEW_MODE

public static final java.lang.String PREVIEW_MODE
Name for the internal client property that marks a component as previewable.

See Also:
Constant Field Values
Method Detail

getBlankImage

public static java.awt.image.BufferedImage getBlankImage(int width,
                                                         int height)
Retrieves transparent image of specified dimension.

Parameters:
width - Image width.
height - Image height.
Returns:
Transparent image of specified dimension.

hasUseModelOnlyProperty

public static boolean hasUseModelOnlyProperty(javax.swing.JComboBox combobox)
Checks whether the specified combobox has "use model only" property.

Parameters:
combobox - Combobox.
Returns:
true if the specified combobox has "use model only" property, false otherwise.

hasAutoCompletion

public static boolean hasAutoCompletion(javax.swing.JComboBox combobox)
Checks whether the specified combobox has auto-completion.

Parameters:
combobox - Combobox.
Returns:
true if the specified combobox has auto-completion, false otherwise.

createCompatibleImage

public static java.awt.image.BufferedImage createCompatibleImage(java.awt.image.BufferedImage image)
Creates a compatible image (for efficient processing and drawing).

Parameters:
image - The original image.
Returns:
Compatible version of the original image.

createThumbnail

public static java.awt.image.BufferedImage createThumbnail(java.awt.image.BufferedImage image,
                                                           int requestedThumbWidth)
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

public static javax.swing.Icon getSearchIcon(int dimension,
                                             boolean leftToRight)
Returns search icon.

Parameters:
dimension - Icon dimension.
leftToRight - Indicates the orientation of the resulting icon.
Returns:
Search icon.

getHexaMarker

public static javax.swing.Icon getHexaMarker(int value)
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

public static void makePreviewable(java.awt.Component comp,
                                   java.util.Map<java.awt.Component,java.lang.Boolean> dbSnapshot)
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 is JComponent, value is Boolean.

restorePreviewable

public static void restorePreviewable(java.awt.Component comp,
                                      java.util.Map<java.awt.Component,java.lang.Boolean> dbSnapshot)
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 is JComponent, value is Boolean.

getAnimationKind

public static LafConstants.AnimationKind getAnimationKind(java.awt.Component component)
Returns the animation kind of the specified component.

Parameters:
component - Component.
Returns:
The animation kind of the specified component.

getSmallLockIcon

public static javax.swing.Icon getSmallLockIcon()
Returns a lock icon.

Returns:
Lock icon.

hasTextFocusSelectAllProperty

public static boolean hasTextFocusSelectAllProperty(javax.swing.text.JTextComponent textComp)
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

public static boolean hasTextFlipSelectOnEscapeProperty(javax.swing.text.JTextComponent textComp)
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

public static boolean hasTextEditContextMenu(javax.swing.text.JTextComponent textComp)
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.

hasAutomaticDnDSupport

public static boolean hasAutomaticDnDSupport(javax.swing.JTree tree)
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

public static boolean toIgnoreGlobalLocale(javax.swing.JComponent jcomp)
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 by Component.getLocale(), false if the custom labels should be looked up based on the global locale as returned by Locale.getDefault().

getResourceBundle

public static java.util.ResourceBundle getResourceBundle(javax.swing.JComponent jcomp)
Returns the resource bundle for the specified component.

Parameters:
jcomp - Component.
Returns:
Resource bundle for the specified component.

hasNoFades

public static boolean hasNoFades(java.awt.Component comp,
                                 FadeKind fadeKind)
Checks whether the specified fade kind has no animations on the specified component. Can be used to cull unnecessary code in animation listeners on large tables and lists.

Parameters:
comp - Component.
fadeKind - Fade kind.
Returns:
true if the specified fade kind has no animations on the specified component, false otherwise.

getIcon

public static javax.swing.Icon getIcon(javax.swing.AbstractButton b)
Returns the current icon for the specified button. This method is for internal use only.

Parameters:
b - Button.
Returns:
Icon for the specified button.