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