Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / image / ConvolveOp.js
1 Clazz.declarePackage ("java.awt.image");
2 Clazz.load (["java.awt.image.BufferedImageOp", "$.RasterOp"], "java.awt.image.ConvolveOp", ["java.lang.IllegalArgumentException", "$.NullPointerException", "java.awt.geom.Point2D", "java.awt.image.BufferedImage", "$.ImagingOpException", "jssun.awt.image.ImagingLib"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.kernel = null;
5 this.edgeHint = 0;
6 this.hints = null;
7 this.swingJStype = 'C';
8 Clazz.instantialize (this, arguments);
9 }, java.awt.image, "ConvolveOp", null, [java.awt.image.BufferedImageOp, java.awt.image.RasterOp]);
10 Clazz.makeConstructor (c$, 
11 function (kernel, edgeCondition, hints) {
12 this.kernel = kernel;
13 this.edgeHint = edgeCondition;
14 this.hints = hints;
15 }, "java.awt.image.Kernel,~N,java.awt.RenderingHints");
16 Clazz.makeConstructor (c$, 
17 function (kernel) {
18 this.kernel = kernel;
19 this.edgeHint = 0;
20 }, "java.awt.image.Kernel");
21 Clazz.defineMethod (c$, "getEdgeCondition", 
22 function () {
23 return this.edgeHint;
24 });
25 Clazz.defineMethod (c$, "getKernel", 
26 function () {
27 return this.kernel.clone ();
28 });
29 Clazz.defineMethod (c$, "filter", 
30 function (src, dst) {
31 if (src == null) {
32 throw  new NullPointerException ("src image is null");
33 }if (src === dst) {
34 throw  new IllegalArgumentException ("src image cannot be the same as the dst image");
35 }var needToConvert = false;
36 var srcCM = src.getColorModel ();
37 var dstCM;
38 var origDst = dst;
39 if (dst == null) {
40 dst = this.createCompatibleDestImage (src, null);
41 dstCM = srcCM;
42 origDst = dst;
43 } else {
44 dstCM = dst.getColorModel ();
45 if (srcCM.getColorSpace ().getType () != dstCM.getColorSpace ().getType ()) {
46 throw  new java.awt.image.ImagingOpException ("SwingJS: Differing color spaces not allowed");
47 }}if (jssun.awt.image.ImagingLib.filter (this, src, dst) == null) {
48 throw  new java.awt.image.ImagingOpException ("Unable to convolve src image");
49 }if (origDst !== dst) {
50 var g = origDst.createGraphics ();
51 try {
52 g.drawImage (dst, 0, 0, null);
53 } finally {
54 g.dispose ();
55 }
56 }return origDst;
57 }, "java.awt.image.BufferedImage,java.awt.image.BufferedImage");
58 Clazz.defineMethod (c$, "filter", 
59 function (src, dst) {
60 if (dst == null) {
61 dst = this.createCompatibleDestRaster (src);
62 } else if (src === dst) {
63 throw  new IllegalArgumentException ("src image cannot be the same as the dst image");
64 } else if (src.getNumBands () != dst.getNumBands ()) {
65 throw  new java.awt.image.ImagingOpException ("Different number of bands in src  and dst Rasters");
66 }if (jssun.awt.image.ImagingLib.filter (this, src, dst) == null) {
67 throw  new java.awt.image.ImagingOpException ("Unable to convolve src image");
68 }return dst;
69 }, "java.awt.image.Raster,java.awt.image.WritableRaster");
70 Clazz.overrideMethod (c$, "createCompatibleDestImage", 
71 function (src, destCM) {
72 var image;
73 var w = src.getWidth ();
74 var h = src.getHeight ();
75 var wr = null;
76 if (destCM == null) {
77 destCM = src.getColorModel ();
78 {
79 wr = src.getData ().createCompatibleWritableRaster (w, h);
80 }}if (wr == null) {
81 wr = destCM.createCompatibleWritableRaster (w, h);
82 }image =  new java.awt.image.BufferedImage (destCM, wr, destCM.isAlphaPremultiplied (), null);
83 return image;
84 }, "java.awt.image.BufferedImage,java.awt.image.ColorModel");
85 Clazz.overrideMethod (c$, "createCompatibleDestRaster", 
86 function (src) {
87 return src.createCompatibleWritableRaster ();
88 }, "java.awt.image.Raster");
89 Clazz.defineMethod (c$, "getBounds2D", 
90 function (src) {
91 return this.getBounds2D (src.getRaster ());
92 }, "java.awt.image.BufferedImage");
93 Clazz.defineMethod (c$, "getBounds2D", 
94 function (src) {
95 return src.getBounds ();
96 }, "java.awt.image.Raster");
97 Clazz.overrideMethod (c$, "getPoint2D", 
98 function (srcPt, dstPt) {
99 if (dstPt == null) {
100 dstPt =  new java.awt.geom.Point2D.Float ();
101 }dstPt.setLocation (srcPt.getX (), srcPt.getY ());
102 return dstPt;
103 }, "java.awt.geom.Point2D,java.awt.geom.Point2D");
104 Clazz.overrideMethod (c$, "getRenderingHints", 
105 function () {
106 return this.hints;
107 });
108 Clazz.defineStatics (c$,
109 "EDGE_ZERO_FILL", 0,
110 "EDGE_NO_OP", 1);
111 });