Java Graphics Draw drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height, final Color main, final Color progress, final int alpha, final int percentage)

Here you can find the source of drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height, final Color main, final Color progress, final int alpha, final int percentage)

Description

draw Progress Bar

License

Open Source License

Declaration

public static void drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height,
            final Color main, final Color progress, final int alpha, final int percentage) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

public class Main {
    public static void drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height,
            final Color main, final Color progress, final int alpha, final int percentage) {
        g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        final GradientPaint base = new GradientPaint(x, y, new Color(200, 200, 200, alpha), x, y + height, main);
        final GradientPaint overlay = new GradientPaint(x, y, new Color(200, 200, 200, alpha), x, y + height,
                progress);/*from   www .  j  a va 2 s .  c om*/
        if (height > width) {
            g.setPaint(base);
            g.fillRect(x, y, width, height);
            g.setPaint(overlay);
            g.fillRect(x, y + (height - (int) (height * (percentage / 100.0D))), width,
                    (int) (height * (percentage / 100.0D)));
        } else {
            g.setPaint(base);
            g.fillRect(x, y, width, height);
            g.setPaint(overlay);
            g.fillRect(x, y, (int) (width * (percentage / 100.0D)), height);
        }
        g.setColor(Color.BLACK);
        g.drawRect(x, y, width, height);
    }
}

Related

  1. drawMask(Graphics2D g2, Shape mask)
  2. drawMovingRect(int x, int y, int width, int height, Graphics g, int seed)
  3. drawOptimizedLine(Graphics g, int x1, int y1, int x2, int y2)
  4. drawPaintedShape(Graphics2D graphics, Shape shape, Paint paint, Rectangle2D paintBounds, Stroke stroke)
  5. drawPowerScaleLabel(Graphics g, int base, int power, int x, int y, boolean yAxisP)
  6. drawRainbow(Graphics2D g2, int x, int y, int Width, int Height, int Mode)
  7. drawRequiredMarker(Graphics2D g2, int x, int y, int iconSize)
  8. drawRTriangle(Graphics g, Color color, int x, int y, int r)
  9. drawScaleTick(Graphics g, int x, int y, boolean yAxisP, int length)