Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / image / ByteLookupTable.js
1 Clazz.declarePackage ("java.awt.image");
2 Clazz.load (["java.awt.image.LookupTable"], "java.awt.image.ByteLookupTable", ["java.lang.ArrayIndexOutOfBoundsException"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.data = null;
5 Clazz.instantialize (this, arguments);
6 }, java.awt.image, "ByteLookupTable", java.awt.image.LookupTable);
7 Clazz.makeConstructor (c$, 
8 function (offset, data) {
9 Clazz.superConstructor (this, java.awt.image.ByteLookupTable, [offset, data.length]);
10 this.numComponents = data.length;
11 this.numEntries = data[0].length;
12 this.data =  Clazz.newByteArray (this.numComponents, 0);
13 for (var i = 0; i < this.numComponents; i++) {
14 this.data[i] = data[i];
15 }
16 }, "~N,~A");
17 Clazz.makeConstructor (c$, 
18 function (offset, data) {
19 Clazz.superConstructor (this, java.awt.image.ByteLookupTable, [offset, data.length]);
20 this.numComponents = 1;
21 this.numEntries = data.length;
22 this.data =  Clazz.newByteArray (1, 0);
23 this.data[0] = data;
24 }, "~N,~A");
25 Clazz.defineMethod (c$, "getTable", 
26 function () {
27 return this.data;
28 });
29 Clazz.defineMethod (c$, "lookupPixel", 
30 function (src, dst) {
31 if (dst == null) {
32 dst =  Clazz.newIntArray (src.length, 0);
33 }if (this.numComponents == 1) {
34 for (var i = 0; i < src.length; i++) {
35 var s = src[i] - this.offset;
36 if (s < 0) {
37 throw  new ArrayIndexOutOfBoundsException ("src[" + i + "]-offset is " + "less than zero");
38 }dst[i] = this.data[0][s];
39 }
40 } else {
41 for (var i = 0; i < src.length; i++) {
42 var s = src[i] - this.offset;
43 if (s < 0) {
44 throw  new ArrayIndexOutOfBoundsException ("src[" + i + "]-offset is " + "less than zero");
45 }dst[i] = this.data[i][s];
46 }
47 }return dst;
48 }, "~A,~A");
49 Clazz.defineMethod (c$, "lookupPixel", 
50 function (src, dst) {
51 if (dst == null) {
52 dst =  Clazz.newByteArray (src.length, 0);
53 }if (this.numComponents == 1) {
54 for (var i = 0; i < src.length; i++) {
55 var s = (src[i] & 0xff) - this.offset;
56 if (s < 0) {
57 throw  new ArrayIndexOutOfBoundsException ("src[" + i + "]-offset is " + "less than zero");
58 }dst[i] = this.data[0][s];
59 }
60 } else {
61 for (var i = 0; i < src.length; i++) {
62 var s = (src[i] & 0xff) - this.offset;
63 if (s < 0) {
64 throw  new ArrayIndexOutOfBoundsException ("src[" + i + "]-offset is " + "less than zero");
65 }dst[i] = this.data[i][s];
66 }
67 }return dst;
68 }, "~A,~A");
69 });