56ead466455a9169f10db22bcc4eecc5834c5470
[jalviewjs.git] / site / swingjs / j2s / javax / swing / ImageIcon.js
1 Clazz.declarePackage ("javax.swing");\r
2 Clazz.load (["javax.swing.Icon", "java.lang.StringBuilder"], "javax.swing.ImageIcon", ["java.awt.Toolkit"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.filename = null;\r
5 this.location = null;\r
6 this.image = null;\r
7 this.loadStatus = 0;\r
8 this.imageObserver = null;\r
9 this.description = null;\r
10 this.width = -1;\r
11 this.height = -1;\r
12 Clazz.instantialize (this, arguments);\r
13 }, javax.swing, "ImageIcon", null, javax.swing.Icon);\r
14 Clazz.makeConstructor (c$, \r
15 function (filename, description) {\r
16 this.image = java.awt.Toolkit.getDefaultToolkit ().getImage (filename);\r
17 if (this.image == null) {\r
18 return;\r
19 }this.filename = filename;\r
20 this.description = description;\r
21 this.loadImage (this.image);\r
22 }, "~S,~S");\r
23 Clazz.makeConstructor (c$, \r
24 function (filename) {\r
25 this.construct (filename, filename);\r
26 }, "~S");\r
27 Clazz.makeConstructor (c$, \r
28 function (location, description) {\r
29 this.image = java.awt.Toolkit.getDefaultToolkit ().getImage (location);\r
30 if (this.image == null) {\r
31 return;\r
32 }this.location = location;\r
33 this.description = description;\r
34 this.loadImage (this.image);\r
35 }, "java.net.URL,~S");\r
36 Clazz.makeConstructor (c$, \r
37 function (location) {\r
38 this.construct (location, location.toExternalForm ());\r
39 }, "java.net.URL");\r
40 Clazz.makeConstructor (c$, \r
41 function (image, description) {\r
42 this.construct (image);\r
43 this.description = description;\r
44 }, "java.awt.Image,~S");\r
45 Clazz.makeConstructor (c$, \r
46 function (image) {\r
47 this.image = image;\r
48 var o = image.getProperty ("comment", this.imageObserver);\r
49 if (Clazz.instanceOf (o, String)) {\r
50 this.description = o;\r
51 }this.loadImage (image);\r
52 }, "java.awt.Image");\r
53 Clazz.makeConstructor (c$, \r
54 function (imageData, description) {\r
55 this.image = java.awt.Toolkit.getDefaultToolkit ().createImage (imageData);\r
56 if (this.image == null) {\r
57 return;\r
58 }this.description = description;\r
59 this.loadImage (this.image);\r
60 }, "~A,~S");\r
61 Clazz.makeConstructor (c$, \r
62 function (imageData) {\r
63 this.image = java.awt.Toolkit.getDefaultToolkit ().createImage (imageData);\r
64 if (this.image == null) {\r
65 return;\r
66 }var o = this.image.getProperty ("comment", this.imageObserver);\r
67 if (Clazz.instanceOf (o, String)) {\r
68 this.description = o;\r
69 }this.loadImage (this.image);\r
70 }, "~A");\r
71 Clazz.makeConstructor (c$, \r
72 function () {\r
73 });\r
74 Clazz.defineMethod (c$, "loadImage", \r
75 function (image) {\r
76 this.width = image.getWidth (this.imageObserver);\r
77 this.height = image.getHeight (this.imageObserver);\r
78 }, "java.awt.Image");\r
79 Clazz.defineMethod (c$, "getImageLoadStatus", \r
80 function () {\r
81 return this.loadStatus;\r
82 });\r
83 Clazz.defineMethod (c$, "getImage", \r
84 function () {\r
85 return this.image;\r
86 });\r
87 Clazz.defineMethod (c$, "setImage", \r
88 function (image) {\r
89 this.image = image;\r
90 this.loadImage (image);\r
91 }, "java.awt.Image");\r
92 Clazz.defineMethod (c$, "getDescription", \r
93 function () {\r
94 return this.description;\r
95 });\r
96 Clazz.defineMethod (c$, "setDescription", \r
97 function (description) {\r
98 this.description = description;\r
99 }, "~S");\r
100 Clazz.overrideMethod (c$, "paintIcon", \r
101 function (c, g, x, y) {\r
102 if (this.imageObserver == null) {\r
103 g.drawImage (this.image, x, y, c);\r
104 } else {\r
105 g.drawImage (this.image, x, y, this.imageObserver);\r
106 }}, "java.awt.Component,java.awt.Graphics,~N,~N");\r
107 Clazz.overrideMethod (c$, "getIconWidth", \r
108 function () {\r
109 return this.width;\r
110 });\r
111 Clazz.overrideMethod (c$, "getIconHeight", \r
112 function () {\r
113 return this.height;\r
114 });\r
115 Clazz.defineMethod (c$, "setImageObserver", \r
116 function (observer) {\r
117 this.imageObserver = observer;\r
118 }, "java.awt.image.ImageObserver");\r
119 Clazz.defineMethod (c$, "getImageObserver", \r
120 function () {\r
121 return this.imageObserver;\r
122 });\r
123 Clazz.defineMethod (c$, "toString", \r
124 function () {\r
125 if (this.description != null) {\r
126 return this.description;\r
127 }return Clazz.superCall (this, javax.swing.ImageIcon, "toString", []);\r
128 });\r
129 Clazz.defineStatics (c$,\r
130 "mediaTrackerID", 0);\r
131 c$.TRACKER_KEY = c$.prototype.TRACKER_KEY =  new StringBuilder ("TRACKER_KEY");\r
132 });\r