Package com.jgoodies.looks.common
Class MenuItemRenderer
java.lang.Object
com.jgoodies.looks.common.MenuItemRenderer
Renders and lays out menu items.
- Version:
- $Revision: 1.14 $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Used as a placeholder if icons are disabled. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
private final Font
private final Color
(package private) static Rectangle
private final Color
(package private) static Rectangle
(package private) static Rectangle
private final Color
private final Icon
protected static final String
private final boolean
(package private) static Rectangle
(package private) static final String
(package private) static final String
private final JMenuItem
private static final Icon
(package private) static Rectangle
private final Color
(package private) static Rectangle
(package private) static Rectangle
(package private) static Rectangle
-
Constructor Summary
ConstructorsConstructorDescriptionMenuItemRenderer
(JMenuItem menuItem, boolean iconBorderEnabled, Font acceleratorFont, Color selectionForeground, Color disabledForeground, Color acceleratorForeground, Color acceleratorSelectionForeground) Constructs a MenuItemRenderer for the specified menu item and settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
private static Icon
Looks up and answers the appropriate menu item icon.getPreferredMenuItemSize
(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) private Icon
getWrappedIcon
(Icon icon) Answers the wrapped icon.private boolean
Checks and answers if the menu item has a custom icon.private boolean
Checks and answers if the parent menu indicates that we should use no icons.private static boolean
protected boolean
private String
layoutMenuItem
(FontMetrics fm, String text, FontMetrics fmAccel, String acceleratorText, Icon icon, Icon checkIcon, Icon arrowIcon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewRectangle, Rectangle iconRectangle, Rectangle textRectangle, Rectangle acceleratorRectangle, Rectangle checkIconRectangle, Rectangle arrowIconRectangle, int textIconGap, int menuItemGap) Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string.private static void
paintBackground
(Graphics g, JMenuItem aMenuItem, Color bgColor) Draws the background of the menu item.void
paintMenuItem
(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) private void
Renders the text of the current menu item.private static void
private boolean
-
Field Details
-
HTML_KEY
- See Also:
-
MAX_TEXT_WIDTH
- See Also:
-
MAX_ACC_WIDTH
- See Also:
-
NO_ICON
-
zeroRect
-
iconRect
-
textRect
-
acceleratorRect
-
checkIconRect
-
arrowIconRect
-
viewRect
-
r
-
iconBorderEnabled
private final boolean iconBorderEnabled -
acceleratorFont
-
selectionForeground
-
disabledForeground
-
acceleratorForeground
-
acceleratorSelectionForeground
-
acceleratorDelimiter
-
fillerIcon
-
-
Constructor Details
-
MenuItemRenderer
public MenuItemRenderer(JMenuItem menuItem, boolean iconBorderEnabled, Font acceleratorFont, Color selectionForeground, Color disabledForeground, Color acceleratorForeground, Color acceleratorSelectionForeground) Constructs a MenuItemRenderer for the specified menu item and settings.
-
-
Method Details
-
getIcon
Looks up and answers the appropriate menu item icon. -
hasCustomIcon
private boolean hasCustomIcon()Checks and answers if the menu item has a custom icon. -
getWrappedIcon
Answers the wrapped icon. -
resetRects
private static void resetRects() -
getPreferredMenuItemSize
public Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) -
paintMenuItem
-
layoutMenuItem
private String layoutMenuItem(FontMetrics fm, String text, FontMetrics fmAccel, String acceleratorText, Icon icon, Icon checkIcon, Icon arrowIcon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewRectangle, Rectangle iconRectangle, Rectangle textRectangle, Rectangle acceleratorRectangle, Rectangle checkIconRectangle, Rectangle arrowIconRectangle, int textIconGap, int menuItemGap) Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string. Locations are computed relative to the viewRect rectangle. -
useCheckAndArrow
private boolean useCheckAndArrow() -
isLeftToRight
-
paintBackground
Draws the background of the menu item. Copied from 1.4.1 BasicMenuItem to make it visible to the MenuItemLayouter- Parameters:
g
- the paint graphicsaMenuItem
- menu item to be paintedbgColor
- selection background color- Since:
- 1.4
-
paintText
Renders the text of the current menu item.- Parameters:
g
- graphics contextaMenuItem
- menu item to rendertextRectangle
- bounding rectangle for rendering the texttext
- string to render- Since:
- 1.4
-
isMnemonicHidden
protected boolean isMnemonicHidden() -
disabledTextHasShadow
protected boolean disabledTextHasShadow() -
hideIcons
private boolean hideIcons()Checks and answers if the parent menu indicates that we should use no icons.
-