1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.util.HashMap", "java.awt.Rectangle"], "javax.swing.RepaintManager", ["java.lang.StringBuffer", "$.Thread", "java.util.ArrayList", "$.HashSet", "$.IdentityHashMap", "java.applet.Applet", "java.awt.Frame", "$.Toolkit", "$.Window", "java.awt.event.InvocationEvent", "javax.swing.CellRendererPane", "$.JComponent", "$.SwingUtilities", "jssun.awt.AWTAccessor", "$.AppContext", "$.SunToolkit", "swingjs.JSToolkit"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.volatileMap = null;
5 this.hwDirtyComponents = null;
6 this.dirtyComponents = null;
7 this.tmpDirtyComponents = null;
8 this.invalidComponents = null;
9 this.runnableList = null;
11 this.painting = false;
12 this.repaintRoot = null;
13 this.paintThread = null;
14 this.processingRunnable = null;
15 this.myComponent = null;
17 if (!Clazz.isClassDefined ("javax.swing.RepaintManager.ProcessingRunnable")) {
18 javax.swing.RepaintManager.$RepaintManager$ProcessingRunnable$ ();
20 Clazz.instantialize (this, arguments);
21 }, javax.swing, "RepaintManager");
22 Clazz.prepareFields (c$, function () {
23 this.volatileMap = new java.util.HashMap (1);
24 this.tmp = new java.awt.Rectangle ();
26 c$.currentManager = Clazz.defineMethod (c$, "currentManager",
28 var appContext = jssun.awt.AppContext.getAppContext ();
29 var rm = appContext.get (javax.swing.RepaintManager.repaintManagerKey);
31 rm = new javax.swing.RepaintManager ();
33 appContext.put (javax.swing.RepaintManager.repaintManagerKey, rm);
35 }, "java.awt.Component");
36 c$.setCurrentManager = Clazz.defineMethod (c$, "setCurrentManager",
37 function (aRepaintManager) {
38 if (aRepaintManager != null) {
39 javax.swing.SwingUtilities.appContextPut (javax.swing.RepaintManager.repaintManagerKey, aRepaintManager);
41 javax.swing.SwingUtilities.appContextRemove (javax.swing.RepaintManager.repaintManagerKey);
42 }}, "javax.swing.RepaintManager");
43 Clazz.makeConstructor (c$,
45 this.processingRunnable = Clazz.innerTypeInstance (javax.swing.RepaintManager.ProcessingRunnable, this, null);
47 Clazz.defineMethod (c$, "set",
50 this.dirtyComponents = new java.util.IdentityHashMap ();
51 this.tmpDirtyComponents = new java.util.IdentityHashMap ();
52 this.hwDirtyComponents = new java.util.IdentityHashMap ();
53 }, "java.awt.Component");
54 Clazz.defineMethod (c$, "addInvalidComponent",
55 function (invalidComponent) {
56 var validateRoot = null;
57 for (var c = invalidComponent; c != null; c = c.getParent ()) {
58 if ((Clazz.instanceOf (c, javax.swing.CellRendererPane))) {
60 }if ((Clazz.instanceOf (c, javax.swing.JComponent)) && ((c).isValidateRoot ())) {
64 if (validateRoot == null) {
67 for (var c = validateRoot; c != null; c = c.getParent ()) {
68 if (!c.isVisible ()) {
70 }if ((Clazz.instanceOf (c, java.awt.Window)) || (Clazz.instanceOf (c, java.applet.Applet))) {
76 }if (this.invalidComponents == null) {
77 this.invalidComponents = new java.util.ArrayList ();
79 var n = this.invalidComponents.size ();
80 for (var i = 0; i < n; i++) {
81 if (validateRoot === this.invalidComponents.get (i)) {
84 }this.invalidComponents.add (validateRoot);
85 this.scheduleProcessingRunnable (root);
86 }, "javax.swing.JComponent");
87 Clazz.defineMethod (c$, "removeInvalidComponent",
88 function (component) {
89 if (this.invalidComponents != null) {
90 var index = this.invalidComponents.indexOf (component);
92 this.invalidComponents.remove (index);
93 }}}, "javax.swing.JComponent");
94 Clazz.defineMethod (c$, "addDirtyRegion0",
95 function (c, x, y, w, h) {
97 var g = c.getGraphics();
98 if (g == null || g.gc == null)return;
99 }if ((w <= 0) || (h <= 0) || (c == null)) {
101 }if ((c.getWidth () <= 0) || (c.getHeight () <= 0)) {
103 }if (this.extendDirtyRegion (c, x, y, w, h)) {
106 for (var p = c; p != null; p = p.getParent ()) {
107 if (!p.isVisible () || p.getPeer () == null) {
109 }if ((Clazz.instanceOf (p, java.awt.Window)) || (Clazz.instanceOf (p, java.applet.Applet))) {
110 if (Clazz.instanceOf (p, java.awt.Frame) && ((p).getExtendedState () & 1) == 1) {
115 if (root == null) return;
117 if (this.extendDirtyRegion (c, x, y, w, h)) {
119 }this.dirtyComponents.put (c, new java.awt.Rectangle (x, y, w, h));
120 }this.scheduleProcessingRunnable (c);
121 }, "java.awt.Container,~N,~N,~N,~N");
122 Clazz.defineMethod (c$, "addDirtyRegion",
123 function (c, x, y, w, h) {
124 this.addDirtyRegion0 (c, x, y, w, h);
125 }, "javax.swing.JComponent,~N,~N,~N,~N");
126 Clazz.defineMethod (c$, "addDirtyRegion",
127 function (window, x, y, w, h) {
128 this.addDirtyRegion0 (window, x, y, w, h);
129 }, "java.awt.Window,~N,~N,~N,~N");
130 Clazz.defineMethod (c$, "addDirtyRegion",
131 function (applet, x, y, w, h) {
132 this.addDirtyRegion0 (applet, x, y, w, h);
133 }, "java.applet.Applet,~N,~N,~N,~N");
134 Clazz.defineMethod (c$, "scheduleHeavyWeightPaints",
138 if (this.hwDirtyComponents.size () == 0) {
140 }hws = this.hwDirtyComponents;
141 this.hwDirtyComponents = new java.util.IdentityHashMap ();
142 }for (var hw, $hw = hws.keySet ().iterator (); $hw.hasNext () && ((hw = $hw.next ()) || true);) {
143 var dirty = hws.get (hw);
144 if (Clazz.instanceOf (hw, java.awt.Window)) {
145 this.addDirtyRegion (hw, dirty.x, dirty.y, dirty.width, dirty.height);
146 } else if (Clazz.instanceOf (hw, java.applet.Applet)) {
147 this.addDirtyRegion (hw, dirty.x, dirty.y, dirty.width, dirty.height);
149 this.addDirtyRegion0 (hw, dirty.x, dirty.y, dirty.width, dirty.height);
152 Clazz.defineMethod (c$, "nativeAddDirtyRegion",
153 function (appContext, c, x, y, w, h) {
154 if (w > 0 && h > 0) {
156 var dirty = this.hwDirtyComponents.get (c);
158 this.hwDirtyComponents.put (c, new java.awt.Rectangle (x, y, w, h));
160 this.hwDirtyComponents.put (c, javax.swing.SwingUtilities.computeUnion (x, y, w, h, dirty));
161 }}this.scheduleProcessingRunnable (appContext);
162 }}, "jssun.awt.AppContext,java.awt.Container,~N,~N,~N,~N");
163 Clazz.defineMethod (c$, "extendDirtyRegion",
164 function (c, x, y, w, h) {
165 var r = this.dirtyComponents.get (c);
167 javax.swing.SwingUtilities.computeUnion (x, y, w, h, r);
170 }, "java.awt.Component,~N,~N,~N,~N");
171 Clazz.defineMethod (c$, "getDirtyRegion",
172 function (aComponent) {
175 r = this.dirtyComponents.get (aComponent);
176 }if (r == null) return new java.awt.Rectangle (0, 0, 0, 0);
177 else return new java.awt.Rectangle (r);
178 }, "javax.swing.JComponent");
179 Clazz.defineMethod (c$, "markCompletelyDirty",
180 function (aComponent) {
181 this.addDirtyRegion (aComponent, 0, 0, 2147483647, 2147483647);
182 }, "javax.swing.JComponent");
183 Clazz.defineMethod (c$, "markCompletelyClean",
184 function (aComponent) {
186 this.dirtyComponents.remove (aComponent);
187 }}, "javax.swing.JComponent");
188 Clazz.defineMethod (c$, "isCompletelyDirty",
189 function (aComponent) {
191 r = this.getDirtyRegion (aComponent);
192 if (r.width == 2147483647 && r.height == 2147483647) return true;
194 }, "javax.swing.JComponent");
195 Clazz.defineMethod (c$, "validateInvalidComponents",
199 if (this.invalidComponents == null) {
201 }ic = this.invalidComponents;
202 this.invalidComponents = null;
204 for (var i = 0; i < n; i++) {
209 Clazz.defineMethod (c$, "prePaintDirtyRegions",
214 dirtyComponents = this.dirtyComponents;
215 runnableList = this.runnableList;
216 this.runnableList = null;
217 }if (runnableList != null) {
218 for (var runnable, $runnable = runnableList.iterator (); $runnable.hasNext () && ((runnable = $runnable.next ()) || true);) {
221 }this.paintDirtyRegions ();
222 if (dirtyComponents.size () > 0) {
223 this.paintDirtyRegions1 (dirtyComponents);
225 Clazz.defineMethod (c$, "updateWindows",
226 function (dirtyComponents) {
227 var toolkit = java.awt.Toolkit.getDefaultToolkit ();
228 if (!(Clazz.instanceOf (toolkit, jssun.awt.SunToolkit) && (toolkit).needUpdateWindow ())) {
229 return dirtyComponents;
230 }var windows = new java.util.HashSet ();
231 var dirtyComps = dirtyComponents.keySet ();
232 for (var it = dirtyComps.iterator (); it.hasNext (); ) {
233 var dirty = it.next ();
234 var window = Clazz.instanceOf (dirty, java.awt.Window) ? dirty : javax.swing.SwingUtilities.getWindowAncestor (dirty);
235 if (window != null && !jssun.awt.AWTAccessor.getWindowAccessor ().isOpaque (window)) {
237 windows.add (window);
239 for (var window, $window = windows.iterator (); $window.hasNext () && ((window = $window.next ()) || true);) {
240 jssun.awt.AWTAccessor.getWindowAccessor ().updateWindow (window, null);
242 return dirtyComponents;
244 Clazz.defineMethod (c$, "paintDirtyRegions",
247 var tmp = this.tmpDirtyComponents;
248 this.tmpDirtyComponents = this.dirtyComponents;
249 this.dirtyComponents = tmp;
250 this.dirtyComponents.clear ();
251 }this.paintDirtyRegions1 (this.tmpDirtyComponents);
253 Clazz.defineMethod (c$, "paintDirtyRegions1",
254 function (tmpDirtyComponents) {
255 if (tmpDirtyComponents.isEmpty ()) {
257 }this.updateWindows (tmpDirtyComponents);
258 var roots = new java.util.ArrayList (tmpDirtyComponents.size ());
259 for (var dirty, $dirty = tmpDirtyComponents.keySet ().iterator (); $dirty.hasNext () && ((dirty = $dirty.next ()) || true);) {
260 this.collectDirtyComponents (tmpDirtyComponents, dirty, roots);
262 var count = roots.size ();
263 this.painting = true;
265 for (var j = 0; j < count; j++) {
267 var dirtyComponent = roots.get (j);
268 var rect = tmpDirtyComponents.get (dirtyComponent);
269 var localBoundsH = dirtyComponent.getHeight ();
270 var localBoundsW = dirtyComponent.getWidth ();
271 javax.swing.SwingUtilities.computeIntersection (0, 0, localBoundsW, localBoundsH, rect);
272 if (Clazz.instanceOf (dirtyComponent, javax.swing.JComponent)) {
273 (dirtyComponent).paintImmediately (rect.x, rect.y, rect.width, rect.height);
274 } else if (dirtyComponent.isShowing ()) {
275 var g = javax.swing.JComponent.safelyGetGraphics (dirtyComponent, dirtyComponent);
278 dirtyComponent.paint (g);
282 }}if (this.repaintRoot != null) {
283 this.adjustRoots (this.repaintRoot, roots, i + 1);
284 count = roots.size ();
285 this.repaintRoot.paintImmediately (0, 0, this.repaintRoot.getWidth (), this.repaintRoot.getHeight ());
286 this.repaintRoot = null;
289 this.painting = false;
291 tmpDirtyComponents.clear ();
293 Clazz.defineMethod (c$, "adjustRoots",
294 function (root, roots, index) {
295 for (var i = roots.size () - 1; i >= index; i--) {
296 var c = roots.get (i);
298 if (c === root || c == null || !(Clazz.instanceOf (c, javax.swing.JComponent))) {
305 }, "javax.swing.JComponent,java.util.List,~N");
306 Clazz.defineMethod (c$, "collectDirtyComponents",
307 function (dirtyComponents, dirtyComponent, roots) {
313 var rootDirtyComponent;
315 component = rootDirtyComponent = dirtyComponent;
316 var x = dirtyComponent.getX ();
317 var y = dirtyComponent.getY ();
318 var w = dirtyComponent.getWidth ();
319 var h = dirtyComponent.getHeight ();
322 this.tmp.setBounds (dirtyComponents.get (dirtyComponent));
323 javax.swing.SwingUtilities.computeIntersection (0, 0, w, h, this.tmp);
324 if (this.tmp.isEmpty ()) {
327 if (!(Clazz.instanceOf (component, javax.swing.JComponent))) break;
328 parent = component.getParent ();
329 if (parent == null) break;
333 this.tmp.setLocation (this.tmp.x + x, this.tmp.y + y);
334 x = component.getX ();
335 y = component.getY ();
336 w = component.getWidth ();
337 h = component.getHeight ();
338 this.tmp = javax.swing.SwingUtilities.computeIntersection (0, 0, w, h, this.tmp);
339 if (this.tmp.isEmpty ()) {
341 }if (dirtyComponents.get (component) != null) {
342 rootDirtyComponent = component;
346 if (dirtyComponent !== rootDirtyComponent) {
348 this.tmp.setLocation (this.tmp.x + rootDx - dx, this.tmp.y + rootDy - dy);
349 r = dirtyComponents.get (rootDirtyComponent);
350 javax.swing.SwingUtilities.computeUnion (this.tmp.x, this.tmp.y, this.tmp.width, this.tmp.height, r);
351 }if (!roots.contains (rootDirtyComponent)) roots.add (rootDirtyComponent);
352 }, "java.util.Map,java.awt.Component,java.util.List");
353 Clazz.overrideMethod (c$, "toString",
355 var sb = new StringBuffer ();
356 if (this.dirtyComponents != null) sb.append ("" + this.dirtyComponents);
357 return sb.toString ();
359 Clazz.defineMethod (c$, "getOffscreenBuffer",
360 function (c, proposedWidth, proposedHeight) {
362 }, "java.awt.Component,~N,~N");
363 Clazz.defineMethod (c$, "getVolatileOffscreenBuffer",
364 function (c, proposedWidth, proposedHeight) {
365 var config = c.getGraphicsConfiguration ();
366 var maxSize = this.getDoubleBufferMaximumSize ();
367 var width = proposedWidth < 1 ? 1 : (proposedWidth > maxSize.width ? maxSize.width : proposedWidth);
368 var height = proposedHeight < 1 ? 1 : (proposedHeight > maxSize.height ? maxSize.height : proposedHeight);
369 var image = this.volatileMap.get (config);
370 if (image == null || image.getWidth () < width || image.getHeight () < height) {
373 }image = config.createCompatibleVolatileImage (width, height);
374 this.volatileMap.put (config, image);
376 }, "java.awt.Component,~N,~N");
377 Clazz.defineMethod (c$, "setDoubleBufferMaximumSize",
379 }, "java.awt.Dimension");
380 Clazz.defineMethod (c$, "getDoubleBufferMaximumSize",
384 Clazz.defineMethod (c$, "setDoubleBufferingEnabled",
387 Clazz.defineMethod (c$, "resetDoubleBuffer",
390 Clazz.defineMethod (c$, "resetVolatileDoubleBuffer",
392 var image = this.volatileMap.remove (gc);
395 }}, "java.awt.GraphicsConfiguration");
396 Clazz.defineMethod (c$, "useVolatileDoubleBuffer",
398 return javax.swing.RepaintManager.volatileImageBufferEnabled;
400 Clazz.defineMethod (c$, "isPaintingThread",
402 return (Thread.currentThread () === this.paintThread);
404 Clazz.defineMethod (c$, "paint",
405 function (paintingComponent, bufferComponent, g, x, y, w, h) {
406 paintingComponent.paintToOffscreen (g, x, y, w, h, x + w, y + h);
407 }, "javax.swing.JComponent,javax.swing.JComponent,java.awt.Graphics,~N,~N,~N,~N");
408 Clazz.defineMethod (c$, "beginPaint",
410 var multiThreadedPaint = false;
412 var currentThread = Thread.currentThread ();
414 paintDepth = this.paintDepth;
415 if (this.paintThread == null || currentThread === this.paintThread) {
416 this.paintThread = currentThread;
419 multiThreadedPaint = true;
421 Clazz.defineMethod (c$, "endPaint",
423 if (this.isPaintingThread ()) {
425 Clazz.defineMethod (c$, "doubleBufferingChanged",
426 function (rootPane) {
427 }, "javax.swing.JRootPane");
428 Clazz.defineMethod (c$, "scheduleProcessingRunnable",
430 this.scheduleProcessingRunnable (c.getAppContext ());
431 }, "java.awt.Component");
432 Clazz.defineMethod (c$, "scheduleProcessingRunnable",
434 if (this.processingRunnable.markPending ()) {
435 jssun.awt.SunToolkit.getSystemEventQueueImplPP (context).postEvent ( new java.awt.event.InvocationEvent (java.awt.Toolkit.getDefaultToolkit (), this.processingRunnable));
436 }}, "jssun.awt.AppContext");
437 c$.$RepaintManager$ProcessingRunnable$ = function () {
439 c$ = Clazz.decorateAsClass (function () {
440 Clazz.prepareCallback (this, arguments);
441 this.pending = false;
442 Clazz.instantialize (this, arguments);
443 }, javax.swing.RepaintManager, "ProcessingRunnable", null, Runnable);
444 Clazz.defineMethod (c$, "markPending",
451 Clazz.overrideMethod (c$, "run",
454 this.pending = false;
455 }this.b$["javax.swing.RepaintManager"].scheduleHeavyWeightPaints ();
456 this.b$["javax.swing.RepaintManager"].validateInvalidComponents ();
457 this.b$["javax.swing.RepaintManager"].prePaintDirtyRegions ();
458 swingjs.JSToolkit.forceRepaint (this.b$["javax.swing.RepaintManager"].myComponent);
462 Clazz.defineStatics (c$,
463 "HANDLE_TOP_LEVEL_PAINT", false);
464 c$.repaintManagerKey = c$.prototype.repaintManagerKey = javax.swing.RepaintManager;
465 Clazz.defineStatics (c$,
466 "volatileImageBufferEnabled", true);
468 javax.swing.RepaintManager.volatileImageBufferEnabled = false;
469 var headless = false;
470 if (javax.swing.RepaintManager.volatileImageBufferEnabled && headless) {
471 javax.swing.RepaintManager.volatileImageBufferEnabled = false;
472 }javax.swing.RepaintManager.HANDLE_TOP_LEVEL_PAINT = true;