protected void paintBorder(Graphics g, Dimension size, int state) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); try { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(JBColor.GRAY); ((Graphics2D)g).draw(getShape(size)); } } else if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) { //do nothing } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); ((Graphics2D)g).draw(getShape(size)); } } finally { config.restore(); } }
public void paintBorder(Graphics g, JComponent component, int state) { if (state == ActionButtonComponent.NORMAL) return; Rectangle r = new Rectangle(component.getWidth(), component.getHeight()); if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4); } } else { final double shift = UIUtil.isUnderDarcula() ? 1/0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4); config.restore(); } }
private static void paintBackground(Graphics g, Dimension size, int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.PUSHED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20)); g.fillRect(0, 0, size.width - 1, size.height - 1); g.setColor(ALPHA_120); g.drawLine(0, 0, 0, size.height - 2); g.drawLine(1, 0, size.width - 2, 0); g.setColor(ALPHA_30); g.drawRect(1, 1, size.width - 3, size.height - 3); } else if (state == ActionButtonComponent.POPPED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200)); g.fillRect(1, 1, size.width - 3, size.height - 3); } } else { final Color bg = UIUtil.getPanelBackground(); final boolean dark = UIUtil.isUnderDarcula(); g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40); g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2)); } }
private static void paintBorder(Graphics g, Dimension size, int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4); } } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4)); config.restore(); } }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { final Dimension size = new Dimension(getIconWidth() + 2*x, getIconHeight() + 2*x); myLook.paintBackground(g, size, Gray._235, ActionButtonComponent.POPPED); myLook.paintBorder(g, size, ActionButtonComponent.POPPED); myIcon.paintIcon(c, g, x + (getIconWidth() - myIcon.getIconWidth())/2, y + (getIconHeight() - myIcon.getIconHeight())/2); }
@Override public void paintBackground(Graphics g, JComponent component, int state) { if (state == ActionButtonComponent.PUSHED) { g.setColor(component.getBackground().darker()); ((Graphics2D)g).fill(g.getClip()); } }
public void paintBackground(Graphics g, JComponent component, int state) { if (state != ActionButtonComponent.NORMAL) { Component opaque = UIUtil.findNearestOpaque(component); Color bg = opaque != null? opaque.getBackground() : null; paintBackground(g, component.getSize(), bg, state); } }
public void paintIcon(Graphics g, ActionButtonComponent actionButton, Icon icon) { final int width = icon.getIconWidth(); final int height = icon.getIconHeight(); final int x = (int)Math.ceil((actionButton.getWidth() - width) / 2); final int y = (int)Math.ceil((actionButton.getHeight() - height) / 2); paintIconAt(g, actionButton, icon, x, y); }
public void paintBackground(Graphics g, JComponent component, int state) { if (state == ActionButtonComponent.NORMAL) return; Dimension dimension = component.getSize(); if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.PUSHED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, dimension.width, dimension.height, ALPHA_20)); g.fillRect(0, 0, dimension.width - 1, dimension.height - 1); g.setColor(ALPHA_120); g.drawLine(0, 0, 0, dimension.height - 2); g.drawLine(1, 0, dimension.width - 2, 0); g.setColor(ALPHA_30); g.drawRect(1, 1, dimension.width - 3, dimension.height - 3); } else if (state == ActionButtonComponent.POPPED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, dimension.height, Gray._200)); g.fillRect(1, 1, dimension.width - 3, dimension.height - 3); } } else { final Color bg = UIUtil.getPanelBackground(); final boolean dark = UIUtil.isUnderDarcula(); g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40); g.fillRect(1, 1, dimension.width - 2, dimension.height - 2); } }
public void paintIcon(Graphics g, ActionButtonComponent actionButton, Icon icon) { int width = icon.getIconWidth(); int height = icon.getIconHeight(); int x = (int)Math.ceil((actionButton.getWidth() - width) / 2); int y = (int)Math.ceil((actionButton.getHeight() - height) / 2); paintIconAt(g, actionButton, icon, x, y); }
@Override public void actionPerformed(@Nonnull AnActionEvent e) { DefaultActionGroup group = new DefaultActionGroup(ActionManager.getInstance().getAction(myActionGroup)); ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, e.getDataContext(), JBPopupFactory.ActionSelectionAid.MNEMONICS, true, ToolWindowContentUI.POPUP_PLACE); Component component = e.getInputEvent().getComponent(); if (component instanceof ActionButtonComponent) { popup.showUnderneathOf(component); } else { popup.showInCenterOf(component); } }
@Override protected void paintBorder(ActionButton button, Graphics g, Dimension size, int state) { final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.setColor(state == ActionButtonComponent.POPPED || state == ActionButtonComponent.PUSHED ? ModernUIUtil.getSelectionBackground() : ModernUIUtil.getBorderColor(button)); g.drawRect(0, 0, size.width - JBUI.scale(1), size.height - JBUI.scale(1)); config.restore(); }
@Override protected void paintBackground(ActionButton button, Graphics g, Dimension size, int state) { if (state == ActionButtonComponent.PUSHED) { g.setColor(ColorUtil.toAlpha(ModernUIUtil.getSelectionBackground(), 100)); g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2)); } }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { final Dimension size = new Dimension(getIconWidth() + 2 * x, getIconHeight() + 2 * x); paintBackground(g, size, ActionButtonComponent.POPPED); paintBorder(g, size, ActionButtonComponent.POPPED); myIcon.paintIcon(c, g, x + (getIconWidth() - myIcon.getIconWidth()) / 2, y + (getIconHeight() - myIcon.getIconHeight()) / 2); }
protected void showPopup(final ListPopup groupPopup, final AnActionEvent e) { final Component component = e.getInputEvent().getComponent(); if (component instanceof ActionButtonComponent) { groupPopup.showUnderneathOf(component); } else { groupPopup.showInBestPositionFor(e.getDataContext()); } }
public <ButtonType extends JComponent & ActionButtonComponent> void paintBackground(Graphics g, ButtonType button) { paintBackground(g, button, getState(button)); }
public <ButtonType extends JComponent & ActionButtonComponent> void paintBorder(Graphics g, ButtonType button) { paintBorder(g, button, getState(button)); }
@SuppressWarnings("MethodMayBeStatic") @ActionButtonComponent.ButtonState protected int getState(ActionButtonComponent button) { // DO NOT inline this method! Because of compiler bug up-cast from ButtonType to ActionButtonComponent is important! return button.getPopState(); }
void paintBackground(Graphics g, Dimension size, Color background, int state) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); try { Color bg = background == null ? JBColor.background() : background; if (UIUtil.isUnderAquaLookAndFeel() || (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF())) { if (state == ActionButtonComponent.PUSHED) { if (UIUtil.isUnderAquaLookAndFeel()) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20)); ((Graphics2D)g).fill(getShape(size)); g.setColor(ALPHA_30); ((Graphics2D)g).draw(getShape(size)); } else { g.setColor(ColorUtil.darker(bg, 1)); ((Graphics2D)g).fill(getShape(size)); g.setColor(Gray.xC0); ((Graphics2D)g).draw(getShape(size)); } } else if (state == ActionButtonComponent.POPPED) { if (UIUtil.isUnderAquaLookAndFeel()) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, bg, 0, size.height, ColorUtil.darker(bg, 2))); ((Graphics2D)g).fill(getShape(size)); } else { ((Graphics2D)g).setPaint(ColorUtil.darker(bg, 1)); ((Graphics2D)g).fill(getShape(size)); g.setColor(Gray.xCC); ((Graphics2D)g).draw(getShape(size)); } } } else { final boolean dark = UIUtil.isUnderDarcula(); g.setColor( state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40); ((Graphics2D)g).fill(getShape(size)); } } finally { config.restore(); } }
public void paintBorder(Graphics g, JComponent component, int state) { if (state != ActionButtonComponent.NORMAL) { paintBorder(g, component.getSize(), state); } }
public void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y) { icon.paintIcon(null, g, x, y); }
public abstract void paintBackground(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
public abstract void paintBorder(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
public abstract void paintIcon(Graphics g, ActionButtonComponent actionButton, Icon icon);
public abstract void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y);