org.jvnet.substance.utils
Class SubstanceSizeUtils

java.lang.Object
  extended by org.jvnet.substance.utils.SubstanceSizeUtils

public class SubstanceSizeUtils
extends java.lang.Object

This class is responsible for computing DPI-aware insets, stroke widths, paddings, icon sizes etc.

Author:
Kirill Grouchnikov

Constructor Summary
SubstanceSizeUtils()
           
 
Method Summary
static float getAdjustedSize(int fontSize, float baseSize, int forEachBase, float toAdjustBy)
          Gets the adjusted size.
static int getAdjustedSize(int fontSize, int baseSize, int forEachBase, int toAdjustBy, boolean toRoundAsEven)
          Gets the adjusted size.
static int getArrowIconHeight(int fontSize)
          Returns the height of arrow icons under the specified font size.
static int getArrowIconWidth(int fontSize)
          Returns the width of arrow icons under the specified font size.
static float getArrowStrokeWidth(int fontSize)
          Returns the stroke width of arrow icons under the specified font size.
static float getBorderStrokeWidth(int fontSize)
          Returns the stroke width of borders under the specified font size.
static javax.swing.border.Border getCheckBoxBorder(int fontSize)
          Returns the border for check boxes under the specified font size.
static int getCheckBoxMarkSize(int fontSize)
          Returns the check mark size for check boxes under the specified font size.
static float getClassicButtonCornerRadius(int fontSize)
          Returns the corner radius for ClassicButtonShaper under the specified font size.
static java.awt.Insets getComboBorderInsets(int fontSize)
          Returns the combo box border insets under the specified font size.
static java.awt.Insets getComboTextBorderInsets(int fontSize)
          Returns the combo box text border insets under the specified font size.
static int getComponentFontSize(java.awt.Component c)
          Computes the font size for the specified component.
static int getControlFontSize()
          Gets the current control font size.
static java.awt.Insets getDefaultBorderInsets(int fontSize)
          Returns the default border insets under the specified font size.
static float getDoubleArrowStrokeWidth(int fontSize)
          Returns the stroke width of double arrow icons under the specified font size.
static int getDragBumpDiameter(int fontSize)
          Returns the diameter of a drag bump dot under the specified font size.
static int getExtraPadding(int fontSize)
          Returns the extra padding amount under the specified font size.
static float getFocusStrokeWidth(int fontSize)
          Returns the stroke width of focus rings under the specified font size.
static java.awt.Insets getListCellRendererInsets(int fontSize)
          Returns the list cell renderer insets under the specified font size.
static int getMenuCheckMarkSize(int fontSize)
          Returns the check mark size of check box menu items and radio button menu items under the specified font size.
static int getMinButtonHeight(int fontSize)
          Returns the minimum button height under the specified font size.
static int getMinButtonWidth(int fontSize)
          Returns the maximum button height under the specified font size.
static int getPasswordDotDiameter(int fontSize)
          Returns the password dot diameter for password fields under the specified font size.
static int getPasswordDotGap(int fontSize)
          Returns the password dot gap for password fields under the specified font size.
static javax.swing.border.Border getRadioButtonBorder(int fontSize)
          Returns the border for radio buttons under the specified font size.
static int getRadioButtonMarkSize(int fontSize)
          Returns the check mark size for radio buttons under the specified font size.
static int getScrollBarWidth(int fontSize)
          Returns the width of scroll bars under the specified font size.
static int getSliderIconSize(int fontSize)
          Returns the slider thumb icon size under the specified font size.
static int getSliderTickSize(int fontSize)
          Returns the slider tick size under the specified font size.
static int getSliderTrackSize(int fontSize)
          Returns the slider track size under the specified font size.
static java.awt.Insets getSpinnerBorderInsets(int fontSize)
          Returns the spinner border insets under the specified font size.
static int getSpinnerButtonWidth(int fontSize)
          Returns the spinner button width under the specified font size.
static java.awt.Insets getSpinnerTextBorderInsets(int fontSize)
          Returns the spinner text border insets under the specified font size.
static java.awt.Insets getTabbedPaneContentInsets(int fontSize)
          Returns the tabbed pane content insets under the specified size.
static float getTabCloseButtonStrokeWidth(int fontSize)
          Returns the stroke width of tab close buttons under the specified size.
static int getTabCloseIconSize(int fontSize)
          Returns the icon size of tab close buttons under the specified size.
static java.awt.Insets getTableCellRendererInsets(int fontSize)
          Returns the table cell renderer insets under the specified font size.
