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