コード例 #1
0
  // draw determinate
  private void drawXpHorzProgress(Graphics g, int x, int y, int w, int h, int amountFull) {
    g.translate(x, y);

    // paint the track
    if (!progressBar.isOpaque()) {
      g.setColor(progressBar.getBackground());
      g.fillRect(0, 0, w, h);
    }

    ProgressKey key = new ProgressKey(progressBar.getForeground(), true, h);
    Object value = cache.get(key);

    if (value == null) {
      // create new image
      Image img = new BufferedImage(6, h, BufferedImage.TYPE_INT_ARGB);
      Graphics imgGraphics = img.getGraphics();

      // draw into image graphics
      Color c = progressBar.getForeground();
      Color c2 = ColorRoutines.lighten(c, 15);
      Color c3 = ColorRoutines.lighten(c, 35);
      Color c4 = ColorRoutines.lighten(c, 60);

      imgGraphics.setColor(c4);
      imgGraphics.drawLine(0, 0, 5, 0);
      imgGraphics.drawLine(0, h - 1, 5, h - 1);

      imgGraphics.setColor(c3);
      imgGraphics.drawLine(0, 1, 5, 1);
      imgGraphics.drawLine(0, h - 2, 5, h - 2);

      imgGraphics.setColor(c2);
      imgGraphics.drawLine(0, 2, 5, 2);
      imgGraphics.drawLine(0, h - 3, 5, h - 3);

      imgGraphics.setColor(c);
      imgGraphics.fillRect(0, 3, 6, h - 6);

      // dispose of image graphics
      imgGraphics.dispose();

      cache.put(key, img);
      value = img;
    }

    int mx = 0;

    while (mx < amountFull) {
      if (mx + 6 > w) {
        // paint partially
        g.drawImage((Image) value, mx, 0, w - mx, h, progressBar);
      } else {
        g.drawImage((Image) value, mx, 0, progressBar);
      }

      mx += 8;
    }

    g.translate(-x, -y);
  }
コード例 #2
0
  // draw indeterminate
  private void drawXpVertProgress(Graphics g, int x, int y, int w, int h, Rectangle boxRect) {
    // paint the track
    if (!progressBar.isOpaque()) {
      g.setColor(progressBar.getBackground());
      g.fillRect(x, y, w, h);
    }

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

    ProgressKey key = new ProgressKey(progressBar.getForeground(), false, w);
    Object value = cache.get(key);

    if (value == null) {
      // create new image
      Image img = new BufferedImage(w, 6, BufferedImage.TYPE_INT_ARGB);
      Graphics imgGraphics = img.getGraphics();

      // draw into image graphics
      Color c = progressBar.getForeground();
      Color c2 = ColorRoutines.lighten(c, 15);
      Color c3 = ColorRoutines.lighten(c, 35);
      Color c4 = ColorRoutines.lighten(c, 60);

      imgGraphics.setColor(c4);
      imgGraphics.drawLine(0, 0, 0, 5);
      imgGraphics.drawLine(w - 1, 0, w - 1, 5);

      imgGraphics.setColor(c3);
      imgGraphics.drawLine(1, 0, 1, 5);
      imgGraphics.drawLine(w - 2, 0, w - 2, 5);

      imgGraphics.setColor(c2);
      imgGraphics.drawLine(2, 0, 2, 5);
      imgGraphics.drawLine(w - 3, 0, w - 3, 5);

      imgGraphics.setColor(c);
      imgGraphics.fillRect(3, 0, w - 6, 6);

      // dispose of image graphics
      imgGraphics.dispose();

      cache.put(key, img);
      value = img;
    }

    int my = 0;

    while (my + 6 < boxRect.height) {
      g.drawImage((Image) value, 0, my, progressBar);

      my += 8;
    }

    g.translate(-boxRect.x, -boxRect.y);
  }
コード例 #3
0
  // draw determinate
  private void drawXpVertProgress(Graphics g, int x, int y, int w, int h, int amountFull) {
    g.translate(x, y);

    // paint the track
    if (!progressBar.isOpaque()) {
      g.setColor(progressBar.getBackground());
      g.fillRect(0, 0, w, h);
    }

    ProgressKey key = new ProgressKey(progressBar.getForeground(), false, w);
    Object value = cache.get(key);

    if (value == null) {
      // create new image
      Image img = new BufferedImage(w, 6, BufferedImage.TYPE_INT_ARGB);
      Graphics imgGraphics = img.getGraphics();

      // draw into image graphics
      Color c = progressBar.getForeground();
      Color c2 = ColorRoutines.lighten(c, 15);
      Color c3 = ColorRoutines.lighten(c, 35);
      Color c4 = ColorRoutines.lighten(c, 60);

      imgGraphics.setColor(c4);
      imgGraphics.drawLine(0, 0, 0, 5);
      imgGraphics.drawLine(w - 1, 0, w - 1, 5);

      imgGraphics.setColor(c3);
      imgGraphics.drawLine(1, 0, 1, 5);
      imgGraphics.drawLine(w - 2, 0, w - 2, 5);

      imgGraphics.setColor(c2);
      imgGraphics.drawLine(2, 0, 2, 5);
      imgGraphics.drawLine(w - 3, 0, w - 3, 5);

      imgGraphics.setColor(c);
      imgGraphics.fillRect(3, 0, w - 6, 6);

      // dispose of image graphics
      imgGraphics.dispose();

      cache.put(key, img);
      value = img;
    }

    // paints bottom to top...
    int my = 0;

    while (my < amountFull) {
      if (my + 6 > h) {
        // paint partially
        g.drawImage((Image) value, 0, 0, w, h - my, progressBar);
      } else {
        g.drawImage((Image) value, 0, h - my - 6, progressBar);
      }

      my += 8;
    }

    g.translate(-x, -y);
  }