| java.lang.Object org.apache.harmony.x.swing.ButtonCommons
ButtonCommons | public class ButtonCommons (Code) | | The storage of different utility methods used for buttons drawing.
|
Method Summary | |
public static void | drawCheck(Graphics g, Color color, int x, int y) Draws 'check' icon at the specified location. | public static Icon | getCurrentIcon(AbstractButton button) Retrieves 'current' button icon - icon which is set for the current button state (enabled/disabled/pressed).
Parameters: button - AbstractButton for which icon should be calculated. | public static Rectangle | getFocusRect(Rectangle rect1, Rectangle rect2, Rectangle rect3) Decides which bounds should be used for drawing focus. | public static String | getPaintingParameters(AbstractButton button, Rectangle viewR, Rectangle iconR, Rectangle textR, Icon icon, int leftInset, int rightInset) Calculate button layout and clipping text. | public static String | getPaintingParameters(AbstractButton button, Rectangle viewR, Rectangle iconR, Rectangle textR, Icon icon) Calculate button layout and clipping text. | public static Dimension | getPreferredSize(AbstractButton button, Icon defaultIcon, int textIconGap) Calculates the preferred button size.
Parameters: button - AbstractButton for which the preferred size to be calculated Parameters: defaultIcon - Icon which is set for the button when calculating its preferred size.Null if no icon is set. | public static Dimension | getPreferredSize(AbstractButton button, Icon defaultIcon) Calculates the preferred button size.
Parameters: button - AbstractButton for which the preferred size to be calculated Parameters: defaultIcon - Icon which is set for the button when calculating its preferred size.Null if no icon is set. | public static void | paintFocus(Graphics g, Rectangle focusRect, Color color) Paints focus border at the specified bounds. | public static void | paintPressed(Graphics g, AbstractButton button, Color color) Paints button in the pressed state (push buttons and toggle-buttons). | public static void | paintText(Graphics g, AbstractButton b, Rectangle textRect, String clippedText, Color color) Paints text on a button. | public static void | paintText(Graphics g, FontMetrics fm, String text, int displayedMnemonicIndex, Rectangle textRect, String clippedText, Color color) Paints text on the specified Graphics in the specified location.
Parameters: g - Graphics to paint on Parameters: fm - FontMetrics set for the button Parameters: text - String representing the original (not-trimmed) button text (AbstractButton.getText()) Parameters: displayedMnemonicIndex - int value specifing an index of a 'mnemonical char', i.e. |
drawCheck | public static void drawCheck(Graphics g, Color color, int x, int y)(Code) | | Draws 'check' icon at the specified location. Used for check boxes.
Parameters: g - Graphics to draw on Parameters: color - Color of the check Parameters: x - int value representing the icon's x-location Parameters: y - int value representing the icon's y-location |
getCurrentIcon | public static Icon getCurrentIcon(AbstractButton button)(Code) | | Retrieves 'current' button icon - icon which is set for the current button state (enabled/disabled/pressed).
Parameters: button - AbstractButton for which icon should be calculated. Icon or null if there is no icon for the button. |
getFocusRect | public static Rectangle getFocusRect(Rectangle rect1, Rectangle rect2, Rectangle rect3)(Code) | | Decides which bounds should be used for drawing focus.
Usually the choice is done among button bounds (rect1), button text bounds (rect2) and button icon bounds (rect3).
The order is the following: if rect1 is apecified (and not empty) rect1 is returned.
Otherwise if rect2 is specified and not empty rect2 is returned.
Otherwise rect3 is returned.
Parameters: rect1 - Rectangle of the most preferrable focus bounds Parameters: rect2 - Rectangle of the next preferrable focus bounds Parameters: rect3 - Rectangle of the least preferrable focus bounds Rectangle of the focus bounds |
getPaintingParameters | public static String getPaintingParameters(AbstractButton button, Rectangle viewR, Rectangle iconR, Rectangle textR, Icon icon, int leftInset, int rightInset)(Code) | | Calculate button layout and clipping text.
Parameters: button - AbstractButton for which parameters to be calculated Parameters: viewR - Rectangle which will be initialized as button local bounds Parameters: iconR - Rectangle which will be initialized as icon bounds Parameters: textR - Rectangle which will be initialized as text bounds Parameters: icon - Icon which is set to button (ususally that is AbstractButton.getIcon()) or null Parameters: leftInset - int value representing button left inset (border) if any Parameters: rightInset - int value representing button right inset (border) if any String which represent the text to be displayed in the button (button labelclipped and complemented with "..." if required) |
getPaintingParameters | public static String getPaintingParameters(AbstractButton button, Rectangle viewR, Rectangle iconR, Rectangle textR, Icon icon)(Code) | | Calculate button layout and clipping text.
Parameters: button - AbstractButton for which parameters to be calculated Parameters: viewR - Rectangle which will be initialized as button local bounds Parameters: iconR - Rectangle which will be initialized as icon bounds Parameters: textR - Rectangle which will be initialized as text bounds Parameters: icon - Icon which is set to button (ususally that is AbstractButton.getIcon()) or null String which represent the text to be displayed in the button (button label clipped and complemented with "..." if required) |
getPreferredSize | public static Dimension getPreferredSize(AbstractButton button, Icon defaultIcon, int textIconGap)(Code) | | Calculates the preferred button size.
Parameters: button - AbstractButton for which the preferred size to be calculated Parameters: defaultIcon - Icon which is set for the button when calculating its preferred size.Null if no icon is set. Usually that is AbstractButton.getIcon() Parameters: textIconGap - int value representing the gap between text and icon (ususally AbstractButton.getIconTextGap()) Dimension of the button preferred size |
getPreferredSize | public static Dimension getPreferredSize(AbstractButton button, Icon defaultIcon)(Code) | | Calculates the preferred button size.
Parameters: button - AbstractButton for which the preferred size to be calculated Parameters: defaultIcon - Icon which is set for the button when calculating its preferred size.Null if no icon is set. Usually that is AbstractButton.getIcon() Dimension of the button preferred size |
paintFocus | public static void paintFocus(Graphics g, Rectangle focusRect, Color color)(Code) | | Paints focus border at the specified bounds.
Parameters: g - Graphics to paint on Parameters: focusRect - Rectangle which specifies the focus border location Parameters: color - Color to paint focus |
paintPressed | public static void paintPressed(Graphics g, AbstractButton button, Color color)(Code) | | Paints button in the pressed state (push buttons and toggle-buttons).
Parameters: g - Graphics to paint on Parameters: button - AbstractButton to be painted as pressed Parameters: color - Color of the button in the pressed state |
paintText | public static void paintText(Graphics g, AbstractButton b, Rectangle textRect, String clippedText, Color color)(Code) | | Paints text on a button.
Parameters: g - Graphics to paint on Parameters: b - AbstractButton to be painted Parameters: textRect - Rectangle bounding the text location Parameters: clippedText - String to be displayed on the button surface (should be trimmed by the bouding rectangle) Parameters: color - Color of the text |
paintText | public static void paintText(Graphics g, FontMetrics fm, String text, int displayedMnemonicIndex, Rectangle textRect, String clippedText, Color color)(Code) | | Paints text on the specified Graphics in the specified location.
Parameters: g - Graphics to paint on Parameters: fm - FontMetrics set for the button Parameters: text - String representing the original (not-trimmed) button text (AbstractButton.getText()) Parameters: displayedMnemonicIndex - int value specifing an index of a 'mnemonical char', i.e. index in the text to be underscored.-1 if no mnemonic is set Parameters: textRect - Rectangle bounding the text location Parameters: clippedText - String to be displayed on the button surface (should be trimmed by the bouding rectangle) Parameters: color - Color of the text |
|
|