diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/network/ProgressBar.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/network/ProgressBar.java')
| -rw-r--r-- | NET/worlds/network/ProgressBar.java | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/NET/worlds/network/ProgressBar.java b/NET/worlds/network/ProgressBar.java new file mode 100644 index 0000000..91e389d --- /dev/null +++ b/NET/worlds/network/ProgressBar.java @@ -0,0 +1,107 @@ +/* */ 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 + */
\ No newline at end of file |