/* */ package NET.worlds.network; /* */ /* */ import NET.worlds.console.Console; /* */ import java.awt.Canvas; /* */ import java.awt.Color; /* */ import java.awt.Dimension; /* */ import java.awt.Event; /* */ import java.awt.Font; /* */ import java.awt.FontMetrics; /* */ import java.awt.Graphics; /* */ import java.awt.Toolkit; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class ProgressBar /* */ extends Canvas /* */ { /* */ private static final long serialVersionUID = -4391762871660491011L; /* */ private static final int borderThickness = 1; /* */ private static final int heightPadding = 2; /* */ private int barWidth; /* */ private int barHeight; /* */ private Font font; /* 37 */ private int fillWidth = -1; /* */ /* */ private int percent; /* */ /* */ public ProgressBar(int width) /* */ { /* 43 */ this.barWidth = width; /* 44 */ this.font = new Font(Console.message("DialogFont"), 1, 14); /* */ /* 46 */ FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(this.font); /* 47 */ this.barHeight = (fm.getAscent() + 4 + 2); /* */ } /* */ /* */ public void setProgress(double amt) /* */ { /* 52 */ int visibleWidth = getSize().width; /* 53 */ if (visibleWidth == 0) /* 54 */ visibleWidth = this.barWidth; /* 55 */ int width = (int)(amt * (visibleWidth - 2)); /* 56 */ if (width != this.fillWidth) { /* 57 */ this.fillWidth = width; /* 58 */ this.percent = ((int)Math.round(100.0D * amt)); /* 59 */ repaint(); /* */ } /* */ } /* */ /* */ public Dimension getPreferredSize() /* */ { /* 65 */ return new Dimension(this.barWidth, this.barHeight); /* */ } /* */ /* */ public Dimension getMinimumSize() /* */ { /* 70 */ return getPreferredSize(); /* */ } /* */ /* */ @Deprecated /* */ public boolean handleEvent(Event event) /* */ { /* 76 */ if (event.id == 201) /* 77 */ return true; /* 78 */ return super.handleEvent(event); /* */ } /* */ /* */ public void paint(Graphics g) /* */ { /* 83 */ Dimension size = getSize(); /* 84 */ int width = size.width; /* 85 */ int height = size.height; /* 86 */ g.setColor(Color.lightGray); /* 87 */ g.draw3DRect(0, 0, width - 1, height - 1, true); /* 88 */ if (this.fillWidth > 0) { /* 89 */ g.setColor(Color.blue); /* 90 */ g.fillRect(1, 1, this.fillWidth, height - /* 91 */ 2); /* */ } /* 93 */ String text = this.percent + "%"; /* 94 */ g.setFont(this.font); /* 95 */ FontMetrics fm = g.getFontMetrics(); /* 96 */ int textWidth = fm.stringWidth(text); /* 97 */ g.setColor(Color.black); /* 98 */ g.drawString(text, (width - textWidth) / 2, /* 99 */ (height + fm.getAscent()) / 2 - 1); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\ProgressBar.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */