Beispiel #1
0
 @Override
 public Insets getBorderInsets(Component c) {
   if (DarculaButtonUI.isSquare(c)) {
     return new InsetsUIResource(2, 0, 2, 0);
   }
   return new InsetsUIResource(8, 16, 8, 14);
 }
Beispiel #2
0
  @Override
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    final Graphics2D g2d = (Graphics2D) g;
    final Insets ins = getBorderInsets(c);
    final int yOff = (ins.top + ins.bottom) / 4;
    final boolean square = DarculaButtonUI.isSquare(c);
    int offset = square ? 1 : getOffset();
    if (c.hasFocus()) {
      if (DarculaButtonUI.isHelpButton((JComponent) c)) {
        int w = c.getWidth();
        int h = c.getHeight();
        DarculaUIUtil.paintFocusOval(g2d, (w - 22) / 2, (h - 22) / 2, 22, 22);
      } else {
        DarculaUIUtil.paintFocusRing(g2d, offset, yOff, width - 2 * offset, height - 2 * yOff);
      }
    } else {
      final GraphicsConfig config = new GraphicsConfig(g);
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
      g2d.setPaint(
          UIUtil.getGradientPaint(
              width / 2,
              y + yOff + 1,
              Gray._80.withAlpha(90),
              width / 2,
              height - 2 * yOff,
              Gray._90.withAlpha(90)));
      // g.drawRoundRect(x + offset + 1, y + yOff + 1, width - 2 * offset, height - 2*yOff, 5, 5);
      ((Graphics2D) g).setPaint(Gray._100.withAlpha(180));
      if (DarculaButtonUI.isHelpButton((JComponent) c)) {
        int w = c.getWidth();
        int h = c.getHeight();
        g.drawOval((w - 22) / 2, (h - 22) / 2, 22, 22);
      } else {
        g.drawRoundRect(
            x + offset,
            y + yOff,
            width - 2 * offset,
            height - 2 * yOff,
            square ? 3 : 5,
            square ? 3 : 5);
      }

      config.restore();
    }
  }