Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / image / Kernel.js
1 Clazz.declarePackage ("java.awt.image");
2 Clazz.load (null, "java.awt.image.Kernel", ["java.lang.IllegalArgumentException", "$.InternalError"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.width = 0;
5 this.height = 0;
6 this.xOrigin = 0;
7 this.yOrigin = 0;
8 this.data = null;
9 Clazz.instantialize (this, arguments);
10 }, java.awt.image, "Kernel", null, Cloneable);
11 Clazz.makeConstructor (c$, 
12 function (width, height, data) {
13 this.width = width;
14 this.height = height;
15 this.xOrigin = (width - 1) >> 1;
16 this.yOrigin = (height - 1) >> 1;
17 var len = width * height;
18 if (data.length < len) {
19 throw  new IllegalArgumentException ("Data array too small (is " + data.length + " and should be " + len);
20 }this.data =  Clazz.newFloatArray (len, 0);
21 System.arraycopy (data, 0, this.data, 0, len);
22 }, "~N,~N,~A");
23 Clazz.defineMethod (c$, "getXOrigin", 
24 function () {
25 return this.xOrigin;
26 });
27 Clazz.defineMethod (c$, "getYOrigin", 
28 function () {
29 return this.yOrigin;
30 });
31 Clazz.defineMethod (c$, "getWidth", 
32 function () {
33 return this.width;
34 });
35 Clazz.defineMethod (c$, "getHeight", 
36 function () {
37 return this.height;
38 });
39 Clazz.defineMethod (c$, "getKernelData", 
40 function (data) {
41 if (data == null) {
42 data =  Clazz.newFloatArray (this.data.length, 0);
43 } else if (data.length < this.data.length) {
44 throw  new IllegalArgumentException ("Data array too small (should be " + this.data.length + " but is " + data.length + " )");
45 }System.arraycopy (this.data, 0, data, 0, this.data.length);
46 return data;
47 }, "~A");
48 Clazz.defineMethod (c$, "clone", 
49 function () {
50 try {
51 return Clazz.superCall (this, java.awt.image.Kernel, "clone", []);
52 } catch (e) {
53 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {
54 throw  new InternalError ();
55 } else {
56 throw e;
57 }
58 }
59 });
60 });