protected void paintBackground(Graphics g) {
   int draggedColumn = -1;
   if ((header != null) && (header.getTable() != null) && header.getDraggedColumn() != null) {
     draggedColumn =
         header.getColumnModel().getColumnIndex(header.getDraggedColumn().getIdentifier());
   }
   int w = getWidth();
   int h = getHeight();
   if ((table != null) && table.isEnabled() && (col == rolloverCol || col == draggedColumn)) {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getRolloverColors(), 0, 0, w, h);
     if (drawRolloverBar()) {
       g.setColor(AbstractLookAndFeel.getFocusColor());
       g.drawLine(0, 0, w - 1, 0);
       g.drawLine(0, 1, w - 1, 1);
       g.drawLine(0, 2, w - 1, 2);
     }
   } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   } else {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   }
 }
 protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getMenuSelectionColors(), x, y, w, h);
   } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) {
     Graphics2D g2D = (Graphics2D) g;
     Composite composite = g2D.getComposite();
     AlphaComposite alpha =
         AlphaComposite.getInstance(
             AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
     g2D.setComposite(alpha);
     g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
     g.fillRect(x, y, w, h);
     g2D.setComposite(composite);
   } else {
     g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
     g.fillRect(x, y, w, h);
   }
   if (menuItem.isSelected() && menuItem.isArmed()) {
     g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
   }
 }
示例#3
0
 protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
   int w = c.getWidth();
   int h = c.getHeight();
   if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
     JTattooUtilities.fillVerGradient(
         g, AbstractLookAndFeel.getTheme().getTrackColors(), 0, 0, w, h);
   } else {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getTrackColors(), 0, 0, w, h);
   }
 }
 protected void paintBackground(Graphics g, Rectangle cellRect, int col) {
   Component component = getHeaderRenderer(col);
   int x = cellRect.x;
   int y = cellRect.y;
   int w = cellRect.width;
   int h = cellRect.height;
   if (header.getBackground() instanceof ColorUIResource) {
     if ((col == rolloverCol) && (component != null) && component.isEnabled()) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getRolloverColors(), x, y, w, h);
     } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), x, y, w, h);
     } else {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), x, y, w, h);
     }
   } else {
     g.setColor(header.getBackground());
     g.fillRect(x, y, w, h);
   }
 }
 public void paintBackground(Graphics g) {
   if (backgroundImage != null) {
     g.drawImage(backgroundImage, 0, 0, null);
   } else {
     BernsteinUtils.fillComponent(g, this);
   }
   Graphics2D g2D = (Graphics2D) g;
   Composite composite = g2D.getComposite();
   AlphaComposite alpha = null;
   if (backgroundImage != null) {
     alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue);
   } else {
     alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
   }
   g2D.setComposite(alpha);
   JTattooUtilities.fillHorGradient(
       g, AbstractLookAndFeel.getTheme().getDefaultColors(), 0, 0, getWidth(), getHeight());
   g2D.setComposite(composite);
 }
示例#6
0
  public void paintTrack(Graphics g) {
    boolean leftToRight = JTattooUtilities.isLeftToRight(slider);

    g.translate(trackRect.x, trackRect.y);
    int overhang = 4;
    int trackLeft = 0;
    int trackTop = 0;
    int trackRight = 0;
    int trackBottom = 0;

    if (slider.getOrientation() == JSlider.HORIZONTAL) {
      trackBottom = (trackRect.height - 1) - overhang;
      trackTop = trackBottom - (getTrackWidth() - 1);
      trackRight = trackRect.width - 1;
    } else {
      if (leftToRight) {
        trackLeft = (trackRect.width - overhang) - getTrackWidth();
        trackRight = (trackRect.width - overhang) - 1;
      } else {
        trackLeft = overhang;
        trackRight = overhang + getTrackWidth() - 1;
      }
      trackBottom = trackRect.height - 1;
    }

    g.setColor(AbstractLookAndFeel.getFrameColor());
    g.drawRect(trackLeft, trackTop, (trackRight - trackLeft) - 1, (trackBottom - trackTop) - 1);

    int middleOfThumb = 0;
    int fillTop = 0;
    int fillLeft = 0;
    int fillBottom = 0;
    int fillRight = 0;

    if (slider.getOrientation() == JSlider.HORIZONTAL) {
      middleOfThumb = thumbRect.x + (thumbRect.width / 2);
      middleOfThumb -= trackRect.x;
      fillTop = trackTop + 1;
      fillBottom = trackBottom - 2;

      if (!drawInverted()) {
        fillLeft = trackLeft + 1;
        fillRight = middleOfThumb;
      } else {
        fillLeft = middleOfThumb;
        fillRight = trackRight - 2;
      }
      Color colors[] = null;
      if (!JTattooUtilities.isActive(slider)) {
        colors = AbstractLookAndFeel.getTheme().getInActiveColors();
      } else {
        if (slider.isEnabled()) {
          colors = AbstractLookAndFeel.getTheme().getSliderColors();
        } else {
          colors = AbstractLookAndFeel.getTheme().getDisabledColors();
        }
      }
      JTattooUtilities.fillHorGradient(
          g, colors, fillLeft + 2, fillTop + 2, fillRight - fillLeft - 2, fillBottom - fillTop - 2);
      Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
      Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);
      JTattooUtilities.draw3DBorder(
          g,
          cHi,
          cLo,
          fillLeft + 1,
          fillTop + 1,
          fillRight - fillLeft - 1,
          fillBottom - fillTop - 1);
    } else {
      middleOfThumb = thumbRect.y + (thumbRect.height / 2);
      middleOfThumb -= trackRect.y;
      fillLeft = trackLeft + 1;
      fillRight = trackRight - 2;

      if (!drawInverted()) {
        fillTop = middleOfThumb;
        fillBottom = trackBottom - 2;
      } else {
        fillTop = trackTop + 1;
        fillBottom = middleOfThumb;
      }
      Color colors[] = null;
      if (!JTattooUtilities.isActive(slider)) {
        colors = AbstractLookAndFeel.getTheme().getInActiveColors();
      } else {
        if (slider.isEnabled()) {
          colors = AbstractLookAndFeel.getTheme().getSliderColors();
        } else {
          colors = AbstractLookAndFeel.getTheme().getDisabledColors();
        }
      }
      JTattooUtilities.fillVerGradient(
          g, colors, fillLeft + 2, fillTop + 2, fillRight - fillLeft - 2, fillBottom - fillTop - 2);
      Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
      Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);
      JTattooUtilities.draw3DBorder(
          g,
          cHi,
          cLo,
          fillLeft + 1,
          fillTop + 1,
          fillRight - fillLeft - 1,
          fillBottom - fillTop - 1);
    }
    g.translate(-trackRect.x, -trackRect.y);
  }
示例#7
0
  protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    if (!c.isEnabled()) {
      return;
    }

    g.translate(thumbBounds.x, thumbBounds.y);

    Color colors[] = getThumbColors();

    Color frameColorHi = ColorHelper.brighter(colors[1], 20);
    Color frameColorLo = ColorHelper.darker(colors[colors.length - 1], 10);

    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
      JTattooUtilities.fillVerGradient(
          g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
      JTattooUtilities.draw3DBorder(
          g,
          frameColorLo,
          ColorHelper.darker(frameColorLo, 15),
          0,
          0,
          thumbBounds.width,
          thumbBounds.height);

      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
      g.setColor(frameColorHi);
      g.drawLine(1, 1, thumbBounds.width - 2, 1);
      g.drawLine(1, 1, 1, thumbBounds.height - 2);

      int dx = 5;
      int dy = thumbBounds.height / 2 - 3;
      int dw = thumbBounds.width - 11;

      Color c1 = Color.white;
      Color c2 = Color.darkGray;

      for (int i = 0; i < 4; i++) {
        g.setColor(c1);
        g.drawLine(dx, dy, dx + dw, dy);
        dy++;
        g.setColor(c2);
        g.drawLine(dx, dy, dx + dw, dy);
        dy++;
      }
      g2D.setComposite(savedComposite);
    } else { // HORIZONTAL
      JTattooUtilities.fillHorGradient(
          g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
      JTattooUtilities.draw3DBorder(
          g,
          frameColorLo,
          ColorHelper.darker(frameColorLo, 10),
          0,
          0,
          thumbBounds.width,
          thumbBounds.height);

      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
      g.setColor(frameColorHi);
      g.drawLine(1, 1, thumbBounds.width - 2, 1);
      g.drawLine(1, 1, 1, thumbBounds.height - 2);

      int dx = thumbBounds.width / 2 - 3;
      int dy = 5;
      int dh = thumbBounds.height - 11;

      Color c1 = Color.white;
      Color c2 = Color.darkGray;

      for (int i = 0; i < 4; i++) {
        g.setColor(c1);
        g.drawLine(dx, dy, dx, dy + dh);
        dx++;
        g.setColor(c2);
        g.drawLine(dx, dy, dx, dy + dh);
        dx++;
      }
    }
    g2D.setComposite(savedComposite);

    g.translate(-thumbBounds.x, -thumbBounds.y);
  }
