JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / awt / image / MemoryImageSource.js
1 Clazz.declarePackage ("java.awt.image");\r
2 Clazz.load (["java.awt.image.ImageProducer", "java.util.Vector"], "java.awt.image.MemoryImageSource", ["java.util.Hashtable", "java.awt.image.ColorModel"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.width = 0;\r
5 this.height = 0;\r
6 this.model = null;\r
7 this.pixels = null;\r
8 this.pixeloffset = 0;\r
9 this.pixelscan = 0;\r
10 this.properties = null;\r
11 this.theConsumers = null;\r
12 this.animating = false;\r
13 this.fullbuffers = false;\r
14 Clazz.instantialize (this, arguments);\r
15 }, java.awt.image, "MemoryImageSource", null, java.awt.image.ImageProducer);\r
16 Clazz.prepareFields (c$, function () {\r
17 this.theConsumers =  new java.util.Vector ();\r
18 });\r
19 Clazz.makeConstructor (c$, \r
20 function (w, h, cm, pix, off, scan) {\r
21 this.initialize (w, h, cm, pix, off, scan, null);\r
22 }, "~N,~N,java.awt.image.ColorModel,~A,~N,~N");\r
23 Clazz.makeConstructor (c$, \r
24 function (w, h, cm, pix, off, scan, props) {\r
25 this.initialize (w, h, cm, pix, off, scan, props);\r
26 }, "~N,~N,java.awt.image.ColorModel,~A,~N,~N,java.util.Hashtable");\r
27 Clazz.makeConstructor (c$, \r
28 function (w, h, cm, pix, off, scan) {\r
29 this.initialize (w, h, cm, pix, off, scan, null);\r
30 }, "~N,~N,java.awt.image.ColorModel,~A,~N,~N");\r
31 Clazz.makeConstructor (c$, \r
32 function (w, h, cm, pix, off, scan, props) {\r
33 this.initialize (w, h, cm, pix, off, scan, props);\r
34 }, "~N,~N,java.awt.image.ColorModel,~A,~N,~N,java.util.Hashtable");\r
35 Clazz.defineMethod (c$, "initialize", \r
36  function (w, h, cm, pix, off, scan, props) {\r
37 this.width = w;\r
38 this.height = h;\r
39 this.model = cm;\r
40 this.pixels = pix;\r
41 this.pixeloffset = off;\r
42 this.pixelscan = scan;\r
43 if (props == null) {\r
44 props =  new java.util.Hashtable ();\r
45 }this.properties = props;\r
46 }, "~N,~N,java.awt.image.ColorModel,~O,~N,~N,java.util.Hashtable");\r
47 Clazz.makeConstructor (c$, \r
48 function (w, h, pix, off, scan) {\r
49 this.initialize (w, h, java.awt.image.ColorModel.getRGBdefault (), pix, off, scan, null);\r
50 }, "~N,~N,~A,~N,~N");\r
51 Clazz.makeConstructor (c$, \r
52 function (w, h, pix, off, scan, props) {\r
53 this.initialize (w, h, java.awt.image.ColorModel.getRGBdefault (), pix, off, scan, props);\r
54 }, "~N,~N,~A,~N,~N,java.util.Hashtable");\r
55 Clazz.overrideMethod (c$, "addConsumer", \r
56 function (ic) {\r
57 if (this.theConsumers.contains (ic)) {\r
58 return;\r
59 }this.theConsumers.addElement (ic);\r
60 try {\r
61 this.initConsumer (ic);\r
62 this.sendPixels (ic, 0, 0, this.width, this.height);\r
63 if (this.isConsumer (ic)) {\r
64 ic.imageComplete (this.animating ? 2 : 3);\r
65 if (!this.animating && this.isConsumer (ic)) {\r
66 ic.imageComplete (1);\r
67 this.removeConsumer (ic);\r
68 }}} catch (e) {\r
69 if (Clazz.exceptionOf (e, Exception)) {\r
70 if (this.isConsumer (ic)) {\r
71 ic.imageComplete (1);\r
72 }} else {\r
73 throw e;\r
74 }\r
75 }\r
76 }, "java.awt.image.ImageConsumer");\r
77 Clazz.overrideMethod (c$, "isConsumer", \r
78 function (ic) {\r
79 return this.theConsumers.contains (ic);\r
80 }, "java.awt.image.ImageConsumer");\r
81 Clazz.overrideMethod (c$, "removeConsumer", \r
82 function (ic) {\r
83 this.theConsumers.removeElement (ic);\r
84 }, "java.awt.image.ImageConsumer");\r
85 Clazz.overrideMethod (c$, "startProduction", \r
86 function (ic) {\r
87 this.addConsumer (ic);\r
88 }, "java.awt.image.ImageConsumer");\r
89 Clazz.overrideMethod (c$, "requestTopDownLeftRightResend", \r
90 function (ic) {\r
91 }, "java.awt.image.ImageConsumer");\r
92 Clazz.defineMethod (c$, "setAnimated", \r
93 function (animated) {\r
94 this.animating = animated;\r
95 if (!this.animating) {\r
96 var enum_ = this.theConsumers.elements ();\r
97 while (enum_.hasMoreElements ()) {\r
98 var ic = enum_.nextElement ();\r
99 ic.imageComplete (3);\r
100 if (this.isConsumer (ic)) {\r
101 ic.imageComplete (1);\r
102 }}\r
103 this.theConsumers.removeAllElements ();\r
104 }}, "~B");\r
105 Clazz.defineMethod (c$, "setFullBufferUpdates", \r
106 function (fullbuffers) {\r
107 if (this.fullbuffers == fullbuffers) {\r
108 return;\r
109 }this.fullbuffers = fullbuffers;\r
110 if (this.animating) {\r
111 var enum_ = this.theConsumers.elements ();\r
112 while (enum_.hasMoreElements ()) {\r
113 var ic = enum_.nextElement ();\r
114 ic.setHints (fullbuffers ? (6) : 1);\r
115 }\r
116 }}, "~B");\r
117 Clazz.defineMethod (c$, "newPixels", \r
118 function () {\r
119 this.newPixels (0, 0, this.width, this.height, true);\r
120 });\r
121 Clazz.defineMethod (c$, "newPixels", \r
122 function (x, y, w, h) {\r
123 this.newPixels (x, y, w, h, true);\r
124 }, "~N,~N,~N,~N");\r
125 Clazz.defineMethod (c$, "newPixels", \r
126 function (x, y, w, h, framenotify) {\r
127 if (this.animating) {\r
128 if (this.fullbuffers) {\r
129 x = y = 0;\r
130 w = this.width;\r
131 h = this.height;\r
132 } else {\r
133 if (x < 0) {\r
134 w += x;\r
135 x = 0;\r
136 }if (x + w > this.width) {\r
137 w = this.width - x;\r
138 }if (y < 0) {\r
139 h += y;\r
140 y = 0;\r
141 }if (y + h > this.height) {\r
142 h = this.height - y;\r
143 }}if ((w <= 0 || h <= 0) && !framenotify) {\r
144 return;\r
145 }var enum_ = this.theConsumers.elements ();\r
146 while (enum_.hasMoreElements ()) {\r
147 var ic = enum_.nextElement ();\r
148 if (w > 0 && h > 0) {\r
149 this.sendPixels (ic, x, y, w, h);\r
150 }if (framenotify && this.isConsumer (ic)) {\r
151 ic.imageComplete (2);\r
152 }}\r
153 }}, "~N,~N,~N,~N,~B");\r
154 Clazz.defineMethod (c$, "newPixels", \r
155 function (newpix, newmodel, offset, scansize) {\r
156 this.pixels = newpix;\r
157 this.model = newmodel;\r
158 this.pixeloffset = offset;\r
159 this.pixelscan = scansize;\r
160 this.newPixels ();\r
161 }, "~A,java.awt.image.ColorModel,~N,~N");\r
162 Clazz.defineMethod (c$, "newPixels", \r
163 function (newpix, newmodel, offset, scansize) {\r
164 this.pixels = newpix;\r
165 this.model = newmodel;\r
166 this.pixeloffset = offset;\r
167 this.pixelscan = scansize;\r
168 this.newPixels ();\r
169 }, "~A,java.awt.image.ColorModel,~N,~N");\r
170 Clazz.defineMethod (c$, "initConsumer", \r
171  function (ic) {\r
172 if (this.isConsumer (ic)) {\r
173 ic.setDimensions (this.width, this.height);\r
174 }if (this.isConsumer (ic)) {\r
175 ic.setProperties (this.properties);\r
176 }if (this.isConsumer (ic)) {\r
177 ic.setColorModel (this.model);\r
178 }if (this.isConsumer (ic)) {\r
179 ic.setHints (this.animating ? (this.fullbuffers ? (6) : 1) : (30));\r
180 }}, "java.awt.image.ImageConsumer");\r
181 Clazz.defineMethod (c$, "sendPixels", \r
182  function (ic, x, y, w, h) {\r
183 var off = this.pixeloffset + this.pixelscan * y + x;\r
184 if (this.isConsumer (ic)) {\r
185 if (Clazz.instanceOf (this.pixels, Array)) {\r
186 ic.setPixels (x, y, w, h, this.model, (this.pixels), off, this.pixelscan);\r
187 } else {\r
188 ic.setPixels (x, y, w, h, this.model, (this.pixels), off, this.pixelscan);\r
189 }}}, "java.awt.image.ImageConsumer,~N,~N,~N,~N");\r
190 });\r