-
Notifications
You must be signed in to change notification settings - Fork 0
/
RRTkProxy.java
56 lines (48 loc) · 1.25 KB
/
RRTkProxy.java
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
/*
* Copyright © 2003, 2011 Bart Massey
* [This program is licensed under the "MIT License"]
* Please see the file COPYING in the source
* distribution of this software for license terms.
*/
/*
* Ricochet Robots Toolkit Proxy
* Created on May 31, 2003
*
*/
/**
* @author Bart Massey <[email protected]>
*
*/
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class RRTkProxy {
JApplet applet = null;
Toolkit tk = null;
RRTkProxy(JApplet applet) { this.applet = applet; }
RRTkProxy(Toolkit tk) { this.tk = tk; }
Image getImage(String name) {
Image result;
if (tk != null)
result = tk.getImage(name);
else if (applet != null)
result = applet.getImage(applet.getCodeBase(), name);
else
throw new Error("No image access");
if (result == null)
throw new Error("Can't load image " + name);
return result;
}
Image createImage(ImageProducer src) {
Image result;
if (tk != null)
result = tk.createImage(src);
else if (applet != null)
result = applet.createImage(src);
else
throw new Error("No image creation");
if (result == null)
throw new Error("Can't create image");
return result;
}
}