示例#8
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      if (!JTattooUtilities.isLeftToRight(c)) {
        x += GAP;
      }
      int w = getIconWidth() - GAP;
      int h = getIconHeight();

      Graphics2D g2D = (Graphics2D) g;
      AbstractButton button = (AbstractButton) c;
      ButtonModel model = button.getModel();
      Color colors[];
      if (button.isEnabled()) {
        if ((button.isRolloverEnabled() && model.isRollover())
            || (model.isPressed() && model.isArmed())) {
          colors = AbstractLookAndFeel.getTheme().getRolloverColors();
        } else {
          if (AbstractLookAndFeel.getTheme().doShowFocusFrame() && button.hasFocus()) {
            colors = AbstractLookAndFeel.getTheme().getFocusColors();
          } else {
            colors = AbstractLookAndFeel.getTheme().getCheckBoxColors();
          }
        }
      } else {
        colors = AbstractLookAndFeel.getTheme().getDisabledColors();
      }

      Color frameColor =
          ColorHelper.brighter(AbstractLookAndFeel.getTheme().getButtonBackgroundColor(), 6);
      Shape savedClip = g.getClip();
      Area clipArea = new Area(new Ellipse2D.Double(x, y, w + 1, h + 1));
      if (savedClip != null) {
        clipArea.intersect(new Area(savedClip));
      }
      g2D.setClip(clipArea);
      JTattooUtilities.fillHorGradient(g, colors, x, y, w, h);
      g2D.setClip(savedClip);

      Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
      g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g.setColor(frameColor);
      g.drawOval(x, y, w, h);

      if (model.isSelected()) {
        if (model.isEnabled()) {
          Color fc = AbstractLookAndFeel.getForegroundColor();
          if (ColorHelper.getGrayValue(colors[0]) < 128) {
            if (ColorHelper.getGrayValue(fc) < 128) {
              g2D.setColor(Color.white);
            } else {
              g2D.setColor(fc);
            }
          } else {
            if (ColorHelper.getGrayValue(fc) > 128) {
              g2D.setColor(Color.black);
            } else {
              g2D.setColor(fc);
            }
          }
        } else {
          g.setColor(AbstractLookAndFeel.getDisabledForegroundColor());
        }
        if (AbstractLookAndFeel.getTheme().isSmallFontSize()) {
          g2D.fillOval(x + 4, y + 4, w - 7, h - 7);
        } else if (AbstractLookAndFeel.getTheme().isMediumFontSize()) {
          g2D.fillOval(x + 4, y + 4, w - 7, h - 7);
        } else {
          g2D.fillOval(x + 5, y + 5, w - 9, h - 9);
        }
      }
      g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
    }
