示例#1
0
  protected void paintIndeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }
    Graphics2D g2D = (Graphics2D) g;

    Insets b = progressBar.getInsets(); // area for border
    int barRectWidth = progressBar.getWidth() - (b.right + b.left);
    int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);

    Color colors[];
    if (progressBar.getForeground() instanceof UIResource) {
      if (!Utilities.isActive(c)) {
        colors = BaseLookAndFeel.getTheme().getInActiveColors();
      } else if (c.isEnabled()) {
        colors = BaseLookAndFeel.getTheme().getProgressBarColors();
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
    } else {
      Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40);
      Color loColor = ColorHelper.darker(progressBar.getForeground(), 20);
      colors = ColorHelper.createColorArr(hiColor, loColor, 20);
    }

    Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
    Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);

    // Paint the bouncing box.
    Rectangle box = getBox(null);
    if (box != null) {
      g2D.setColor(progressBar.getForeground());
      Utilities.draw3DBorder(g, cHi, cLo, box.x + 1, box.y + 1, box.width - 2, box.height - 2);
      if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
        Utilities.fillHorGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4);
      } else {
        Utilities.fillVerGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4);
      }

      // Deal with possible text painting
      if (progressBar.isStringPainted()) {
        Object savedRenderingHint = null;
        if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
          savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
          g2D.setRenderingHint(
              RenderingHints.KEY_TEXT_ANTIALIASING,
              BaseLookAndFeel.getTheme().getTextAntiAliasingHint());
        }
        if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
          paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.width, b);
        } else {
          paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.height, b);
        }
        if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
          g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
        }
      }
    }
  }
示例#2
0
  protected void paintDeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }

    Graphics2D g2D = (Graphics2D) g;
    Insets b = progressBar.getInsets(); // area for border
    int w = progressBar.getWidth() - (b.right + b.left);
    int h = progressBar.getHeight() - (b.top + b.bottom);

    // amount of progress to draw
    int amountFull = getAmountFull(b, w, h);
    Color colors[];
    if (progressBar.getForeground() instanceof UIResource) {
      if (!Utilities.isActive(c)) {
        colors = BaseLookAndFeel.getTheme().getInActiveColors();
      } else if (c.isEnabled()) {
        colors = BaseLookAndFeel.getTheme().getProgressBarColors();
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
    } else {
      Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40);
      Color loColor = ColorHelper.darker(progressBar.getForeground(), 20);
      colors = ColorHelper.createColorArr(hiColor, loColor, 20);
    }
    Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
    Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);
    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      if (Utilities.isLeftToRight(progressBar)) {
        Utilities.draw3DBorder(g, cHi, cLo, 1 + b.left, 2, amountFull - 2, h - 2);
        Utilities.fillHorGradient(g, colors, 2 + b.left, 3, amountFull - 4, h - 4);
      } else {
        Utilities.draw3DBorder(
            g,
            cHi,
            cLo,
            progressBar.getWidth() - amountFull - b.right + 2,
            2,
            amountFull - 2,
            h - 2);
        Utilities.fillHorGradient(
            g, colors, progressBar.getWidth() - amountFull - b.right + 3, 3, amountFull - 4, h - 4);
      }
    } else { // VERTICAL
      Utilities.draw3DBorder(g, cHi, cLo, 2, h - amountFull + 2, w - 2, amountFull - 2);
      Utilities.fillVerGradient(g, colors, 3, h - amountFull + 3, w - 4, amountFull - 4);
    }

    // Deal with possible text painting
    if (progressBar.isStringPainted()) {
      Object savedRenderingHint = null;
      if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
        g2D.setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            BaseLookAndFeel.getTheme().getTextAntiAliasingHint());
      }
      paintString(g, b.left, b.top, w, h, amountFull, b);
      if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
      }
    }
  }