FileDocCategorySizeDatePackage
ProgressBar.javaAPI DocGlassfish v2 API6180Fri May 04 22:35:06 BST 2007com.sun.enterprise.tools.upgrade.gui

ProgressBar

public class ProgressBar extends Component

Fields Summary
protected Dimension
size
protected int
progress
protected int
depth
Constructors Summary
public ProgressBar()

        size = new Dimension(250, 16);
        progress = 0;
        depth = 1;
    
Methods Summary
protected voiddrawProgress(java.awt.Graphics g, int i, int j)

        if(g == null)
        {
            return;
        }
        int k = size.width - 2 * depth;
        int l = (int)(((double)k / 100D) * (double)i);
        int i1 = (int)(((double)k / 100D) * (double)j);
        if(g != null)
        {
            if(i1 < l)
            {
                g.setColor(Color.white);
                g.fillRect(depth + i1, depth, l - i1, size.height - 2 * depth);
            } else
            {
                g.setColor(Color.blue);
                g.fillRect(depth + l, depth, i1 - l, size.height - 2 * depth);
            }
        }
    
protected voiddrawProgressBorder(java.awt.Graphics g)

        size = getSize();
        if(size.width == 0 || size.height == 0)
        {
            Stack stack = new Stack();
            Container container = getParent();
            Dimension dimension = null;
            if(container != null)
            {
                dimension = container.getSize();
            }
            while(container != null && (dimension.width == 0 || dimension.height == 0)) 
            {
                stack.push(container);
                container = container.getParent();
                if(container != null)
                {
                    dimension = container.getSize();
                }
            }
            if(container == null)
            {
                container = (Container)stack.pop();
            }
            if(container != null)
            {
                container.validate();
            }
            return;
        }
        Color color = getBackground();
        Color color1 = Color.white;
        Color color2 = Color.black;
        int i = 150 / depth;
        for(int j = 0; j < depth; j++)
        {
            g.setColor(color1);
            g.drawLine(j, size.height - (j + 1), j, j);
            g.drawLine(j, j, size.width - (j + 1), j);
            g.setColor(color2);
            g.drawLine(j + 1, size.height - (j + 1), size.width - (j + 1), size.height - (j + 1));
            g.drawLine(size.width - (j + 1), size.height - (j + 1), size.width - (j + 1), j + 1);
            color1 = new Color(color1.getRed() - i, color1.getGreen() - i, color1.getBlue() - i);
            color2 = new Color(color2.getRed() + i, color2.getGreen() + i, color2.getBlue() + i);
        }

        g.setColor(Color.white);
        g.fillRect(depth, depth, size.width - 2 * depth, size.height - 2 * depth);
    
public intgetDepth()

        return depth;
    
public java.awt.DimensiongetMinimumSize()

        return getPreferredSize();
    
public java.awt.DimensiongetPreferredSize()

        Container container = getParent();
        if(container == null)
        {
            return size;
        }
        Dimension dimension = container.getSize();
        if(dimension.width == 0 || dimension.height == 0)
        {
            return size;
        } else
        {
            Insets insets = container.getInsets();
            return new Dimension(dimension.width - insets.left - insets.right, size.height);
        }
    
public intgetProgress()

        return progress;
    
public voidpaint(java.awt.Graphics g)

        Dimension dimension = getSize();
        g.setClip(0, 0, dimension.width, dimension.height);
        drawProgressBorder(g);
        drawProgress(g, 0, progress);
    
public voidsetDepth(int i)

        depth = i;
    
public voidsetProgress(int i)

        Graphics g = getGraphics();
        if(g != null)
        {
            Dimension dimension = getSize();
            g.setClip(0, 0, dimension.width, dimension.height);
        }
        drawProgress(g, progress, i);
        progress = i;
    
public voidsetSize(java.awt.Dimension dimension)

        super.setSize(dimension);
        size = dimension;