summaryrefslogtreecommitdiff
path: root/NET/worlds/console/SplashCanvas.java
blob: 2ccd13df396cd5ab6d642ca67afc07cb487d3e9a (plain) (blame)
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
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import java.awt.Canvas;
/*     */ import java.awt.Component;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Image;
/*     */ import java.awt.MediaTracker;
/*     */ import java.awt.Toolkit;
/*     */ import java.util.Vector;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ class SplashCanvas
/*     */   extends Canvas
/*     */ {
/*     */   private static final long serialVersionUID = 341168247494647821L;
/*     */   protected String name;
/*     */   protected Image image;
/*     */   protected Dimension dim;
/*  90 */   protected Vector<Overlay> overlays = new Vector();
/*     */   
/*     */   SplashCanvas(String name) {
/*  93 */     this.name = name;
/*     */   }
/*     */   
/*     */   public void flush() {
/*  97 */     this.image.flush();
/*  98 */     this.image = null;
/*     */     
/* 100 */     for (int i = 0; i < this.overlays.size(); i++) {
/* 101 */       Overlay over = (Overlay)this.overlays.elementAt(i);
/* 102 */       over.flush();
/*     */     }
/* 104 */     this.overlays.removeAllElements();
/*     */   }
/*     */   
/*     */   public void paint(Graphics g)
/*     */   {
/* 109 */     super.paint(g);
/* 110 */     g.drawImage(this.image, 0, 0, this);
/* 111 */     for (int i = 0; i < this.overlays.size(); i++) {
/* 112 */       Overlay over = (Overlay)this.overlays.elementAt(i);
/* 113 */       over.paint(g, this);
/*     */     }
/*     */   }
/*     */   
/*     */   public void setImage(String name) {
/* 118 */     this.name = name;
/* 119 */     this.image = null;
/* 120 */     imageSize();
/*     */   }
/*     */   
/*     */   public void addOverlay(String name, int x, int y) {
/* 124 */     Overlay over = new Overlay(name, x, y);
/*     */     
/* 126 */     Dimension dim = over.imageSize(this);
/* 127 */     this.overlays.addElement(over);
/* 128 */     repaint(x, y, dim.width, dim.height);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void removeOverlay(String name, int x, int y)
/*     */   {
/* 136 */     for (int i = 0; i < this.overlays.size(); i++) {
/* 137 */       Overlay over = (Overlay)this.overlays.elementAt(i);
/* 138 */       if (over.matches(name, x, y)) {
/* 139 */         Dimension dim = over.imageSize(this);
/* 140 */         this.overlays.removeElementAt(i);
/* 141 */         repaint(x, y, dim.width, dim.height);
/* 142 */         return;
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   private Dimension imageSize() {
/* 148 */     if (this.image == null) {
/* 149 */       this.image = getEarlyImage(this.name, this);
/* 150 */       if (this.image != null) {
/* 151 */         int width = this.image.getWidth(this);
/* 152 */         int height = this.image.getHeight(this);
/* 153 */         if ((width != -1) && (height != -1))
/* 154 */           return this.dim = new Dimension(width, height);
/*     */       }
/* 156 */       this.dim = new Dimension(0, 0);
/*     */     }
/* 158 */     for (int i = 0; i < this.overlays.size(); i++) {
/* 159 */       Overlay over = (Overlay)this.overlays.elementAt(i);
/* 160 */       over.imageSize(this);
/*     */     }
/* 162 */     return this.dim;
/*     */   }
/*     */   
/*     */ 
/*     */   public static Image getEarlyImage(String name, Component comp)
/*     */   {
/* 168 */     for (int pass = 0; pass < 2; pass++) {
/* 169 */       String imagename = Gamma.earlyURLUnalias(name);
/* 170 */       Image image = Toolkit.getDefaultToolkit().getImage(imagename);
/*     */       
/*     */ 
/* 173 */       MediaTracker tracker = new MediaTracker(comp);
/* 174 */       tracker.addImage(image, 0);
/*     */       try {
/* 176 */         tracker.waitForAll();
/*     */       }
/*     */       catch (InterruptedException localInterruptedException) {}
/*     */       
/* 180 */       if (!tracker.isErrorAny()) {
/* 181 */         return image;
/*     */       }
/*     */       
/* 184 */       if (pass == 0)
/* 185 */         name = "..\\" + name;
/*     */     }
/* 187 */     return null;
/*     */   }
/*     */   
/*     */   public Dimension getPreferredSize()
/*     */   {
/* 192 */     return imageSize();
/*     */   }
/*     */   
/*     */   public Dimension getMinimumSize()
/*     */   {
/* 197 */     return imageSize();
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\SplashCanvas.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */