org.jvnet.lafwidget
Class LafWidgetSupport

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

public class LafWidgetSupport
extends java.lang.Object

LAF-specific support for widgets. Each LAF should override relevant functions based on the internal implementation. Note that if LafWidgetRepository.setLafSupport(LafWidgetSupport) is called with a custom implementation, that implementation should not throw exceptions in any function.

Author:
Kirill Grouchnikov

Constructor Summary
LafWidgetSupport()
           
 
Method Summary
 javax.swing.Icon getArrowIcon(int orientation)
          Returns the arrow icon (the icon used in combo box drop button, scroll bar buttons etc.).
 javax.swing.JComponent getComponentForHover(javax.swing.JInternalFrame.JDesktopIcon desktopIcon)
          Returns the component for desktop icon hover (internal frame preview) functionality.
 javax.swing.Icon getLockIcon()
          Returns the lock icon.
 int getLookupButtonSize()
          Returns the size of the lookup button.
 int getLookupIconSize()
          Returns the size of the lookup icon.
 javax.swing.Icon getNumberIcon(int number)
          Returns the icon that matches the specified number.
 int getRolloverTabIndex(javax.swing.JTabbedPane tabbedPane)
          Returns the index of the rollover tab in the specified tabbed pane.
 javax.swing.Icon getSearchIcon(int dimension, java.awt.ComponentOrientation componentOrientation)
          Returns the search icon that matches the specified parameters.
 java.awt.Insets getTabAreaInsets(javax.swing.JTabbedPane tabbedPane)
          Returns the tab area insets for the specified tabbed pane.Is used in the TabOverviewDialogWidget widget.
 java.awt.Rectangle getTabRectangle(javax.swing.JTabbedPane tabbedPane, int tabIndex)
          Returns the tab rectangle for the specified tab in a tabbed pane.Is used in the TabHoverPreviewWidget widget.
 boolean hasLockIcon(java.awt.Component comp)
          Checks whether the specified component should show a lock icon.
 void markButtonAsFlat(javax.swing.AbstractButton button)
          Marks the specified button as flat.
 void paintPasswordStrengthMarker(java.awt.Graphics g, int x, int y, int width, int height, LafConstants.PasswordStrength pStrength)
          Paints password strength marker.
 void setTabAreaInsets(javax.swing.JTabbedPane tabbedPane, java.awt.Insets tabAreaInsets)
          Sets the tab area insets for the specified tabbed pane.
 boolean toInstallExtraElements(java.awt.Component comp)
          Returns indication whether additional functionality should be installed on the specified component.
 boolean toInstallMenuSearch(javax.swing.JMenuBar menuBar)
          Returns indication whether the menu search functionality should be installed on the specified menu bar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LafWidgetSupport

public LafWidgetSupport()
Method Detail

getComponentForHover

public javax.swing.JComponent getComponentForHover(javax.swing.JInternalFrame.JDesktopIcon desktopIcon)
Returns the component for desktop icon hover (internal frame preview) functionality. Is used in the DesktopIconHoverPreviewWidget widget.

Parameters:
desktopIcon - Desktop icon.
Returns:
The component for desktop icon hover (internal frame preview) functionality.

toInstallMenuSearch

public boolean toInstallMenuSearch(javax.swing.JMenuBar menuBar)
Returns indication whether the menu search functionality should be installed on the specified menu bar. Is used in the MenuSearchWidget widget.

Parameters:
menuBar - Menu bar.
Returns:
true if the menu search functionality should be installed on the specified menu bar, false otherwise.

toInstallExtraElements

public boolean toInstallExtraElements(java.awt.Component comp)
Returns indication whether additional functionality should be installed on the specified component.

Parameters:
comp - Component.
Returns:
true if additional functionality should be installed on the specified component, false otherwise.

getSearchIcon

public javax.swing.Icon getSearchIcon(int dimension,
                                      java.awt.ComponentOrientation componentOrientation)
Returns the search icon that matches the specified parameters. Is used in the MenuSearchWidget widget.

Parameters:
dimension - Search icon dimension.
componentOrientation - The orientation for the search icon. Should be considered in the implementation code for proper RTL support.
Returns:
The search icon that matches the specified parameters.

getNumberIcon