示例#9
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      if (!JTattooUtilities.isLeftToRight(c)) {
        x += GAP;
      }
      int w = getIconWidth() - GAP;
      int h = getIconHeight();
      AbstractButton button = (AbstractButton) c;
      ButtonModel model = button.getModel();
      Graphics2D g2D = (Graphics2D) g;
      if (button.isEnabled()) {
        if ((button.isRolloverEnabled() && model.isRollover())) {
          JTattooUtilities.fillHorGradient(
              g, AbstractLookAndFeel.getTheme().getRolloverColors(), x + 1, y + 1, w - 1, h - 1);
        } else {
          if (AbstractLookAndFeel.getTheme().doShowFocusFrame() && button.hasFocus()) {
            JTattooUtilities.fillHorGradient(
                g, AbstractLookAndFeel.getTheme().getFocusColors(), x + 1, y + 1, w - 1, h - 1);
          } else {
            JTattooUtilities.fillHorGradient(
                g, AbstractLookAndFeel.getTheme().getCheckBoxColors(), x + 1, y + 1, w - 1, h - 1);
          }
        }
      } else {
        JTattooUtilities.fillHorGradient(
            g, AbstractLookAndFeel.getTheme().getDisabledColors(), x + 1, y + 1, w - 1, h - 1);
      }

      Color frameColor =
          ColorHelper.brighter(AbstractLookAndFeel.getTheme().getButtonBackgroundColor(), 6);
      Color loFrameColor =
          ColorHelper.darker(AbstractLookAndFeel.getTheme().getButtonBackgroundColor(), 50);

      g.setColor(frameColor);
      g.drawRect(x, y, w, h);
      Composite savedComposite = g2D.getComposite();
      AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
      g2D.setComposite(alpha);
      g.setColor(loFrameColor);
      g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
      g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
      g2D.setComposite(savedComposite);

      Icon checkIcon;
      Icon checkDisabledIcon;
      Icon checkInverseIcon;
      if (AbstractLookAndFeel.getTheme().isSmallFontSize()) {
        checkIcon = SMALL_CHECK_ICON;
        checkDisabledIcon = SMALL_CHECK_DISABLED_ICON;
        checkInverseIcon = SMALL_CHECK_INVERSE_ICON;
      } else if (AbstractLookAndFeel.getTheme().isMediumFontSize()) {
        checkIcon = MEDIUM_CHECK_ICON;
        checkDisabledIcon = MEDIUM_CHECK_DISABLED_ICON;
        checkInverseIcon = MEDIUM_CHECK_INVERSE_ICON;
      } else {
        checkIcon = LARGE_CHECK_ICON;
        checkDisabledIcon = LARGE_CHECK_DISABLED_ICON;
        checkInverseIcon = LARGE_CHECK_INVERSE_ICON;
      }
      int xi = x + ((w - checkIcon.getIconWidth()) / 2) + 1;
      int yi = y + ((h - checkIcon.getIconHeight()) / 2);
      int gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getButtonForegroundColor());
      if (model.isPressed() && model.isArmed()) {
        Color bc =
            gv > 128
                ? AbstractLookAndFeel.getTheme().getSelectionForegroundColor()
                : AbstractLookAndFeel.getTheme().getSelectionBackgroundColor();
        Color fc = gv > 128 ? ColorHelper.brighter(bc, 20) : ColorHelper.darker(bc, 40);
        g.setColor(fc);
        g.drawRect(x + 4, y + 4, w - 8, h - 8);
        g.setColor(bc);
        g.fillRect(x + 5, y + 5, w - 9, h - 9);
      } else if (model.isSelected()) {
        if (!model.isEnabled()) {
          checkDisabledIcon.paintIcon(c, g, xi + 1, yi);
        } else {
          if (gv > 128) {
            checkIcon.paintIcon(c, g, xi, yi);
          } else {
            checkInverseIcon.paintIcon(c, g, xi + 1, yi + 1);
          }
        }
      }
    }
