1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
*/
|