Java Code Examples for sun.swing.MenuItemLayoutHelper#LayoutResult
The following examples show how to use
sun.swing.MenuItemLayoutHelper#LayoutResult .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SynthGraphicsUtils.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
static void paintIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getIcon() != null) { Icon icon; JMenuItem mi = lh.getMenuItem(); ButtonModel model = mi.getModel(); if (!model.isEnabled()) { icon = mi.getDisabledIcon(); } else if (model.isPressed() && model.isArmed()) { icon = mi.getPressedIcon(); if (icon == null) { // Use default icon icon = mi.getIcon(); } } else { icon = mi.getIcon(); } if (icon != null) { Rectangle iconRect = lr.getIconRect(); SynthIcon.paintIcon(icon, lh.getContext(), g, iconRect.x, iconRect.y, iconRect.width, iconRect.height); } } }
Example 2
Source File: SynthGraphicsUtils.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void paintIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getIcon() != null) { Icon icon; JMenuItem mi = lh.getMenuItem(); ButtonModel model = mi.getModel(); if (!model.isEnabled()) { icon = mi.getDisabledIcon(); } else if (model.isPressed() && model.isArmed()) { icon = mi.getPressedIcon(); if (icon == null) { // Use default icon icon = mi.getIcon(); } } else { icon = mi.getIcon(); } if (icon != null) { Rectangle iconRect = lr.getIconRect(); SynthIcon.paintIcon(icon, lh.getContext(), g, iconRect.x, iconRect.y, iconRect.width, iconRect.height); } } }
Example 3
Source File: SynthGraphicsUtils.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void paintText(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (!lh.getText().equals("")) { if (lh.getHtmlView() != null) { // Text is HTML lh.getHtmlView().paint(g, lr.getTextRect()); } else { // Text isn't HTML g.setColor(lh.getStyle().getColor( lh.getContext(), ColorType.TEXT_FOREGROUND)); g.setFont(lh.getStyle().getFont(lh.getContext())); lh.getGraphicsUtils().paintText(lh.getContext(), g, lh.getText(), lr.getTextRect().x, lr.getTextRect().y, lh.getMenuItem().getDisplayedMnemonicIndex()); } } }
Example 4
Source File: SynthGraphicsUtils.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void paintMenuItem(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { // Save original graphics font and color Font holdf = g.getFont(); Color holdc = g.getColor(); paintCheckIcon(g, lh, lr); paintIcon(g, lh, lr); paintText(g, lh, lr); paintAccText(g, lh, lr); paintArrowIcon(g, lh, lr); // Restore original graphics font and color g.setColor(holdc); g.setFont(holdf); }
Example 5
Source File: DarkMenuItemUIBase.java From darklaf with MIT License | 6 votes |
protected void paintIcon(final Graphics g, final JMenuItem mi, final MenuItemLayoutHelper lh, final MenuItemLayoutHelper.LayoutResult lr, final Color holdc) { if (lh.getIcon() != null) { Icon icon; ButtonModel model = mi.getModel(); if (!model.isEnabled()) { icon = mi.getDisabledIcon(); } else if (model.isPressed() && model.isArmed()) { icon = mi.getPressedIcon(); if (icon == null) { // Use default icon icon = mi.getIcon(); } } else { icon = mi.getIcon(); } if (icon != null) { icon.paintIcon(mi, g, lr.getIconRect().x, lr.getIconRect().y); g.setColor(holdc); } } }
Example 6
Source File: SynthGraphicsUtils.java From Java8CN with Apache License 2.0 | 6 votes |
static void paintIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getIcon() != null) { Icon icon; JMenuItem mi = lh.getMenuItem(); ButtonModel model = mi.getModel(); if (!model.isEnabled()) { icon = mi.getDisabledIcon(); } else if (model.isPressed() && model.isArmed()) { icon = mi.getPressedIcon(); if (icon == null) { // Use default icon icon = mi.getIcon(); } } else { icon = mi.getIcon(); } if (icon != null) { Rectangle iconRect = lr.getIconRect(); SynthIcon.paintIcon(icon, lh.getContext(), g, iconRect.x, iconRect.y, iconRect.width, iconRect.height); } } }
Example 7
Source File: SynthGraphicsUtils.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
static void paint(SynthContext context, SynthContext accContext, Graphics g, Icon checkIcon, Icon arrowIcon, String acceleratorDelimiter, int defaultTextIconGap, String propertyPrefix) { JMenuItem mi = (JMenuItem) context.getComponent(); SynthStyle style = context.getStyle(); g.setFont(style.getFont(context)); Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight()); boolean leftToRight = SynthLookAndFeel.isLeftToRight(mi); applyInsets(viewRect, mi.getInsets(), leftToRight); SynthMenuItemLayoutHelper lh = new SynthMenuItemLayoutHelper( context, accContext, mi, checkIcon, arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter, leftToRight, MenuItemLayoutHelper.useCheckAndArrow(mi), propertyPrefix); MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem(); paintMenuItem(g, lh, lr); }
Example 8
Source File: SynthGraphicsUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static void paint(SynthContext context, SynthContext accContext, Graphics g, Icon checkIcon, Icon arrowIcon, String acceleratorDelimiter, int defaultTextIconGap, String propertyPrefix) { JMenuItem mi = (JMenuItem) context.getComponent(); SynthStyle style = context.getStyle(); g.setFont(style.getFont(context)); Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight()); boolean leftToRight = SynthLookAndFeel.isLeftToRight(mi); applyInsets(viewRect, mi.getInsets(), leftToRight); SynthMenuItemLayoutHelper lh = new SynthMenuItemLayoutHelper( context, accContext, mi, checkIcon, arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter, leftToRight, MenuItemLayoutHelper.useCheckAndArrow(mi), propertyPrefix); MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem(); paintMenuItem(g, lh, lr); }
Example 9
Source File: SynthGraphicsUtils.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static void paint(SynthContext context, SynthContext accContext, Graphics g, Icon checkIcon, Icon arrowIcon, String acceleratorDelimiter, int defaultTextIconGap, String propertyPrefix) { JMenuItem mi = (JMenuItem) context.getComponent(); SynthStyle style = context.getStyle(); g.setFont(style.getFont(context)); Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight()); boolean leftToRight = SynthLookAndFeel.isLeftToRight(mi); applyInsets(viewRect, mi.getInsets(), leftToRight); SynthMenuItemLayoutHelper lh = new SynthMenuItemLayoutHelper( context, accContext, mi, checkIcon, arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter, leftToRight, MenuItemLayoutHelper.useCheckAndArrow(mi), propertyPrefix); MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem(); paintMenuItem(g, lh, lr); }
Example 10
Source File: SynthGraphicsUtils.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static void paintText(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (!lh.getText().equals("")) { if (lh.getHtmlView() != null) { // Text is HTML lh.getHtmlView().paint(g, lr.getTextRect()); } else { // Text isn't HTML g.setColor(lh.getStyle().getColor( lh.getContext(), ColorType.TEXT_FOREGROUND)); g.setFont(lh.getStyle().getFont(lh.getContext())); lh.getGraphicsUtils().paintText(lh.getContext(), g, lh.getText(), lr.getTextRect().x, lr.getTextRect().y, lh.getMenuItem().getDisplayedMnemonicIndex()); } } }
Example 11
Source File: SynthGraphicsUtils.java From Bytecoder with Apache License 2.0 | 5 votes |
static void paintAccText(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { String accText = lh.getAccText(); if (accText != null && !accText.isEmpty()) { g.setColor(lh.getAccStyle().getColor(lh.getAccContext(), ColorType.TEXT_FOREGROUND)); g.setFont(lh.getAccStyle().getFont(lh.getAccContext())); lh.getAccGraphicsUtils().paintText(lh.getAccContext(), g, accText, lr.getAccRect().x, lr.getAccRect().y, -1); } }
Example 12
Source File: SynthGraphicsUtils.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static void paintArrowIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getArrowIcon() != null) { Rectangle arrowRect = lr.getArrowRect(); SynthIcon.paintIcon(lh.getArrowIcon(), lh.getContext(), g, arrowRect.x, arrowRect.y, arrowRect.width, arrowRect.height); } }
Example 13
Source File: SynthGraphicsUtils.java From Bytecoder with Apache License 2.0 | 5 votes |
static void paintArrowIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getArrowIcon() != null) { Rectangle arrowRect = lr.getArrowRect(); paintIcon(lh.getArrowIcon(), lh.getContext(), g, arrowRect.x, arrowRect.y, arrowRect.width, arrowRect.height); } }
Example 14
Source File: SynthGraphicsUtils.java From hottub with GNU General Public License v2.0 | 5 votes |
static void paintCheckIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getCheckIcon() != null) { Rectangle checkRect = lr.getCheckRect(); SynthIcon.paintIcon(lh.getCheckIcon(), lh.getContext(), g, checkRect.x, checkRect.y, checkRect.width, checkRect.height); } }
Example 15
Source File: SynthGraphicsUtils.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static void paintAccText(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { String accText = lh.getAccText(); if (accText != null && !accText.equals("")) { g.setColor(lh.getAccStyle().getColor(lh.getAccContext(), ColorType.TEXT_FOREGROUND)); g.setFont(lh.getAccStyle().getFont(lh.getAccContext())); lh.getAccGraphicsUtils().paintText(lh.getAccContext(), g, accText, lr.getAccRect().x, lr.getAccRect().y, -1); } }
Example 16
Source File: DarculaCheckBoxMenuItemUI.java From Darcula with Apache License 2.0 | 5 votes |
@Override protected void paintCheckIcon(Graphics g2, MenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr, Color holdc, Color foreground) { Graphics2D g = (Graphics2D) g2; final GraphicsConfig config = new GraphicsConfig(g); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.translate(lr.getCheckRect().x+2, lr.getCheckRect().y+2); final int sz = 13; g.setPaint(new GradientPaint(sz / 2, 1, Gray._110, sz / 2, sz, Gray._95)); g.fillRoundRect(0, 0, sz, sz - 1 , 4, 4); g.setPaint(new GradientPaint(sz / 2, 1, Gray._120.withAlpha(0x5a), sz / 2, sz, Gray._105.withAlpha(90))); g.drawRoundRect(0, (UIUtil.isUnderDarcula() ? 1 : 0), sz, sz - 1, 4, 4); g.setPaint(Gray._40.withAlpha(180)); g.drawRoundRect(0, 0, sz, sz - 1, 4, 4); if (lh.getMenuItem().isSelected()) { g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); g.setPaint(Gray._30); g.drawLine(4, 7, 7, 10); g.drawLine(7, 10, sz, 2); g.setPaint(Gray._170); g.drawLine(4, 5, 7, 8); g.drawLine(7, 8, sz, 0); } g.translate(-lr.getCheckRect().x-2, -lr.getCheckRect().y-2); config.restore(); g.setColor(foreground); }
Example 17
Source File: SynthGraphicsUtils.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void paintAccText(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { String accText = lh.getAccText(); if (accText != null && !accText.equals("")) { g.setColor(lh.getAccStyle().getColor(lh.getAccContext(), ColorType.TEXT_FOREGROUND)); g.setFont(lh.getAccStyle().getFont(lh.getAccContext())); lh.getAccGraphicsUtils().paintText(lh.getAccContext(), g, accText, lr.getAccRect().x, lr.getAccRect().y, -1); } }
Example 18
Source File: SynthGraphicsUtils.java From JDKSourceCode1.8 with MIT License | 5 votes |
static void paintCheckIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getCheckIcon() != null) { Rectangle checkRect = lr.getCheckRect(); SynthIcon.paintIcon(lh.getCheckIcon(), lh.getContext(), g, checkRect.x, checkRect.y, checkRect.width, checkRect.height); } }
Example 19
Source File: SeaGlassGraphicsUtils.java From seaglass with Apache License 2.0 | 5 votes |
static void paintArrowIcon(Graphics g, SeaGlassMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getArrowIcon() != null) { Rectangle arrowRect = lr.getArrowRect(); SynthIcon.paintIcon(lh.getArrowIcon(), lh.getContext(), g, arrowRect.x, arrowRect.y, arrowRect.width, arrowRect.height); } }
Example 20
Source File: SynthGraphicsUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void paintArrowIcon(Graphics g, SynthMenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr) { if (lh.getArrowIcon() != null) { Rectangle arrowRect = lr.getArrowRect(); paintIcon(lh.getArrowIcon(), lh.getContext(), g, arrowRect.x, arrowRect.y, arrowRect.width, arrowRect.height); } }