static java.awt.Insets getTextBorderInsets(int fontSize)
          Returns the text border insets under the specified font size.
static int getTitlePaneIconSize()
          Returns the icon size of title pane buttons under the specified size.
static int getToolBarDragInset(int fontSize)
          Returns the tool bar drag inset under the specified font size.
static java.awt.Insets getToolBarInsets(int fontSize)
          Returns the tool bar insets under the specified font size.
static int getTreeIconSize(int fontSize)
          Returns the icon size of tree expand / collapse icons under the specified size.
static void setControlFontSize(int size)
          Sets the new value for the control font size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubstanceSizeUtils

public SubstanceSizeUtils()
Method Detail

getControlFontSize

public static int getControlFontSize()
Gets the current control font size.

Returns:
Control font size.

setControlFontSize

public static void setControlFontSize(int size)
Sets the new value for the control font size.

Parameters:
size - Control font size.

getComponentFontSize

public static int getComponentFontSize(java.awt.Component c)
Computes the font size for the specified component. If the component is null or doesn't have font set (Component.getFont() returns null), this method returns the default control font size from getControlFontSize().

Parameters:
c - Component.
Returns:
Font size for the specified component

getAdjustedSize

public static float getAdjustedSize(int fontSize,
                                    float baseSize,
                                    int forEachBase,
                                    float toAdjustBy)
Gets the adjusted size. The basic functionality of this method is as follows: For example, if you want base value to be 1.2 pixels, and have it grow by 0.1 pixel for every additional pixel in the font size, call this method with the following values:

Parameters:
fontSize - Font size.
baseSize - The base value.
forEachBase - Base units for computing the adjustment.
toAdjustBy - Adjustment amount for computing the adjustment.
Returns:
Adjusted size.

getAdjustedSize

public static int getAdjustedSize(int fontSize,
                                  int baseSize,
                                  int forEachBase,
                                  int toAdjustBy,
                                  boolean toRoundAsEven)
Gets the adjusted size. The basic functionality of this method is as follows: For example, if you want base value to be 4 pixels, and have it grow by 1 pixel for every 3 additional pixels in the font size, call this method with the following values:

Parameters:
fontSize - Font size.
baseSize - The base value.
forEachBase - Base units for computing the adjustment.
toAdjustBy - Adjustment amount for computing the adjustment.
toRoundAsEven - If true, the final value will be rounded down to the closest even value.
Returns:
Adjusted size.

getArrowIconHeight

public static int getArrowIconHeight(int fontSize)
Returns the height of arrow icons under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Height of arrow icons under the specified font size.

getArrowIconWidth

public static int getArrowIconWidth(int fontSize)
Returns the width of arrow icons under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Width of arrow icons under the specified font size.

getArrowStrokeWidth

public static float getArrowStrokeWidth(int fontSize)
Returns the stroke width of arrow icons under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Stroke width of arrow icons under the specified font size.

getBorderStrokeWidth

public static float getBorderStrokeWidth(int fontSize)
Returns the stroke width of borders under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Stroke width of borders under the specified font size.

getCheckBoxBorder

public static javax.swing.border.Border getCheckBoxBorder(int fontSize)
Returns the border for check boxes under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Border for check boxes under the specified font size.

getCheckBoxMarkSize

public static int getCheckBoxMarkSize(int fontSize)
Returns the check mark size for check boxes under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Check mark size for check boxes under the specified font size.

getClassicButtonCornerRadius

public static float getClassicButtonCornerRadius(int fontSize)
Returns the corner radius for ClassicButtonShaper under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Corner radius for ClassicButtonShaper under the specified font size.

getComboBorderInsets

public static java.awt.Insets getComboBorderInsets(int fontSize)
Returns the combo box border insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Combo box border insets under the specified font size.

getComboTextBorderInsets

public static java.awt.Insets getComboTextBorderInsets(int fontSize)
Returns the combo box text border insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Combo box text border insets under the specified font size.

getDefaultBorderInsets

public static java.awt.Insets getDefaultBorderInsets(int fontSize)
Returns the default border insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Default border insets under the specified font size.

getDoubleArrowStrokeWidth

public static float getDoubleArrowStrokeWidth(int fontSize)
Returns the stroke width of double arrow icons under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Stroke width of double arrow icons under the specified font size.

getDragBumpDiameter

public static int getDragBumpDiameter(int fontSize)
Returns the diameter of a drag bump dot under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Diameter of a drag bump dot under the specified font size.

getExtraPadding

public static int getExtraPadding(int fontSize)
Returns the extra padding amount under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Extra padding amount under the specified font size.

