Java 类com.intellij.openapi.actionSystem.ActionButtonComponent 实例源码

项目:intellij-ce-playground    文件:IdeaActionButtonLook.java   
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();
  }
}
项目:tools-idea    文件:IdeaActionButtonLook.java   
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();
  }
}
项目:consulo    文件:PoppedIcon.java   
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));
  }
}
项目:consulo    文件:PoppedIcon.java   
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();
  }
}
项目:intellij-ce-playground    文件:PoppedIcon.java   
@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);
}
项目:intellij-ce-playground    文件:MacToolbarDecoratorButtonLook.java   
@Override
public void paintBackground(Graphics g, JComponent component, int state) {
  if (state == ActionButtonComponent.PUSHED) {
    g.setColor(component.getBackground().darker());
    ((Graphics2D)g).fill(g.getClip());
  }
}
项目:intellij-ce-playground    文件:IdeaActionButtonLook.java   
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);
  }
}
项目:intellij-ce-playground    文件:IdeaActionButtonLook.java   
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);
}
项目:tools-idea    文件:MacToolbarDecoratorButtonLook.java   
@Override
public void paintBackground(Graphics g, JComponent component, int state) {
  if (state == ActionButtonComponent.PUSHED) {
    g.setColor(component.getBackground().darker());
    ((Graphics2D)g).fill(g.getClip());
  }
}
项目:tools-idea    文件:IdeaActionButtonLook.java   
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);
  }
}
项目:tools-idea    文件:IdeaActionButtonLook.java   
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);
}
项目:consulo    文件:VcsLogGearActionGroup.java   
@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);
  }
}
项目:consulo    文件:ModernActionButtonUI.java   
@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();
}
项目:consulo    文件:ModernActionButtonUI.java   
@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));
  }
}
项目:consulo    文件:PoppedIcon.java   
@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);
}
项目:consulo-xml    文件:AddDomElementAction.java   
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());
  }
}
项目:intellij-ce-playground    文件:ActionButtonLook.java   
public <ButtonType extends JComponent & ActionButtonComponent> void paintBackground(Graphics g, ButtonType button) {
  paintBackground(g, button, getState(button));
}
项目:intellij-ce-playground    文件:ActionButtonLook.java   
public <ButtonType extends JComponent & ActionButtonComponent> void paintBorder(Graphics g, ButtonType button) {
  paintBorder(g, button, getState(button));
}
项目:intellij-ce-playground    文件:ActionButtonLook.java   
@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();
}
项目:intellij-ce-playground    文件:IdeaActionButtonLook.java   
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();
  }
}
项目:intellij-ce-playground    文件:IdeaActionButtonLook.java   
public void paintBorder(Graphics g, JComponent component, int state) {
  if (state != ActionButtonComponent.NORMAL) {
    paintBorder(g, component.getSize(), state);
  }
}
项目:intellij-ce-playground    文件:IdeaActionButtonLook.java   
public void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y) {
  icon.paintIcon(null, g, x, y);
}
项目:tools-idea    文件:ActionButtonLook.java   
public <ButtonType extends JComponent & ActionButtonComponent> void paintBackground(Graphics g, ButtonType button) {
  paintBackground(g, button, getState(button));
}
项目:tools-idea    文件:ActionButtonLook.java   
public <ButtonType extends JComponent & ActionButtonComponent> void paintBorder(Graphics g, ButtonType button) {
  paintBorder(g, button, getState(button));
}
项目:tools-idea    文件:ActionButtonLook.java   
@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();
}
项目:tools-idea    文件:IdeaActionButtonLook.java   
public void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y) {
  icon.paintIcon(null, g, x, y);
}
项目:intellij-ce-playground    文件:ActionButtonLook.java   
public abstract void paintBackground(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
项目:intellij-ce-playground    文件:ActionButtonLook.java   
public abstract void paintBorder(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
项目:intellij-ce-playground    文件:ActionButtonLook.java   
public abstract void paintIcon(Graphics g, ActionButtonComponent actionButton, Icon icon);
项目:intellij-ce-playground    文件:ActionButtonLook.java   
public abstract void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y);
项目:tools-idea    文件:ActionButtonLook.java   
public abstract void paintBackground(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
项目:tools-idea    文件:ActionButtonLook.java   
public abstract void paintBorder(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
项目:tools-idea    文件:ActionButtonLook.java   
public abstract void paintIcon(Graphics g, ActionButtonComponent actionButton, Icon icon);
项目:tools-idea    文件:ActionButtonLook.java   
public abstract void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y);