Пример #1
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);
   }
 }
Пример #2
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);
  }
Пример #3
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);
  }
Пример #4
0
 public void paint(Graphics g, JComponent c) {
   JTattooUtilities.fillVerGradient(
       g, MintLookAndFeel.getTheme().getToolBarColors(), 0, 0, c.getWidth(), c.getHeight());
 }