public javax.swing.Icon getNumberIcon(int number)
Returns the icon that matches the specified number. This function is used in MenuSearchWidget to set icons on menu search results. See default implementation in LafWidgetUtilities.getHexaMarker(int) that returns binary-based icons for numbers from 0 to 15. Is used in the MenuSearchWidget widget.

Parameters:
number - Number.
Returns:
The icon that matches the specified number.

markButtonAsFlat

public void markButtonAsFlat(javax.swing.AbstractButton button)
Marks the specified button as flat. A flat button doesn't show its background unless selected, armed, pressed or (possibly) hovered over. Some LAFs have flat buttons on toolbars. Is used in MenuSearchWidget and TabOverviewDialogWidget widgets.

Parameters:
button - Button to mark as flat.

getRolloverTabIndex

public int getRolloverTabIndex(javax.swing.JTabbedPane tabbedPane)
Returns the index of the rollover tab in the specified tabbed pane. Is used in the TabHoverPreviewWidget widget.

Parameters:
tabbedPane - Tabbed pane.
Returns:
The index of the rollover tab in the specified tabbed pane.
Throws:
java.lang.UnsupportedOperationException - In the base implementation.

setTabAreaInsets

public void setTabAreaInsets(javax.swing.JTabbedPane tabbedPane,
                             java.awt.Insets tabAreaInsets)
Sets the tab area insets for the specified tabbed pane. Is used in the TabOverviewDialogWidget widget.

Parameters:
tabbedPane - Tabbed pane.
tabAreaInsets - Tab area insets.
Throws:
java.lang.UnsupportedOperationException - In the base implementation.

getTabAreaInsets

public java.awt.Insets getTabAreaInsets(javax.swing.JTabbedPane tabbedPane)
Returns the tab area insets for the specified tabbed pane.Is used in the TabOverviewDialogWidget widget.

Parameters:
tabbedPane - Tabbed pane.
Returns:
The tab area insets for the specified tabbed pane.

getTabRectangle

public java.awt.Rectangle getTabRectangle(javax.swing.JTabbedPane tabbedPane,
                                          int tabIndex)
Returns the tab rectangle for the specified tab in a tabbed pane.Is used in the TabHoverPreviewWidget widget.

Parameters:
tabbedPane - Tabbed pane.
tabIndex - Index of a tab.
Returns:
The tab rectangle for the specified parameters.
Throws:
java.lang.UnsupportedOperationException - In the base implementation.

paintPasswordStrengthMarker

public void paintPasswordStrengthMarker(java.awt.Graphics g,
                                        int x,
                                        int y,
                                        int width,
                                        int height,
                                        LafConstants.PasswordStrength pStrength)
Paints password strength marker. Is used in the PasswordStrengthCheckerWidget widget. The default implementation uses orange color for LafConstants.PasswordStrength#WEAK passwords, yellow color for LafConstants.PasswordStrength#MEDIUM passwords and green color for LafConstants.PasswordStrength#STRONG passwords.

Parameters:
g - Graphics context.
x - X coordinate for the marker.
y - Y coordinate for the marker.
width - Marker width.
height - Marker height.
pStrength - Password strength.

hasLockIcon

public boolean hasLockIcon(java.awt.Component comp)
Checks whether the specified component should show a lock icon. In the default implementation, the following component show lock icons: Is used in the LockBorderWidget widget.

Parameters:
comp - Component.
Returns:
true if the specified component should show a lock icon, false otherwise.

getLockIcon

public javax.swing.Icon getLockIcon()
Returns the lock icon. Is used in LockBorderWidget widget.

Returns:
Lock icon. Should be sufficiently small (preferrably not more than 5-6 pixels wide).

getArrowIcon

public javax.swing.Icon getArrowIcon(int orientation)
Returns the arrow icon (the icon used in combo box drop button, scroll bar buttons etc.).

Parameters:
orientation - One of SwingConstants.NORTH or SwingConstants.SOUTH.
Returns:
Arrow icon.

getLookupIconSize

public int getLookupIconSize()
Returns the size of the lookup icon. Override to handle high DPI mode.

Returns:
The size of the lookup icon.

getLookupButtonSize

public int getLookupButtonSize()
Returns the size of the lookup button. Override to handle high DPI mode.

Returns:
The size of the lookup button.