8b4ddde8d4e6f6609fea6c0300db5930b68cf0ed
[jalviewjs.git] / site / swingjs / j2s / jssun / swing / ImageCache.js
1 Clazz.declarePackage ("jssun.swing");
2 Clazz.load (null, "jssun.swing.ImageCache", ["java.util.LinkedList"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.maxCount = 0;
5 this.entries = null;
6 Clazz.instantialize (this, arguments);
7 }, jssun.swing, "ImageCache");
8 Clazz.makeConstructor (c$, 
9 function (maxCount) {
10 this.maxCount = maxCount;
11 this.entries =  new java.util.LinkedList ();
12 }, "~N");
13 Clazz.defineMethod (c$, "setMaxCount", 
14 function (maxCount) {
15 this.maxCount = maxCount;
16 }, "~N");
17 Clazz.defineMethod (c$, "flush", 
18 function () {
19 this.entries.clear ();
20 });
21 Clazz.defineMethod (c$, "getEntry", 
22  function (key, config, w, h, args) {
23 var entry;
24 var iter = this.entries.listIterator ();
25 while (iter.hasNext ()) {
26 var ref = iter.next ();
27 entry = ref;
28 if (entry == null) {
29 iter.remove ();
30 } else if (entry.equals (config, w, h, args)) {
31 iter.remove ();
32 this.entries.addFirst (ref);
33 return entry;
34 }}
35 entry =  new jssun.swing.ImageCache.Entry (config, w, h, args);
36 if (this.entries.size () >= this.maxCount) {
37 this.entries.removeLast ();
38 }this.entries.addFirst (entry);
39 return entry;
40 }, "~O,java.awt.GraphicsConfiguration,~N,~N,~A");
41 Clazz.defineMethod (c$, "getImage", 
42 function (key, config, w, h, args) {
43 var entry = this.getEntry (key, config, w, h, args);
44 return entry.getImage ();
45 }, "~O,java.awt.GraphicsConfiguration,~N,~N,~A");
46 Clazz.defineMethod (c$, "setImage", 
47 function (key, config, w, h, args, image) {
48 var entry = this.getEntry (key, config, w, h, args);
49 entry.setImage (image);
50 }, "~O,java.awt.GraphicsConfiguration,~N,~N,~A,java.awt.Image");
51 Clazz.pu$h(self.c$);
52 c$ = Clazz.decorateAsClass (function () {
53 this.config = null;
54 this.w = 0;
55 this.h = 0;
56 this.args = null;
57 this.image = null;
58 Clazz.instantialize (this, arguments);
59 }, jssun.swing.ImageCache, "Entry");
60 Clazz.makeConstructor (c$, 
61 function (a, b, c, d) {
62 this.config = a;
63 this.args = d;
64 this.w = b;
65 this.h = c;
66 }, "java.awt.GraphicsConfiguration,~N,~N,~A");
67 Clazz.defineMethod (c$, "setImage", 
68 function (a) {
69 this.image = a;
70 }, "java.awt.Image");
71 Clazz.defineMethod (c$, "getImage", 
72 function () {
73 return this.image;
74 });
75 Clazz.defineMethod (c$, "toString", 
76 function () {
77 var a = Clazz.superCall (this, jssun.swing.ImageCache.Entry, "toString", []) + "[ graphicsConfig=" + this.config + ", image=" + this.image + ", w=" + this.w + ", h=" + this.h;
78 if (this.args != null) {
79 for (var b = 0; b < this.args.length; b++) {
80 a += ", " + this.args[b];
81 }
82 }a += "]";
83 return a;
84 });
85 Clazz.defineMethod (c$, "equals", 
86 function (a, b, c, d) {
87 if (this.w == b && this.h == c && ((this.config != null && this.config.equals (a)) || (this.config == null && a == null))) {
88 if (this.args == null && d == null) {
89 return true;
90 }if (this.args != null && d != null && this.args.length == d.length) {
91 for (var e = d.length - 1; e >= 0; e--) {
92 var f = this.args[e];
93 var g = d[e];
94 if ((f == null && g != null) || (f != null && !f.equals (g))) {
95 return false;
96 }}
97 return true;
98 }}return false;
99 }, "java.awt.GraphicsConfiguration,~N,~N,~A");
100 c$ = Clazz.p0p ();
101 });