46d30983b4621ac7abd91e4504c89cb2f141835b
[jalviewjs.git] / site / swingjs / j2s / jssun / awt / SunToolkit.js
1 Clazz.declarePackage ("jssun.awt");
2 Clazz.load (["java.awt.Toolkit", "jssun.awt.ComponentFactory", "$.WindowClosingListener", "$.WindowClosingSupport", "java.util.HashMap"], "jssun.awt.SunToolkit", ["java.lang.NullPointerException", "$.Thread", "java.awt.Component", "$.Dimension", "$.EventQueue", "$.Panel", "$.Window", "jssun.awt.AWTAccessor", "$.AWTAutoShutdown", "$.AppContext", "$.PeerEvent", "$.PostEventQueue", "jssun.font.FontDesignMetrics"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.windowClosingListener = null;
5 Clazz.instantialize (this, arguments);
6 }, jssun.awt, "SunToolkit", java.awt.Toolkit, [jssun.awt.WindowClosingSupport, jssun.awt.WindowClosingListener, jssun.awt.ComponentFactory]);
7 Clazz.makeConstructor (c$, 
8 function () {
9 Clazz.superConstructor (this, jssun.awt.SunToolkit, []);
10 var eventQueue;
11 eventQueue =  new java.awt.EventQueue ();
12 var appContext = jssun.awt.AppContext.getAppContext ();
13 if (appContext != null) {
14 appContext.put (jssun.awt.AppContext.EVENT_QUEUE_KEY, eventQueue);
15 var postEventQueue =  new jssun.awt.PostEventQueue (eventQueue);
16 appContext.put ("PostEventQueue", postEventQueue);
17 }});
18 Clazz.defineMethod (c$, "useBufferPerWindow", 
19 function () {
20 return false;
21 });
22 c$.createNewAppContext = Clazz.defineMethod (c$, "createNewAppContext", 
23 function () {
24 var threadGroup = Thread.currentThread ().getThreadGroup ();
25 return jssun.awt.SunToolkit.createNewAppContext (threadGroup);
26 });
27 c$.createNewAppContext = Clazz.defineMethod (c$, "createNewAppContext", 
28 function (threadGroup) {
29 var eventQueue;
30 var eqName = System.getProperty ("AWT.EventQueueClass", "java.awt.EventQueue");
31 try {
32 eventQueue = Clazz._4Name (eqName).newInstance ();
33 } catch (e) {
34 if (Clazz.exceptionOf (e, Exception)) {
35 System.err.println ("Failed loading " + eqName + ": " + e);
36 eventQueue =  new java.awt.EventQueue ();
37 } else {
38 throw e;
39 }
40 }
41 var appContext =  new jssun.awt.AppContext (threadGroup);
42 appContext.put (jssun.awt.AppContext.EVENT_QUEUE_KEY, eventQueue);
43 var postEventQueue =  new jssun.awt.PostEventQueue (eventQueue);
44 appContext.put ("PostEventQueue", postEventQueue);
45 return appContext;
46 }, "ThreadGroup");
47 c$.wakeupEventQueue = Clazz.defineMethod (c$, "wakeupEventQueue", 
48 function (q, isShutdown) {
49 q.wakeup (isShutdown);
50 }, "java.awt.EventQueue,~B");
51 c$.targetToPeer = Clazz.defineMethod (c$, "targetToPeer", 
52 function (target) {
53 if (target != null) {
54 return jssun.awt.AWTAutoShutdown.getInstance ().getPeer (target);
55 }return null;
56 }, "~O");
57 c$.targetCreatedPeer = Clazz.defineMethod (c$, "targetCreatedPeer", 
58 function (target, peer) {
59 if (target != null && peer != null) {
60 jssun.awt.AWTAutoShutdown.getInstance ().registerPeer (target, peer);
61 }}, "~O,~O");
62 c$.targetDisposedPeer = Clazz.defineMethod (c$, "targetDisposedPeer", 
63 function (target, peer) {
64 if (target != null && peer != null) {
65 jssun.awt.AWTAutoShutdown.getInstance ().unregisterPeer (target, peer);
66 }}, "~O,~O");
67 c$.setAppContext = Clazz.defineMethod (c$, "setAppContext", 
68  function (target, context) {
69 if (Clazz.instanceOf (target, java.awt.Component)) {
70 jssun.awt.AWTAccessor.getComponentAccessor ().setAppContext (target, context);
71 } else {
72 return false;
73 }return true;
74 }, "~O,jssun.awt.AppContext");
75 c$.getAppContext = Clazz.defineMethod (c$, "getAppContext", 
76  function (target) {
77 if (Clazz.instanceOf (target, java.awt.Component)) {
78 {
79 return target.appContext;
80 }} else {
81 return null;
82 }}, "~O");
83 c$.targetToAppContext = Clazz.defineMethod (c$, "targetToAppContext", 
84 function (target) {
85 if (target == null) {
86 return null;
87 }var context = jssun.awt.SunToolkit.getAppContext (target);
88 if (context == null) {
89 context = jssun.awt.SunToolkit.appContextMap.get (target);
90 }return context;
91 }, "~O");
92 c$.setLWRequestStatus = Clazz.defineMethod (c$, "setLWRequestStatus", 
93 function (changed, status) {
94 jssun.awt.AWTAccessor.getWindowAccessor ().setLWRequestStatus (changed, status);
95 }, "java.awt.Window,~B");
96 c$.checkAndSetPolicy = Clazz.defineMethod (c$, "checkAndSetPolicy", 
97 function (cont, isSwingCont) {
98 }, "java.awt.Container,~B");
99 c$.insertTargetMapping = Clazz.defineMethod (c$, "insertTargetMapping", 
100 function (target, appContext) {
101 if (!jssun.awt.SunToolkit.setAppContext (target, appContext)) {
102 jssun.awt.SunToolkit.appContextMap.put (target, appContext);
103 }}, "~O,jssun.awt.AppContext");
104 c$.postEvent = Clazz.defineMethod (c$, "postEvent", 
105 function (appContext, event) {
106 if (event == null) {
107 throw  new NullPointerException ();
108 }var postEventQueue = appContext.get ("PostEventQueue");
109 if (postEventQueue != null) {
110 postEventQueue.postEvent (event);
111 }}, "jssun.awt.AppContext,java.awt.AWTEvent");
112 c$.postPriorityEvent = Clazz.defineMethod (c$, "postPriorityEvent", 
113 function (e) {
114 var pe =  new jssun.awt.PeerEvent (java.awt.Toolkit.getDefaultToolkit (), ((Clazz.isClassDefined ("jssun.awt.SunToolkit$1") ? 0 : jssun.awt.SunToolkit.$SunToolkit$1$ ()), Clazz.innerTypeInstance (jssun.awt.SunToolkit$1, this, Clazz.cloneFinals ("e", e))), 2);
115 jssun.awt.SunToolkit.postEvent (jssun.awt.SunToolkit.targetToAppContext (e.getSource ()), pe);
116 }, "java.awt.AWTEvent");
117 c$.flushPendingEvents = Clazz.defineMethod (c$, "flushPendingEvents", 
118 function () {
119 var appContext = jssun.awt.AppContext.getAppContext ();
120 var postEventQueue = appContext.get ("PostEventQueue");
121 if (postEventQueue != null) {
122 postEventQueue.flush ();
123 }});
124 c$.isPostEventQueueEmpty = Clazz.defineMethod (c$, "isPostEventQueueEmpty", 
125 function () {
126 var appContext = jssun.awt.AppContext.getAppContext ();
127 var postEventQueue = appContext.get ("PostEventQueue");
128 return (postEventQueue == null || postEventQueue.noEvents ());
129 });
130 c$.executeOnEventHandlerThread = Clazz.defineMethod (c$, "executeOnEventHandlerThread", 
131 function (target, runnable) {
132 jssun.awt.SunToolkit.executeOnEventHandlerThread ( new jssun.awt.PeerEvent (target, runnable, 1));
133 }, "~O,Runnable");
134 c$.executeOnEventHandlerThread = Clazz.defineMethod (c$, "executeOnEventHandlerThread", 
135 function (target, runnable, when) {
136 jssun.awt.SunToolkit.executeOnEventHandlerThread (((Clazz.isClassDefined ("jssun.awt.SunToolkit$2") ? 0 : jssun.awt.SunToolkit.$SunToolkit$2$ ()), Clazz.innerTypeInstance (jssun.awt.SunToolkit$2, this, Clazz.cloneFinals ("when", when), target, runnable, 1)));
137 }, "~O,Runnable,~N");
138 c$.executeOnEventHandlerThread = Clazz.defineMethod (c$, "executeOnEventHandlerThread", 
139 function (peerEvent) {
140 jssun.awt.SunToolkit.postEvent (jssun.awt.SunToolkit.targetToAppContext (peerEvent.getSource ()), peerEvent);
141 }, "jssun.awt.PeerEvent");
142 c$.invokeLaterOnAppContext = Clazz.defineMethod (c$, "invokeLaterOnAppContext", 
143 function (appContext, dispatcher) {
144 jssun.awt.SunToolkit.postEvent (appContext,  new jssun.awt.PeerEvent (java.awt.Toolkit.getDefaultToolkit (), dispatcher, 1));
145 }, "jssun.awt.AppContext,Runnable");
146 c$.isDispatchThreadForAppContext = Clazz.defineMethod (c$, "isDispatchThreadForAppContext", 
147 function (target) {
148 var appContext = jssun.awt.SunToolkit.targetToAppContext (target);
149 var eq = appContext.get (jssun.awt.AppContext.EVENT_QUEUE_KEY);
150 var next = jssun.awt.AWTAccessor.getEventQueueAccessor ().getNextQueue (eq);
151 while (next != null) {
152 eq = next;
153 next = jssun.awt.AWTAccessor.getEventQueueAccessor ().getNextQueue (eq);
154 }
155 return (Thread.currentThread () === jssun.awt.AWTAccessor.getEventQueueAccessor ().getDispatchThread (eq));
156 }, "~O");
157 Clazz.overrideMethod (c$, "getScreenSize", 
158 function () {
159 return  new java.awt.Dimension (this.getScreenWidth (), this.getScreenHeight ());
160 });
161 Clazz.overrideMethod (c$, "getFontMetrics", 
162 function (font) {
163 return jssun.font.FontDesignMetrics.getMetrics (font);
164 }, "java.awt.Font");
165 Clazz.overrideMethod (c$, "getFontList", 
166 function () {
167 var hardwiredFontList =  Clazz.newArray (-1, ["Dialog", "SansSerif", "Serif", "Monospaced", "DialogInput"]);
168 return hardwiredFontList;
169 });
170 Clazz.overrideMethod (c$, "createPanel", 
171 function (target) {
172 return this.createComponent (target);
173 }, "java.awt.Panel");
174 Clazz.defineMethod (c$, "disableBackgroundErase", 
175 function (component) {
176 this.disableBackgroundEraseImpl (component);
177 }, "java.awt.Component");
178 Clazz.defineMethod (c$, "disableBackgroundEraseImpl", 
179  function (component) {
180 jssun.awt.AWTAccessor.getComponentAccessor ().setBackgroundEraseDisabled (component, true);
181 }, "java.awt.Component");
182 c$.getSunAwtNoerasebackground = Clazz.defineMethod (c$, "getSunAwtNoerasebackground", 
183 function () {
184 return false;
185 });
186 c$.getSunAwtErasebackgroundonresize = Clazz.defineMethod (c$, "getSunAwtErasebackgroundonresize", 
187 function () {
188 return true;
189 });
190 Clazz.defineMethod (c$, "setOverrideRedirect", 
191 function (target) {
192 }, "java.awt.Window");
193 c$.getImageFromHash = Clazz.defineMethod (c$, "getImageFromHash", 
194 function (tk, url) {
195 var img = jssun.awt.SunToolkit.imgCache.get (url);
196 if (img == null) {
197 try {
198 img = tk.createImage (url);
199 jssun.awt.SunToolkit.imgCache.put (url, img);
200 } catch (e) {
201 if (Clazz.exceptionOf (e, Exception)) {
202 } else {
203 throw e;
204 }
205 }
206 }return img;
207 }, "java.awt.Toolkit,java.net.URL");
208 c$.getImageFromHash = Clazz.defineMethod (c$, "getImageFromHash", 
209 function (tk, filename) {
210 var img = jssun.awt.SunToolkit.imgCache.get (filename);
211 if (img == null) {
212 try {
213 tk.createImage (filename);
214 jssun.awt.SunToolkit.imgCache.put (filename, img);
215 } catch (e) {
216 if (Clazz.exceptionOf (e, Exception)) {
217 } else {
218 throw e;
219 }
220 }
221 }return img;
222 }, "java.awt.Toolkit,~S");
223 Clazz.defineMethod (c$, "getImage", 
224 function (filename) {
225 return jssun.awt.SunToolkit.getImageFromHash (this, filename);
226 }, "~S");
227 Clazz.defineMethod (c$, "getImage", 
228 function (url) {
229 return jssun.awt.SunToolkit.getImageFromHash (this, url);
230 }, "java.net.URL");
231 Clazz.overrideMethod (c$, "checkImage", 
232 function (img, w, h, o) {
233 return 0;
234 }, "java.awt.Image,~N,~N,java.awt.image.ImageObserver");
235 Clazz.overrideMethod (c$, "prepareImage", 
236 function (img, w, h, o) {
237 if (w == 0 || h == 0) {
238 return true;
239 }return true;
240 }, "java.awt.Image,~N,~N,java.awt.image.ImageObserver");
241 Clazz.overrideMethod (c$, "getSystemEventQueueImpl", 
242 function () {
243 return jssun.awt.SunToolkit.getSystemEventQueueImplPP ();
244 });
245 c$.getSystemEventQueueImplPP = Clazz.defineMethod (c$, "getSystemEventQueueImplPP", 
246 function () {
247 return jssun.awt.SunToolkit.getSystemEventQueueImplPP (jssun.awt.AppContext.getAppContext ());
248 });
249 c$.getSystemEventQueueImplPP = Clazz.defineMethod (c$, "getSystemEventQueueImplPP", 
250 function (appContext) {
251 var theEventQueue = appContext.get (jssun.awt.AppContext.EVENT_QUEUE_KEY);
252 return theEventQueue;
253 }, "jssun.awt.AppContext");
254 c$.getNativeContainer = Clazz.defineMethod (c$, "getNativeContainer", 
255 function (c) {
256 return java.awt.Toolkit.getNativeContainer (c);
257 }, "java.awt.Component");
258 Clazz.defineMethod (c$, "enableInputMethodsForTextComponent", 
259 function () {
260 return false;
261 });
262 c$.getStartupLocale = Clazz.defineMethod (c$, "getStartupLocale", 
263 function () {
264 if (jssun.awt.SunToolkit.startupLocale == null) {
265 {
266 }}return jssun.awt.SunToolkit.startupLocale;
267 });
268 Clazz.defineMethod (c$, "getDefaultKeyboardLocale", 
269 function () {
270 return jssun.awt.SunToolkit.getStartupLocale ();
271 });
272 c$.setDataTransfererClassName = Clazz.defineMethod (c$, "setDataTransfererClassName", 
273 function (className) {
274 jssun.awt.SunToolkit.dataTransfererClassName = className;
275 }, "~S");
276 c$.getDataTransfererClassName = Clazz.defineMethod (c$, "getDataTransfererClassName", 
277 function () {
278 if (jssun.awt.SunToolkit.dataTransfererClassName == null) {
279 java.awt.Toolkit.getDefaultToolkit ();
280 }return jssun.awt.SunToolkit.dataTransfererClassName;
281 });
282 Clazz.overrideMethod (c$, "getWindowClosingListener", 
283 function () {
284 return this.windowClosingListener;
285 });
286 Clazz.overrideMethod (c$, "setWindowClosingListener", 
287 function (wcl) {
288 this.windowClosingListener = wcl;
289 }, "jssun.awt.WindowClosingListener");
290 Clazz.defineMethod (c$, "windowClosingNotify", 
291 function (event) {
292 if (this.windowClosingListener != null) {
293 return this.windowClosingListener.windowClosingNotify (event);
294 } else {
295 return null;
296 }}, "java.awt.event.WindowEvent");
297 Clazz.defineMethod (c$, "windowClosingDelivered", 
298 function (event) {
299 if (this.windowClosingListener != null) {
300 return this.windowClosingListener.windowClosingDelivered (event);
301 } else {
302 return null;
303 }}, "java.awt.event.WindowEvent");
304 c$.isModalExcluded = Clazz.defineMethod (c$, "isModalExcluded", 
305 function (window) {
306 return true;
307 }, "java.awt.Window");
308 c$.isLightweightOrUnknown = Clazz.defineMethod (c$, "isLightweightOrUnknown", 
309 function (comp) {
310 if (comp.isLightweight () || !(Clazz.instanceOf (java.awt.Toolkit.getDefaultToolkit (), jssun.awt.SunToolkit))) {
311 return true;
312 }return !(Clazz.instanceOf (comp, java.awt.Panel) || Clazz.instanceOf (comp, java.awt.Window));
313 }, "java.awt.Component");
314 Clazz.defineMethod (c$, "getDesktopAAHints", 
315 function () {
316 return null;
317 });
318 c$.getContainingWindow = Clazz.defineMethod (c$, "getContainingWindow", 
319 function (comp) {
320 while (comp != null && !(Clazz.instanceOf (comp, java.awt.Window))) {
321 comp = comp.getParent ();
322 }
323 return comp;
324 }, "java.awt.Component");
325 Clazz.defineMethod (c$, "isNativeGTKAvailable", 
326 function () {
327 return false;
328 });
329 Clazz.defineMethod (c$, "isWindowOpacitySupported", 
330 function () {
331 return false;
332 });
333 Clazz.defineMethod (c$, "isWindowShapingSupported", 
334 function () {
335 return false;
336 });
337 Clazz.defineMethod (c$, "isWindowTranslucencySupported", 
338 function () {
339 return false;
340 });
341 Clazz.defineMethod (c$, "isTranslucencyCapable", 
342 function (gc) {
343 return false;
344 }, "java.awt.GraphicsConfiguration");
345 Clazz.defineMethod (c$, "needUpdateWindow", 
346 function () {
347 return false;
348 });
349 c$.$SunToolkit$1$ = function () {
350 Clazz.pu$h(self.c$);
351 c$ = Clazz.declareAnonymous (jssun.awt, "SunToolkit$1", null, Runnable);
352 Clazz.overrideMethod (c$, "run", 
353 function () {
354 jssun.awt.AWTAccessor.getAWTEventAccessor ().setPosted (this.f$.e);
355 (this.f$.e.getSource ()).dispatchEvent (this.f$.e);
356 });
357 c$ = Clazz.p0p ();
358 };
359 c$.$SunToolkit$2$ = function () {
360 Clazz.pu$h(self.c$);
361 c$ = Clazz.declareAnonymous (jssun.awt, "SunToolkit$2", jssun.awt.PeerEvent);
362 Clazz.overrideMethod (c$, "getWhen", 
363 function () {
364 return this.f$.when;
365 });
366 c$ = Clazz.p0p ();
367 };
368 Clazz.defineStatics (c$,
369 "GRAB_EVENT_MASK", 0x80000000,
370 "POST_EVENT_QUEUE_KEY", "PostEventQueue");
371 c$.appContextMap = c$.prototype.appContextMap =  new java.util.HashMap ();
372 c$.imgCache = c$.prototype.imgCache =  new java.util.HashMap ();
373 Clazz.defineStatics (c$,
374 "startupLocale", null,
375 "dataTransfererClassName", null,
376 "DESKTOPFONTHINTS", "awt.font.desktophints");
377 });