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