0a15f4d320c09b965a6a9ca9a3b5283bc3a83bb9
[jalviewjs.git] / site / swingjs / j2s / jssun / awt / image / IntegerInterleavedRaster.js
1 Clazz.declarePackage ("jssun.awt.image");
2 Clazz.load (["jssun.awt.image.IntegerComponentRaster"], "jssun.awt.image.IntegerInterleavedRaster", ["java.lang.ArrayIndexOutOfBoundsException", "java.awt.Point", "$.Rectangle", "java.awt.image.DataBufferInt", "$.RasterFormatException", "$.SinglePixelPackedSampleModel"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.$maxX = 0;
5 this.$maxY = 0;
6 Clazz.instantialize (this, arguments);
7 }, jssun.awt.image, "IntegerInterleavedRaster", jssun.awt.image.IntegerComponentRaster);
8 Clazz.makeConstructor (c$, 
9 function (sampleModel, origin) {
10 Clazz.superConstructor (this, jssun.awt.image.IntegerInterleavedRaster, []);
11 this.setIntInterRaster (sampleModel, sampleModel.createDataBuffer (),  new java.awt.Rectangle (origin.x, origin.y, sampleModel.getWidth (), sampleModel.getHeight ()), origin, null);
12 }, "java.awt.image.SampleModel,java.awt.Point");
13 Clazz.makeConstructor (c$, 
14 function (sampleModel, dataBuffer, origin) {
15 Clazz.superConstructor (this, jssun.awt.image.IntegerInterleavedRaster, []);
16 this.setParams (sampleModel, dataBuffer, origin);
17 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Point");
18 Clazz.makeConstructor (c$, 
19 function () {
20 Clazz.superConstructor (this, jssun.awt.image.IntegerInterleavedRaster, []);
21 });
22 Clazz.overrideMethod (c$, "setParams", 
23 function (sampleModel, dataBuffer, origin) {
24 this.setIntInterRaster (sampleModel, dataBuffer,  new java.awt.Rectangle (origin.x, origin.y, sampleModel.getWidth (), sampleModel.getHeight ()), origin, null);
25 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Point");
26 Clazz.makeConstructor (c$, 
27 function (sampleModel, dataBuffer, aRegion, origin, parent) {
28 Clazz.superConstructor (this, jssun.awt.image.IntegerInterleavedRaster, []);
29 this.setIntInterRaster (sampleModel, dataBuffer, aRegion, origin, parent);
30 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Rectangle,java.awt.Point,jssun.awt.image.IntegerInterleavedRaster");
31 Clazz.defineMethod (c$, "setIntInterRaster", 
32  function (sampleModel, dataBuffer, aRegion, origin, parent) {
33 this.setIntCompRaster (sampleModel, dataBuffer, aRegion, origin, parent);
34 this.$maxX = this.minX + this.width;
35 this.$maxY = this.minY + this.height;
36 if (!(Clazz.instanceOf (dataBuffer, java.awt.image.DataBufferInt))) {
37 throw  new java.awt.image.RasterFormatException ("IntegerInterleavedRasters must haveinteger DataBuffers");
38 }var dbi = dataBuffer;
39 this.data = jssun.awt.image.SunWritableRaster.stealData (dbi, 0);
40 if (Clazz.instanceOf (sampleModel, java.awt.image.SinglePixelPackedSampleModel)) {
41 var sppsm = sampleModel;
42 this.scanlineStride = sppsm.getScanlineStride ();
43 this.pixelStride = 1;
44 this.dataOffsets =  Clazz.newIntArray (1, 0);
45 this.dataOffsets[0] = dbi.getOffset ();
46 this.bandOffset = this.dataOffsets[0];
47 var xOffset = aRegion.x - origin.x;
48 var yOffset = aRegion.y - origin.y;
49 this.dataOffsets[0] += xOffset + yOffset * this.scanlineStride;
50 this.numDataElems = sppsm.getNumDataElements ();
51 } else {
52 throw  new java.awt.image.RasterFormatException ("IntegerInterleavedRasters must have SinglePixelPackedSampleModel");
53 }this.verify ();
54 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Rectangle,java.awt.Point,jssun.awt.image.IntegerInterleavedRaster");
55 Clazz.overrideMethod (c$, "getDataOffsets", 
56 function () {
57 return this.dataOffsets.clone ();
58 });
59 Clazz.overrideMethod (c$, "getDataOffset", 
60 function (band) {
61 return this.dataOffsets[band];
62 }, "~N");
63 Clazz.overrideMethod (c$, "getScanlineStride", 
64 function () {
65 return this.scanlineStride;
66 });
67 Clazz.overrideMethod (c$, "getPixelStride", 
68 function () {
69 return this.pixelStride;
70 });
71 Clazz.overrideMethod (c$, "getDataStorage", 
72 function () {
73 return this.data;
74 });
75 Clazz.defineMethod (c$, "getDataElements", 
76 function (x, y, obj) {
77 if ((x < this.minX) || (y < this.minY) || (x >= this.$maxX) || (y >= this.$maxY)) {
78 throw  new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!");
79 }var outData;
80 if (obj == null) {
81 outData =  Clazz.newIntArray (1, 0);
82 } else {
83 outData = obj;
84 }var off = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
85 outData[0] = this.data[off];
86 return outData;
87 }, "~N,~N,~O");
88 Clazz.defineMethod (c$, "getDataElements", 
89 function (x, y, w, h, obj) {
90 if ((x < this.minX) || (y < this.minY) || (x + w > this.$maxX) || (y + h > this.$maxY)) {
91 throw  new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!");
92 }var outData;
93 if (Clazz.instanceOf (obj, Array)) {
94 outData = obj;
95 } else {
96 outData =  Clazz.newIntArray (w * h, 0);
97 }var yoff = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
98 var off = 0;
99 for (var ystart = 0; ystart < h; ystart++) {
100 System.arraycopy (this.data, yoff, outData, off, w);
101 off += w;
102 yoff += this.scanlineStride;
103 }
104 return outData;
105 }, "~N,~N,~N,~N,~O");
106 Clazz.defineMethod (c$, "setDataElements", 
107 function (x, y, obj) {
108 if ((x < this.minX) || (y < this.minY) || (x >= this.$maxX) || (y >= this.$maxY)) {
109 throw  new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!");
110 }var inData = obj;
111 var off = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
112 this.data[off] = inData[0];
113 this.markDirty ();
114 }, "~N,~N,~O");
115 Clazz.defineMethod (c$, "setDataElements", 
116 function (x, y, inRaster) {
117 var dstOffX = x + inRaster.getMinX ();
118 var dstOffY = y + inRaster.getMinY ();
119 var width = inRaster.getWidth ();
120 var height = inRaster.getHeight ();
121 if ((dstOffX < this.minX) || (dstOffY < this.minY) || (dstOffX + width > this.$maxX) || (dstOffY + height > this.$maxY)) {
122 throw  new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!");
123 }this.setDataElements (dstOffX, dstOffY, width, height, inRaster);
124 }, "~N,~N,java.awt.image.Raster");
125 Clazz.defineMethod (c$, "setDataElements", 
126  function (dstX, dstY, width, height, inRaster) {
127 if (width <= 0 || height <= 0) {
128 return;
129 }var srcOffX = inRaster.getMinX ();
130 var srcOffY = inRaster.getMinY ();
131 var tdata = null;
132 if (Clazz.instanceOf (inRaster, jssun.awt.image.IntegerInterleavedRaster)) {
133 var ict = inRaster;
134 tdata = ict.getDataStorage ();
135 var tss = ict.getScanlineStride ();
136 var toff = ict.getDataOffset (0);
137 var srcOffset = toff;
138 var dstOffset = this.dataOffsets[0] + (dstY - this.minY) * this.scanlineStride + (dstX - this.minX);
139 for (var startY = 0; startY < height; startY++) {
140 System.arraycopy (tdata, srcOffset, this.data, dstOffset, width);
141 srcOffset += tss;
142 dstOffset += this.scanlineStride;
143 }
144 this.markDirty ();
145 return;
146 }var odata = null;
147 for (var startY = 0; startY < height; startY++) {
148 odata = inRaster.getDataElements (srcOffX, srcOffY + startY, width, 1, odata);
149 this.setDataElements (dstX, dstY + startY, width, 1, odata);
150 }
151 }, "~N,~N,~N,~N,java.awt.image.Raster");
152 Clazz.defineMethod (c$, "setDataElements", 
153 function (x, y, w, h, obj) {
154 if ((x < this.minX) || (y < this.minY) || (x + w > this.$maxX) || (y + h > this.$maxY)) {
155 throw  new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!");
156 }var inData = obj;
157 var yoff = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
158 var off = 0;
159 for (var ystart = 0; ystart < h; ystart++) {
160 System.arraycopy (inData, off, this.data, yoff, w);
161 off += w;
162 yoff += this.scanlineStride;
163 }
164 this.markDirty ();
165 }, "~N,~N,~N,~N,~O");
166 Clazz.overrideMethod (c$, "createWritableChild", 
167 function (x, y, width, height, x0, y0, bandList) {
168 if (x < this.minX) {
169 throw  new java.awt.image.RasterFormatException ("x lies outside raster");
170 }if (y < this.minY) {
171 throw  new java.awt.image.RasterFormatException ("y lies outside raster");
172 }if ((x + width < x) || (x + width > this.minX + this.width)) {
173 throw  new java.awt.image.RasterFormatException ("(x + width) is outside raster");
174 }if ((y + height < y) || (y + height > this.minY + this.height)) {
175 throw  new java.awt.image.RasterFormatException ("(y + height) is outside raster");
176 }var sm;
177 if (bandList != null) sm = this.sampleModel.createSubsetSampleModel (bandList);
178  else sm = this.sampleModel;
179 var deltaX = x0 - x;
180 var deltaY = y0 - y;
181 return  new jssun.awt.image.IntegerInterleavedRaster (sm, this.dataBuffer,  new java.awt.Rectangle (x0, y0, width, height),  new java.awt.Point (this.sampleModelTranslateX + deltaX, this.sampleModelTranslateY + deltaY), this);
182 }, "~N,~N,~N,~N,~N,~N,~A");
183 Clazz.overrideMethod (c$, "createChild", 
184 function (x, y, width, height, x0, y0, bandList) {
185 return this.createWritableChild (x, y, width, height, x0, y0, bandList);
186 }, "~N,~N,~N,~N,~N,~N,~A");
187 Clazz.defineMethod (c$, "createCompatibleWritableRaster", 
188 function (w, h) {
189 if (w <= 0 || h <= 0) {
190 throw  new java.awt.image.RasterFormatException ("negative " + ((w <= 0) ? "width" : "height"));
191 }var sm = this.sampleModel.createCompatibleSampleModel (w, h);
192 return  new jssun.awt.image.IntegerInterleavedRaster (sm,  new java.awt.Point (0, 0));
193 }, "~N,~N");
194 Clazz.defineMethod (c$, "createCompatibleWritableRaster", 
195 function () {
196 return this.createCompatibleWritableRaster (this.width, this.height);
197 });
198 Clazz.overrideMethod (c$, "toString", 
199 function () {
200 return  String.instantialize ("IntegerInterleavedRaster: width = " + this.width + " height = " + this.height + " #Bands = " + this.numBands + " xOff = " + this.sampleModelTranslateX + " yOff = " + this.sampleModelTranslateY + " dataOffset[0] " + this.dataOffsets[0]);
201 });
202 });