Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / image / WritableRaster.js
1 Clazz.declarePackage ("java.awt.image");
2 Clazz.load (["java.awt.image.Raster"], "java.awt.image.WritableRaster", ["java.lang.ArrayIndexOutOfBoundsException", "java.awt.Point", "$.Rectangle", "java.awt.image.RasterFormatException"], function () {
3 c$ = Clazz.declareType (java.awt.image, "WritableRaster", java.awt.image.Raster);
4 Clazz.defineMethod (c$, "setParams", 
5 function (model, dataBuffer, origin) {
6 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Point");
7 Clazz.makeConstructor (c$, 
8 function () {
9 Clazz.superConstructor (this, java.awt.image.WritableRaster, []);
10 });
11 Clazz.makeConstructor (c$, 
12 function (sampleModel, origin) {
13 Clazz.superConstructor (this, java.awt.image.WritableRaster, []);
14 this.setRaster (sampleModel, sampleModel.createDataBuffer (),  new java.awt.Rectangle (origin.x, origin.y, sampleModel.getWidth (), sampleModel.getHeight ()), origin, null);
15 }, "java.awt.image.SampleModel,java.awt.Point");
16 Clazz.makeConstructor (c$, 
17 function (sampleModel, dataBuffer, origin) {
18 Clazz.superConstructor (this, java.awt.image.WritableRaster, []);
19 this.setRaster (sampleModel, dataBuffer,  new java.awt.Rectangle (origin.x, origin.y, sampleModel.getWidth (), sampleModel.getHeight ()), origin, null);
20 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Point");
21 Clazz.makeConstructor (c$, 
22 function (sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent) {
23 Clazz.superConstructor (this, java.awt.image.WritableRaster, []);
24 this.setRaster (sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent);
25 }, "java.awt.image.SampleModel,java.awt.image.DataBuffer,java.awt.Rectangle,java.awt.Point,java.awt.image.Raster");
26 Clazz.defineMethod (c$, "getWritableParent", 
27 function () {
28 return this.parent;
29 });
30 Clazz.defineMethod (c$, "createWritableTranslatedChild", 
31 function (childMinX, childMinY) {
32 return this.createWritableChild (this.minX, this.minY, this.width, this.height, childMinX, childMinY, null);
33 }, "~N,~N");
34 Clazz.defineMethod (c$, "createWritableChild", 
35 function (parentX, parentY, w, h, childMinX, childMinY, bandList) {
36 if (parentX < this.minX) {
37 throw  new java.awt.image.RasterFormatException ("parentX lies outside raster");
38 }if (parentY < this.minY) {
39 throw  new java.awt.image.RasterFormatException ("parentY lies outside raster");
40 }if ((parentX + w < parentX) || (parentX + w > this.width + this.minX)) {
41 throw  new java.awt.image.RasterFormatException ("(parentX + width) is outside raster");
42 }if ((parentY + h < parentY) || (parentY + h > this.height + this.minY)) {
43 throw  new java.awt.image.RasterFormatException ("(parentY + height) is outside raster");
44 }var sm;
45 if (bandList != null) {
46 sm = this.sampleModel.createSubsetSampleModel (bandList);
47 } else {
48 sm = this.sampleModel;
49 }var deltaX = childMinX - parentX;
50 var deltaY = childMinY - parentY;
51 return  new java.awt.image.WritableRaster (sm, this.getDataBuffer (),  new java.awt.Rectangle (childMinX, childMinY, w, h),  new java.awt.Point (this.sampleModelTranslateX + deltaX, this.sampleModelTranslateY + deltaY), this);
52 }, "~N,~N,~N,~N,~N,~N,~A");
53 Clazz.defineMethod (c$, "setDataElements", 
54 function (x, y, inData) {
55 if (Clazz.instanceOf (inData, java.awt.image.Raster)) {
56 this.setDataElementsRaster (x, y, inData);
57 } else {
58 this.sampleModel.setDataElements (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, inData, this.dataBuffer);
59 }}, "~N,~N,~O");
60 Clazz.defineMethod (c$, "setDataElementsRaster", 
61 function (x, y, inRaster) {
62 var dstOffX = x + inRaster.getMinX ();
63 var dstOffY = y + inRaster.getMinY ();
64 var width = inRaster.getWidth ();
65 var height = inRaster.getHeight ();
66 if ((dstOffX < this.minX) || (dstOffY < this.minY) || (dstOffX + width > this.minX + this.width) || (dstOffY + height > this.minY + this.height)) {
67 throw  new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!");
68 }var srcOffX = inRaster.getMinX ();
69 var srcOffY = inRaster.getMinY ();
70 var tdata = null;
71 for (var startY = 0; startY < height; startY++) {
72 tdata = inRaster.getDataElements (srcOffX, srcOffY + startY, width, 1, tdata);
73 this.setDataElements (dstOffX, dstOffY + startY, width, 1, tdata);
74 }
75 }, "~N,~N,java.awt.image.Raster");
76 Clazz.defineMethod (c$, "setDataElements", 
77 function (x, y, w, h, inData) {
78 this.sampleModel.setDataElements (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, w, h, inData, this.dataBuffer);
79 }, "~N,~N,~N,~N,~O");
80 Clazz.defineMethod (c$, "setRect", 
81 function (srcRaster) {
82 this.setRect (0, 0, srcRaster);
83 }, "java.awt.image.Raster");
84 Clazz.defineMethod (c$, "setRect", 
85 function (dx, dy, srcRaster) {
86 var width = srcRaster.getWidth ();
87 var height = srcRaster.getHeight ();
88 var srcOffX = srcRaster.getMinX ();
89 var srcOffY = srcRaster.getMinY ();
90 var dstOffX = dx + srcOffX;
91 var dstOffY = dy + srcOffY;
92 if (dstOffX < this.minX) {
93 var skipX = this.minX - dstOffX;
94 width -= skipX;
95 srcOffX += skipX;
96 dstOffX = this.minX;
97 }if (dstOffY < this.minY) {
98 var skipY = this.minY - dstOffY;
99 height -= skipY;
100 srcOffY += skipY;
101 dstOffY = this.minY;
102 }if (dstOffX + width > this.minX + this.width) {
103 width = this.minX + this.width - dstOffX;
104 }if (dstOffY + height > this.minY + this.height) {
105 height = this.minY + this.height - dstOffY;
106 }if (width <= 0 || height <= 0) {
107 return;
108 }switch (srcRaster.getSampleModel ().getDataType ()) {
109 case 0:
110 case 3:
111 var iData = null;
112 for (var startY = 0; startY < height; startY++) {
113 iData = srcRaster.getPixels (srcOffX, srcOffY + startY, width, 1, iData);
114 this.setPixels (dstOffX, dstOffY + startY, width, 1, iData);
115 }
116 break;
117 }
118 }, "~N,~N,java.awt.image.Raster");
119 Clazz.defineMethod (c$, "setPixel", 
120 function (x, y, iArray) {
121 this.sampleModel.setPixel (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, iArray, this.dataBuffer);
122 }, "~N,~N,~A");
123 Clazz.defineMethod (c$, "setPixel", 
124 function (x, y, fArray) {
125 this.sampleModel.setPixel (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, fArray, this.dataBuffer);
126 }, "~N,~N,~A");
127 Clazz.defineMethod (c$, "setPixel", 
128 function (x, y, dArray) {
129 this.sampleModel.setPixel (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, dArray, this.dataBuffer);
130 }, "~N,~N,~A");
131 Clazz.defineMethod (c$, "setPixels", 
132 function (x, y, w, h, iArray) {
133 this.sampleModel.setPixels (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, w, h, iArray, this.dataBuffer);
134 }, "~N,~N,~N,~N,~A");
135 Clazz.defineMethod (c$, "setPixels", 
136 function (x, y, w, h, fArray) {
137 this.sampleModel.setPixels (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, w, h, fArray, this.dataBuffer);
138 }, "~N,~N,~N,~N,~A");
139 Clazz.defineMethod (c$, "setPixels", 
140 function (x, y, w, h, dArray) {
141 this.sampleModel.setPixels (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, w, h, dArray, this.dataBuffer);
142 }, "~N,~N,~N,~N,~A");
143 Clazz.defineMethod (c$, "setSample", 
144 function (x, y, b, s) {
145 this.sampleModel.setSample (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, b, s, this.dataBuffer);
146 }, "~N,~N,~N,~N");
147 Clazz.defineMethod (c$, "setSample", 
148 function (x, y, b, s) {
149 this.sampleModel.setSample (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, b, s, this.dataBuffer);
150 }, "~N,~N,~N,~N");
151 Clazz.defineMethod (c$, "setSample", 
152 function (x, y, b, s) {
153 this.sampleModel.setSample (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, b, s, this.dataBuffer);
154 }, "~N,~N,~N,~N");
155 Clazz.defineMethod (c$, "setSamples", 
156 function (x, y, w, h, b, iArray) {
157 this.sampleModel.setSamples (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, w, h, b, iArray, this.dataBuffer);
158 }, "~N,~N,~N,~N,~N,~A");
159 Clazz.defineMethod (c$, "setSamples", 
160 function (x, y, w, h, b, fArray) {
161 this.sampleModel.setSamples (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, w, h, b, fArray, this.dataBuffer);
162 }, "~N,~N,~N,~N,~N,~A");
163 Clazz.defineMethod (c$, "setSamples", 
164 function (x, y, w, h, b, dArray) {
165 this.sampleModel.setSamples (x - this.sampleModelTranslateX, y - this.sampleModelTranslateY, w, h, b, dArray, this.dataBuffer);
166 }, "~N,~N,~N,~N,~N,~A");
167 });