示例#10
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      Graphics2D g2D = (Graphics2D) g;
      boolean active = isActive(c);
      boolean resizable = isResizable(c);
      int th = getTitleHeight(c);
      Color frameColor = AbstractLookAndFeel.getWindowInactiveBorderColor();
      Color titleColor = AbstractLookAndFeel.getWindowInactiveTitleColorLight();
      if (active) {
        titleColor = AbstractLookAndFeel.getWindowTitleColorLight();
        frameColor = AbstractLookAndFeel.getWindowBorderColor();
      }

      if (!resizable) {
        Insets bi = getBorderInsets(c);
        g.setColor(frameColor);
        g.drawRect(x, y, w - 1, h - 1);
        if (active) {
          g.setColor(AbstractLookAndFeel.getWindowTitleColorDark());
        } else {
          g.setColor(AbstractLookAndFeel.getWindowInactiveTitleColorDark());
        }
        for (int i = 1; i < bi.left; i++) {
          g.drawRect(i, i, w - (2 * i) - 1, h - (2 * i) - 1);
        }
        g.setColor(frameColor);
        g.drawLine(bi.left - 1, y + th + bi.top, bi.left - 1, y + h - bi.bottom);
        g.drawLine(w - bi.right, y + th + bi.top, w - bi.right, y + h - bi.bottom);
        g.drawLine(bi.left - 1, y + h - bi.bottom, w - bi.right, y + h - bi.bottom);
        return;
      }
      g.setColor(titleColor);
      g.fillRect(x, y + 1, w, dw - 1);
      g.fillRect(x + 1, y + h - dw, w - 2, dw - 1);
      Color color = ColorHelper.brighter(AbstractLookAndFeel.getWindowTitleColorDark(), 30);
      if (active) {
        JTattooUtilities.fillHorGradient(
            g, AbstractLookAndFeel.getTheme().getWindowTitleColors(), 1, dw, dw, th + 1);
        JTattooUtilities.fillHorGradient(
            g, AbstractLookAndFeel.getTheme().getWindowTitleColors(), w - dw, dw, dw, th + 1);

        Color c1 = AbstractLookAndFeel.getTheme().getWindowTitleColorDark();
        Color c2 = AbstractLookAndFeel.getTheme().getWindowTitleColorLight();
        g2D.setPaint(new GradientPaint(0, dw + th + 1, c1, 0, h - th - (2 * dw), c2));
        g.fillRect(1, dw + th + 1, dw - 1, h - th - (2 * dw));
        g.fillRect(w - dw, dw + th + 1, dw - 1, h - th - (2 * dw));
        g2D.setPaint(null);
      } else {
        JTattooUtilities.fillHorGradient(
            g, AbstractLookAndFeel.getTheme().getWindowInactiveTitleColors(), 1, dw, dw, th + 1);
        JTattooUtilities.fillHorGradient(
            g,
            AbstractLookAndFeel.getTheme().getWindowInactiveTitleColors(),
            w - dw,
            dw,
            dw,
            th + 1);

        Color c1 = AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorDark();
        Color c2 = AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorLight();
        g2D.setPaint(new GradientPaint(0, dw + th + 1, c1, 0, h - th - (2 * dw), c2));
        g.fillRect(1, dw + th + 1, dw - 1, h - th - (2 * dw));
        g.fillRect(w - dw, dw + th + 1, dw - 1, h - th - (2 * dw));
        g2D.setPaint(null);
      }
      if (active && resizable) {
        int d = dw + 12;
        // unten
        color = AbstractLookAndFeel.getWindowTitleColorDark();
        Color cHi = ColorHelper.brighter(color, 30);
        Color cLo = ColorHelper.darker(color, 20);

        // links
        g.setColor(color);
        g.fillRect(x + 1, y + h - d, dw - 1, d - 1);
        g.fillRect(x + dw, y + h - dw, d - dw - 1, d - dw - 1);

        g.setColor(cLo);
        g.drawLine(x + 1, y + h - d - 2, x + dw - 2, y + h - d - 2);
        g.drawLine(x + dw - 2, y + h - d - 2, x + dw - 2, y + h - dw);
        g.drawLine(x + dw - 2, y + h - dw, x + d - 1, y + h - dw);
        g.drawLine(x + d - 1, y + h - dw, x + d - 1, y + h - 1);

        g.setColor(cHi);
        g.drawLine(x + 1, y + h - d - 1, x + dw - 3, y + h - d - 1);
        g.drawLine(x + dw - 1, y + h - d - 1, x + dw - 1, y + h - dw - 1);
        g.drawLine(x + dw - 1, y + h - dw + 1, x + d - 2, y + h - dw + 1);
        g.drawLine(x + d - 2, y + h - dw + 1, x + d - 2, y + h - 1);

        // rechts
        g.setColor(color);
        g.fillRect(x + w - d - 1, y + h - dw, d, dw - 1);
        g.fillRect(x + w - dw, y + h - d - 1, dw - 1, d);

        g.setColor(cLo);
        g.drawLine(x + w - dw - 1, y + h - d - 2, x + w - 1, y + h - d - 2);
        g.drawLine(x + w - dw, y + h - d - 2, x + w - dw, y + h - dw);
        g.drawLine(x + w - d - 1, y + h - dw, x + w - dw, y + h - dw);
        g.drawLine(x + w - d - 1, y + h - dw, x + w - d - 1, y + h - 1);

        g.setColor(cHi);
        g.drawLine(x + w - dw + 1, y + h - d - 1, x + w - 1, y + h - d - 1);
        g.drawLine(x + w - dw + 1, y + h - d - 1, x + w - dw + 1, y + h - dw);
        g.drawLine(x + w - d, y + h - dw + 1, x + w - dw + 1, y + h - dw + 1);
        g.drawLine(x + w - d, y + h - dw + 1, x + w - d, y + h - 1);
      }
      g.setColor(frameColor);
      g.drawRect(x, y, w - 1, h - 1);
      g.drawLine(x + dw - 1, y + dw + th, x + dw - 1, y + h - dw);
      g.drawLine(x + w - dw, y + dw + th, x + w - dw, y + h - dw);
      g.drawLine(x + dw - 1, y + h - dw, x + w - dw, y + h - dw);
    }
