summaryrefslogtreecommitdiff
path: root/NET/worlds/console/ProgressBar.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/console/ProgressBar.java')
-rw-r--r--NET/worlds/console/ProgressBar.java227
1 files changed, 227 insertions, 0 deletions
diff --git a/NET/worlds/console/ProgressBar.java b/NET/worlds/console/ProgressBar.java
new file mode 100644
index 0000000..b8a458f
--- /dev/null
+++ b/NET/worlds/console/ProgressBar.java
@@ -0,0 +1,227 @@
+/* */ package NET.worlds.console;
+/* */
+/* */ import NET.worlds.network.CacheEntry;
+/* */ import java.awt.Button;
+/* */ import java.awt.Canvas;
+/* */ import java.awt.Color;
+/* */ import java.awt.Event;
+/* */ import java.awt.Font;
+/* */ import java.awt.FontMetrics;
+/* */ import java.awt.Frame;
+/* */ import java.awt.Graphics;
+/* */ import java.awt.GridLayout;
+/* */ import java.awt.Image;
+/* */ import java.awt.Label;
+/* */ import java.awt.Panel;
+/* */ import java.awt.TextField;
+/* */ import java.awt.event.ActionEvent;
+/* */ import java.awt.event.ActionListener;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class ProgressBar
+/* */ extends Frame
+/* */ implements ActionListener
+/* */ {
+/* */ private static final long serialVersionUID = -5057984821909220829L;
+/* */ private int _total;
+/* 44 */ private int _current = 0;
+/* */
+/* */
+/* 47 */ private boolean _offline = false;
+/* */
+/* */
+/* */
+/* */ private Canvas _barCanvas;
+/* */
+/* */
+/* */
+/* */ private Label _header;
+/* */
+/* */
+/* */
+/* */ private TextField _message;
+/* */
+/* */
+/* */
+/* */ private Button _offlineButton;
+/* */
+/* */
+/* */
+/* */ private static final int BAR_WIDTH = 250;
+/* */
+/* */
+/* */
+/* */ private static final int BAR_HEIGHT = 20;
+/* */
+/* */
+/* */
+/* */ private static final int BORDER = 10;
+/* */
+/* */
+/* */
+/* */ public ProgressBar(String header, int total)
+/* */ {
+/* 81 */ this._header = new Label(header);
+/* 82 */ this._total = total;
+/* 83 */ if (this._total < 1)
+/* 84 */ this._total = 1;
+/* 85 */ build();
+/* 86 */ setTitle("Loading Progress");
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void advance()
+/* */ {
+/* 95 */ this._current += 1;
+/* 96 */ if (this._current > this._total)
+/* 97 */ this._current = this._total;
+/* 98 */ paintBar();
+/* */ }
+/* */
+/* */ public int current()
+/* */ {
+/* 103 */ return this._current;
+/* */ }
+/* */
+/* */ public int total()
+/* */ {
+/* 108 */ return this._total;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public int percentComplete()
+/* */ {
+/* 116 */ return this._current * 100 / this._total;
+/* */ }
+/* */
+/* */ public boolean offline()
+/* */ {
+/* 121 */ return this._offline;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public void setMessage(String m)
+/* */ {
+/* 129 */ this._message.setText(m);
+/* 130 */ update(getGraphics());
+/* */ }
+/* */
+/* */ protected int pixelsComplete()
+/* */ {
+/* 135 */ return this._current * 250 / this._total;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ protected void build()
+/* */ {
+/* 144 */ setLayout(new GridLayout(3, 1, 10, 0));
+/* 145 */ this._barCanvas = new Canvas();
+/* 146 */ this._barCanvas.setSize(270, 40);
+/* 147 */ add(this._barCanvas);
+/* */
+/* 149 */ this._message = new TextField("Working...");
+/* 150 */ this._message.setEditable(false);
+/* 151 */ add(this._message);
+/* */
+/* */
+/* */
+/* 155 */ Panel buttonPanel = new Panel();
+/* 156 */ this._offlineButton = new Button("Go Offline");
+/* 157 */ this._offlineButton.addActionListener(this);
+/* 158 */ buttonPanel.add(this._offlineButton);
+/* 159 */ add(buttonPanel);
+/* */
+/* 161 */ pack();
+/* */ }
+/* */
+/* */
+/* */ public void paint(Graphics g)
+/* */ {
+/* 167 */ paintBar();
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void actionPerformed(ActionEvent ae)
+/* */ {
+/* 176 */ if (ae.getSource() == this._offlineButton) {
+/* 177 */ this._offline = true;
+/* 178 */ CacheEntry.setOffline();
+/* 179 */ this._offlineButton.setEnabled(false);
+/* */ }
+/* */ }
+/* */
+/* */ @Deprecated
+/* */ public boolean handleEvent(Event e)
+/* */ {
+/* 186 */ if (e.id == 201) {
+/* 187 */ setVisible(false);
+/* 188 */ dispose();
+/* 189 */ Main.end();
+/* 190 */ throw new Error("User cancelled startup.");
+/* */ }
+/* */
+/* 193 */ return super.handleEvent(e);
+/* */ }
+/* */
+/* */ protected void paintBar()
+/* */ {
+/* 198 */ Graphics g = this._barCanvas.getGraphics();
+/* 199 */ Image off = createImage(270, 40);
+/* 200 */ Graphics offG = off.getGraphics();
+/* 201 */ offG.setColor(getBackground());
+/* 202 */ offG.fillRect(0, 0, 270, 40);
+/* 203 */ offG.setColor(Color.gray);
+/* 204 */ offG.fillRect(10, 10, pixelsComplete(), 20);
+/* 205 */ offG.setColor(Color.darkGray);
+/* 206 */ offG.draw3DRect(11, 11, pixelsComplete() - 1,
+/* 207 */ 18, true);
+/* 208 */ offG.setColor(Color.black);
+/* 209 */ offG.drawRect(10, 10, 250, 20);
+/* 210 */ String perString = Integer.toString(percentComplete()) + "% Complete";
+/* 211 */ g.setFont(new Font("Times Roman", 0, 12));
+/* 212 */ FontMetrics fm = g.getFontMetrics();
+/* 213 */ int halfHeight = fm.getHeight() / 2;
+/* 214 */ int halfWidth = fm.stringWidth(perString) / 2;
+/* 215 */ offG.drawString(perString, 135 - halfWidth, 20 +
+/* 216 */ halfHeight);
+/* 217 */ g.drawImage(off, 0, 0, null);
+/* 218 */ offG.dispose();
+/* 219 */ off.flush();
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\ProgressBar.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file