getFocusStrokeWidth

public static float getFocusStrokeWidth(int fontSize)
Returns the stroke width of focus rings under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Stroke width of focus rings under the specified font size.

getListCellRendererInsets

public static java.awt.Insets getListCellRendererInsets(int fontSize)
Returns the list cell renderer insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
List cell renderer insets under the specified font size.

getMenuCheckMarkSize

public static int getMenuCheckMarkSize(int fontSize)
Returns the check mark size of check box menu items and radio button menu items under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Check mark size of check box menu items and radio button menu items under the specified font size.

getMinButtonHeight

public static int getMinButtonHeight(int fontSize)
Returns the minimum button height under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Minimum button height under the specified font size.

getMinButtonWidth

public static int getMinButtonWidth(int fontSize)
Returns the maximum button height under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Maximum button height under the specified font size.

getPasswordDotDiameter

public static int getPasswordDotDiameter(int fontSize)
Returns the password dot diameter for password fields under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Password dot diameter for password fields under the specified font size.

getPasswordDotGap

public static int getPasswordDotGap(int fontSize)
Returns the password dot gap for password fields under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Password dot gap for password fields under the specified font size.

getRadioButtonBorder

public static javax.swing.border.Border getRadioButtonBorder(int fontSize)
Returns the border for radio buttons under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Border for radio buttons under the specified font size.

getRadioButtonMarkSize

public static int getRadioButtonMarkSize(int fontSize)
Returns the check mark size for radio buttons under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Check mark size for radio buttons under the specified font size.

getScrollBarWidth

public static int getScrollBarWidth(int fontSize)
Returns the width of scroll bars under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Width of scroll bars under the specified font size.

getSliderIconSize

public static int getSliderIconSize(int fontSize)
Returns the slider thumb icon size under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Slider thumb icon size under the specified font size.

getSliderTickSize

public static int getSliderTickSize(int fontSize)
Returns the slider tick size under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Slider tick size under the specified font size.

getSliderTrackSize

public static int getSliderTrackSize(int fontSize)
Returns the slider track size under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Slider track size under the specified font size.

getSpinnerBorderInsets

public static java.awt.Insets getSpinnerBorderInsets(int fontSize)
Returns the spinner border insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Spinner border insets under the specified font size.

getSpinnerButtonWidth

public static int getSpinnerButtonWidth(int fontSize)
Returns the spinner button width under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Spinner button width under the specified font size.

getSpinnerTextBorderInsets

public static java.awt.Insets getSpinnerTextBorderInsets(int fontSize)
Returns the spinner text border insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Spinner text border insets under the specified font size.

getTabbedPaneContentInsets

public static java.awt.Insets getTabbedPaneContentInsets(int fontSize)
Returns the tabbed pane content insets under the specified size. The SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL is assumed.

Parameters:
fontSize - Font size.
Returns:
Tabbed pane content insets under the specified size.

getTabCloseButtonStrokeWidth

public static float getTabCloseButtonStrokeWidth(int fontSize)
Returns the stroke width of tab close buttons under the specified size.

Parameters:
fontSize - Font size.
Returns:
Stroke width of tab close buttons under the specified size.

getTabCloseIconSize

public static int getTabCloseIconSize(int fontSize)
Returns the icon size of tab close buttons under the specified size.

Parameters:
fontSize - Font size.
Returns:
Icon size of tab close buttons under the specified size.

getTableCellRendererInsets

public static java.awt.Insets getTableCellRendererInsets(int fontSize)
Returns the table cell renderer insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Table cell renderer insets under the specified font size.

getTextBorderInsets

public static java.awt.Insets getTextBorderInsets(int fontSize)
Returns the text border insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Text border insets under the specified font size.

getTitlePaneIconSize

public static int getTitlePaneIconSize()
Returns the icon size of title pane buttons under the specified size.

Parameters:
fontSize - Font size.
Returns:
Icon size of title pane buttons under the specified size.

getToolBarDragInset

public static int getToolBarDragInset(int fontSize)
Returns the tool bar drag inset under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Tool bar drag inset under the specified font size.

getToolBarInsets

public static java.awt.Insets getToolBarInsets(int fontSize)
Returns the tool bar insets under the specified font size.

Parameters:
fontSize - Font size.
Returns:
Tool bar insets under the specified font size.

getTreeIconSize

public static int getTreeIconSize(int fontSize)
Returns the icon size of tree expand / collapse icons under the specified size.

Parameters:
fontSize - Font size.
Returns:
Icon size of tree expand / collapse icons under the specified size.