org.jvnet.substance
Class Utilities

java.lang.Object
  extended by org.jvnet.substance.Utilities

public class Utilities
extends Object

Various utility functions.

Author:
Kirill Grouchnikov

Method Summary
static String clipString(FontMetrics metrics, int availableWidth, String fullText)
          Clips string based on specified font metrics and available width (in pixels).
static boolean hasIcon(AbstractButton button)
          Checks whether the specified button has associated icon.
static boolean hasText(AbstractButton button)
          Checks whether the specified button has associated text.
static boolean isComboBoxButton(AbstractButton b)
          Checks and answers if the specified button is in a combo box.
static boolean isInColorChooserDialog(Component component)
           
static boolean isScrollBarButton(AbstractButton b)
          Checks and answers if the specified button is in a combo box.
static boolean isScrollButton(AbstractButton b)
          Checks answers if the specified button is in scroll control, such as scroll bar or tabbed pane (as tab scroller).
static boolean isSpinnerButton(AbstractButton b)
          Checks and answers if the specified button is in a spinner.
static boolean isTabbedPaneButton(AbstractButton b)
          Checks and answers if the specified button is in a tabbed pane.
static boolean isTitleBarButton(AbstractButton b)
          Checks and answers if the specified button is in a title bar.
static boolean isToolBarButton(AbstractButton b)
          Checks and answers if the specified button is in a spinner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clipString

public static String clipString(FontMetrics metrics,
                                int availableWidth,
                                String fullText)
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 origianl 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 origianl string otherwise.

hasIcon

public static boolean hasIcon(AbstractButton button)
Checks whether the specified button has associated icon.

Parameters:
button - Button.
Returns:
If the button has associated icon, true is returned, otherwise false.

hasText

public static boolean hasText(AbstractButton button)
Checks whether the specified button has associated text.

Parameters:
button - Button.
Returns:
If the button has associated text, true is returned, otherwise false.

isComboBoxButton

public static boolean isComboBoxButton(AbstractButton b)
Checks and answers if the specified button is in a combo box.

Parameters:
b - the button to check
Returns:
true if in tool bar, false otherwise

isScrollBarButton

public static boolean isScrollBarButton(AbstractButton b)
Checks and answers if the specified button is in a combo box.

Parameters:
b - the button to check
Returns:
true if in tool bar, false otherwise

isTitleBarButton

public static boolean isTitleBarButton(AbstractButton b)
Checks and answers if the specified button is in a title bar.

Parameters:
b - the button to check
Returns:
true if in title bar, false otherwise

isSpinnerButton

public static boolean isSpinnerButton(AbstractButton b)
Checks and answers if the specified button is in a spinner.

Parameters:
b - the button to check
Returns:
true if in spinner, false otherwise

isToolBarButton

public static boolean isToolBarButton(AbstractButton b)
Checks and answers if the specified button is in a spinner.

Parameters:
b - the button to check
Returns:
true if in spinner, false otherwise

isTabbedPaneButton

public static boolean isTabbedPaneButton(AbstractButton b)
Checks and answers if the specified button is in a tabbed pane.

Parameters:
b - the button to check
Returns:
true if in spinner, false otherwise

isScrollButton

public static boolean isScrollButton(AbstractButton b)
Checks answers if the specified button is in scroll control, such as scroll bar or tabbed pane (as tab scroller).

Parameters:
b - the button to check
Returns:
true if in scroll control, false otherwise

isInColorChooserDialog

public static boolean isInColorChooserDialog(Component component)