示例#11
0
  protected void paintBackground(Graphics g, AbstractButton b) {
    if (!b.isContentAreaFilled() || (b.getParent() instanceof JMenuBar)) {
      return;
    }

    if (!(b.isBorderPainted() && (b.getBorder() instanceof UIResource))) {
      super.paintBackground(g, b);
      return;
    }

    int width = b.getWidth();
    int height = b.getHeight();
    ButtonModel model = b.getModel();
    Graphics2D g2D = (Graphics2D) g;
    Composite composite = g2D.getComposite();
    Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (((width < 64) || (height < 16)) && ((b.getText() == null) || b.getText().length() == 0)) {
      if (model.isSelected()) {
        Color color = ColorHelper.darker(b.getBackground(), 20);
        g2D.setColor(color);
        g2D.fillRect(0, 0, width - 1, height - 1);
        if (model.isEnabled()) {
          g2D.setColor(AbstractLookAndFeel.getFrameColor());
        } else {
          g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20));
        }
        g2D.drawRect(0, 0, width - 1, height - 1);
      } else {
        Color[] colors = null;
        if (b.getBackground() instanceof ColorUIResource) {
          if (!model.isEnabled()) {
            colors = AbstractLookAndFeel.getTheme().getDisabledColors();
          } else if (b.isRolloverEnabled() && model.isRollover()) {
            colors = AbstractLookAndFeel.getTheme().getRolloverColors();
          } else {
            colors = AbstractLookAndFeel.getTheme().getButtonColors();
          }
        } else {
          colors =
              ColorHelper.createColorArr(
                  ColorHelper.brighter(b.getBackground(), 20),
                  ColorHelper.darker(b.getBackground(), 20),
                  20);
        }
        JTattooUtilities.fillHorGradient(g, colors, 0, 0, width - 1, height - 1);
        if (model.isEnabled()) {
          g2D.setColor(AbstractLookAndFeel.getFrameColor());
        } else {
          g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20));
        }
        g2D.drawRect(0, 0, width - 1, height - 1);
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
        g2D.setComposite(alpha);
        g2D.setColor(Color.white);
        g2D.drawRect(1, 1, width - 3, height - 3);
      }
    } else if (model.isPressed() && model.isArmed()) {
      int d = height - 2;
      Color color = AbstractLookAndFeel.getTheme().getSelectionBackgroundColor();
      g2D.setColor(color);
      g2D.fillRoundRect(0, 0, width - 1, height - 1, d, d);

      g2D.setColor(ColorHelper.darker(color, 40));
      g2D.drawRoundRect(0, 0, width - 1, height - 1, d, d);
    } else if (model.isSelected()) {
      int d = height - 2;
      Color color = ColorHelper.darker(b.getBackground(), 20);
      g2D.setColor(color);
      g2D.fillRoundRect(0, 0, width - 1, height - 1, d, d);

      if (model.isEnabled()) {
        g2D.setColor(AbstractLookAndFeel.getFrameColor());
      } else {
        g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20));
      }
      g2D.drawRoundRect(0, 0, width - 1, height - 1, d, d);
    } else {
      int d = height - 2;

      Color[] colors = null;
      if (b.getBackground() instanceof ColorUIResource) {
        if (!model.isEnabled()) {
          colors = AbstractLookAndFeel.getTheme().getDisabledColors();
        } else if (b.isRolloverEnabled() && model.isRollover()) {
          colors = AbstractLookAndFeel.getTheme().getRolloverColors();
        } else {
          colors = AbstractLookAndFeel.getTheme().getButtonColors();
        }
      } else {
        colors =
            ColorHelper.createColorArr(
                ColorHelper.brighter(b.getBackground(), 20),
                ColorHelper.darker(b.getBackground(), 20),
                20);
      }

      Shape savedClip = g.getClip();
      Area clipArea = new Area(new RoundRectangle2D.Double(0, 0, width - 1, height - 1, d, d));
      clipArea.intersect(new Area(savedClip));
      g2D.setClip(clipArea);
      JTattooUtilities.fillHorGradient(g, colors, 0, 0, width, height);
      g2D.setClip(savedClip);

      if (model.isEnabled()) {
        g2D.setColor(AbstractLookAndFeel.getFrameColor());
      } else {
        g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20));
      }
      g2D.drawRoundRect(0, 0, width - 1, height - 1, d, d);

      AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
      g2D.setComposite(alpha);
      g2D.setColor(Color.white);
      g2D.drawRoundRect(1, 1, width - 3, height - 3, d - 2, d - 2);
    }
    g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
    g2D.setComposite(composite);
  }