Example #1
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (JTattooUtilities.isFrameActive((JComponent) c)) {
     g.setColor(AbstractLookAndFeel.getFrameColor());
   } else {
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 40));
   }
   g.drawRect(x, y, w - 1, h - 1);
 }
Example #2
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   Color borderColorLo = AbstractLookAndFeel.getFrameColor();
   Color borderColorHi =
       ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
   if (c.getParent() instanceof JMenuBar) {
     if (model.isArmed() || model.isSelected()) {
       g.setColor(borderColorLo);
       g.drawLine(x, y, x + w - 1, y);
       g.drawLine(x, y, x, y + h - 1);
       g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
       g.setColor(borderColorHi);
       g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
       g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
     }
   } else {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(borderColorLo);
       g.drawLine(x, y, x + w - 1, y);
       g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
       g.setColor(borderColorHi);
       g.drawLine(x, y + 1, x + w - 2, y + 1);
     }
   }
 }
Example #3
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   Color logoColor = AbstractLookAndFeel.getMenuSelectionBackgroundColor();
   Color borderColorLo = AbstractLookAndFeel.getFrameColor();
   Color borderColorHi =
       ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
   g.setColor(logoColor);
   if (JTattooUtilities.isLeftToRight(c)) {
     int dx = getBorderInsets(c).left;
     g.fillRect(x, y, dx - 1, h - 1);
     paintLogo(c, g, x, y, w, h);
     // - highlight
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
     g.drawLine(x + dx, y + 1, x + w - 2, y + 1);
     g.setColor(borderColorHi);
     g.drawLine(x + 1, y, x + 1, y + h - 2);
     // - outer frame
     g.setColor(borderColorLo);
     if (isMenuBarPopup(c)) {
       // top
       g.drawLine(x + dx - 1, y, x + w, y);
       // left
       g.drawLine(x, y, x, y + h - 1);
       // bottom
       g.drawLine(x, y + h - 1, x + w, y + h - 1);
       // right
       g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
     } else {
       g.drawRect(x, y, w - 1, h - 1);
     }
     // - logo separator
     g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - 1);
   } else {
     int dx = getBorderInsets(c).right;
     g.fillRect(x + w - dx, y, dx, h - 1);
     paintLogo(c, g, x, y, w, h);
     // - highlight
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
     g.drawLine(x + 1, y + 1, x + w - dx - 1, y + 1);
     g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
     // - outer frame
     g.setColor(borderColorLo);
     if (isMenuBarPopup(c)) {
       // top
       g.drawLine(x, y, x + w - dx, y);
       // left
       g.drawLine(x, y, x, y + h - 1);
       // bottom
       g.drawLine(x, y + h - 1, x + w, y + h - 1);
       // right
       g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
     } else {
       g.drawRect(x, y, w - 1, h - 1);
     }
     // - logo separator
     g.drawLine(x + w - dx, y + 1, x + w - dx, y + h - 1);
   }
 }
Example #4
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);
  }
Example #5
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      Graphics2D g2D = (Graphics2D) g;
      Composite savedComposite = g2D.getComposite();
      AlphaComposite alpha =
          AlphaComposite.getInstance(
              AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
      g2D.setComposite(alpha);
      Color logoColor = AbstractLookAndFeel.getTheme().getMenuSelectionBackgroundColor();
      Color borderColorLo = AbstractLookAndFeel.getFrameColor();
      Color borderColorHi =
          ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
      g.setColor(logoColor);
      if (JTattooUtilities.isLeftToRight(c)) {
        int dx = getBorderInsets(c).left;
        g.fillRect(x, y, dx - 1, h - 1 - shadowSize);
        paintLogo(c, g, x, y, w, h);
        // - highlight
        g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
        g.drawLine(x + dx, y + 1, x + w - shadowSize - 2, y + 1);
        g.setColor(borderColorHi);
        g.drawLine(x + 1, y, x + 1, y + h - shadowSize - 2);
        // - outer frame
        g.setColor(borderColorLo);
        if (isMenuBarPopup(c)) {
          // top
          g.drawLine(x + dx - 1, y, x + w - shadowSize - 1, y);
          // left
          g.drawLine(x, y, x, y + h - shadowSize - 1);
          // bottom
          g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1);
          // right
          g.drawLine(x + w - shadowSize - 1, y + 1, x + w - shadowSize - 1, y + h - shadowSize - 1);
        } else {
          g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1);
        }
        // - logo separator
        g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - shadowSize - 1);
      } else {
        int dx = getBorderInsets(c).right - shadowSize;
        g.fillRect(x + w - dx - shadowSize, y, dx - 1, h - 1 - shadowSize);
        paintLogo(c, g, x, y, w, h);
        // - highlight
        g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
        g.drawLine(x + 1, y + 1, x + w - dx - shadowSize - 1, y + 1);
        g.drawLine(x + 1, y + 1, x + 1, y + h - shadowSize - 2);
        // - outer frame
        g.setColor(borderColorLo);
        if (isMenuBarPopup(c)) {
          // top
          g.drawLine(x, y, x + w - dx - shadowSize, y);
          // left
          g.drawLine(x, y, x, y + h - shadowSize - 1);
          // bottom
          g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1);
          // right
          g.drawLine(x + w - shadowSize - 1, y, x + w - shadowSize - 1, y + h - shadowSize - 1);
        } else {
          g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1);
        }
        // - logo separator
        g.drawLine(x + w - dx - shadowSize, y + 1, x + w - dx - shadowSize, y + h - shadowSize - 1);
      }

      // paint the shadow
      g2D.setColor(AbstractLookAndFeel.getTheme().getShadowColor());
      float alphaValue = 0.4f;
      for (int i = 0; i < shadowSize; i++) {
        alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue);
        g2D.setComposite(alpha);
        g.drawLine(
            x + w - shadowSize + i,
            y + shadowSize,
            x + w - shadowSize + i,
            y + h - shadowSize - 1 + i);
        g.drawLine(
            x + shadowSize, y + h - shadowSize + i, x + w - shadowSize + i, y + h - shadowSize + i);
        alphaValue -= (alphaValue / 2);
      }

      g2D.setComposite(savedComposite);
    }
  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);
  }