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 () {
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$,
20 Clazz.superConstructor (this, jssun.awt.image.IntegerInterleavedRaster, []);
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 ();
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 ();
52 throw new java.awt.image.RasterFormatException ("IntegerInterleavedRasters must have SinglePixelPackedSampleModel");
54 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Rectangle,java.awt.Point,jssun.awt.image.IntegerInterleavedRaster");
55 Clazz.overrideMethod (c$, "getDataOffsets",
57 return this.dataOffsets.clone ();
59 Clazz.overrideMethod (c$, "getDataOffset",
61 return this.dataOffsets[band];
63 Clazz.overrideMethod (c$, "getScanlineStride",
65 return this.scanlineStride;
67 Clazz.overrideMethod (c$, "getPixelStride",
69 return this.pixelStride;
71 Clazz.overrideMethod (c$, "getDataStorage",
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!");
81 outData = Clazz.newIntArray (1, 0);
84 }var off = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
85 outData[0] = this.data[off];
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!");
93 if (Clazz.instanceOf (obj, Array)) {
96 outData = Clazz.newIntArray (w * h, 0);
97 }var yoff = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
99 for (var ystart = 0; ystart < h; ystart++) {
100 System.arraycopy (this.data, yoff, outData, off, w);
102 yoff += this.scanlineStride;
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!");
111 var off = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
112 this.data[off] = inData[0];
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) {
129 }var srcOffX = inRaster.getMinX ();
130 var srcOffY = inRaster.getMinY ();
132 if (Clazz.instanceOf (inRaster, jssun.awt.image.IntegerInterleavedRaster)) {
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);
142 dstOffset += this.scanlineStride;
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);
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!");
157 var yoff = (y - this.minY) * this.scanlineStride + (x - this.minX) + this.dataOffsets[0];
159 for (var ystart = 0; ystart < h; ystart++) {
160 System.arraycopy (inData, off, this.data, yoff, w);
162 yoff += this.scanlineStride;
165 }, "~N,~N,~N,~N,~O");
166 Clazz.overrideMethod (c$, "createWritableChild",
167 function (x, y, width, height, x0, y0, bandList) {
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");
177 if (bandList != null) sm = this.sampleModel.createSubsetSampleModel (bandList);
178 else sm = this.sampleModel;
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",
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));
194 Clazz.defineMethod (c$, "createCompatibleWritableRaster",
196 return this.createCompatibleWritableRaster (this.width, this.height);
198 Clazz.overrideMethod (c$, "toString",
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]);