1 Clazz.declarePackage ("jssun.swing");
2 Clazz.load (["java.util.HashMap"], "jssun.swing.CachedPainter", ["java.awt.image.BufferedImage", "$.VolatileImage", "jssun.swing.ImageCache"], function () {
3 c$ = Clazz.declareType (jssun.swing, "CachedPainter");
4 c$.getCache = Clazz.defineMethod (c$, "getCache",
7 var cache = jssun.swing.CachedPainter.cacheMap.get (key);
9 cache = new jssun.swing.ImageCache (1);
10 jssun.swing.CachedPainter.cacheMap.put (key, cache);
13 Clazz.makeConstructor (c$,
14 function (cacheCount) {
15 jssun.swing.CachedPainter.getCache (this.getClass ()).setMaxCount (cacheCount);
17 Clazz.defineMethod (c$, "paint",
18 function (c, g, x, y, w, h, args) {
19 if (w <= 0 || h <= 0) {
22 this.paint0 (c, g, x, y, w, h, args);
24 this.paint0 (c, g, x, y, w, h, args);
25 }}, "java.awt.Component,java.awt.Graphics,~N,~N,~N,~N,~A");
26 Clazz.defineMethod (c$, "paint0",
27 function (c, g, x, y, w, h, args) {
28 var key = this.getClass ();
29 var config = this.getGraphicsConfiguration (c);
30 var cache = jssun.swing.CachedPainter.getCache (key);
31 var image = cache.getImage (key, config, w, h, args);
35 if (Clazz.instanceOf (image, java.awt.image.VolatileImage)) {
36 switch ((image).validate (config)) {
46 image = this.createImage (c, w, h, config, args);
47 cache.setImage (key, config, w, h, args, image);
50 var g2 = image.getGraphics ();
51 this.paintToImage (c, image, g2, w, h, args);
53 }this.paintImage (c, g, x, y, w, h, image, args);
54 } while ((Clazz.instanceOf (image, java.awt.image.VolatileImage)) && (image).contentsLost () && ++attempts < 3);
55 }, "java.awt.Component,java.awt.Graphics,~N,~N,~N,~N,~A");
56 Clazz.defineMethod (c$, "paintImage",
57 function (c, g, x, y, w, h, image, args) {
58 g.drawImage (image, x, y, null);
59 }, "java.awt.Component,java.awt.Graphics,~N,~N,~N,~N,java.awt.Image,~A");
60 Clazz.defineMethod (c$, "createImage",
61 function (c, w, h, config, args) {
63 return new java.awt.image.BufferedImage (w, h, 1);
64 }return config.createCompatibleVolatileImage (w, h);
65 }, "java.awt.Component,~N,~N,java.awt.GraphicsConfiguration,~A");
66 Clazz.defineMethod (c$, "flush",
69 jssun.swing.CachedPainter.getCache (this.getClass ()).flush ();
71 Clazz.defineMethod (c$, "getGraphicsConfiguration",
75 }return c.getGraphicsConfiguration ();
76 }, "java.awt.Component");
77 c$.cacheMap = c$.prototype.cacheMap = new java.util.HashMap ();