Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package swingjs.api.js

File HTML5Canvas.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
60% of files have more coverage

Code metrics

6
10
3
1
59
25
6
0.6
3.33
3
2

Classes

Class Line # Actions
HTML5Canvas 5 10 6
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package swingjs.api.js;
2   
3    import java.awt.image.BufferedImage;
4   
 
5    public interface HTML5Canvas extends DOMNode {
6   
7    HTML5CanvasContext2D getContext(String str2d);
8   
9    /*
10    * Retrieves the byte[] data buffer from an HTML5 CANVAS element, optionally
11    * first setting its contents to a source IMG, CANVAS, or VIDEO element.
12    *
13    */
 
14  0 toggle static byte[] getDataBufferBytes(HTML5Canvas canvas, DOMNode sourceNode, int w, int h) {
15  0 if (sourceNode != null) {
16  0 DOMNode.setAttrInt(canvas, "width", w);
17  0 DOMNode.setAttrInt(canvas, "height", h);
18    }
19  0 HTML5CanvasContext2D ctx = canvas.getContext("2d");
20  0 if (sourceNode != null) {
21  0 ctx.drawImage(sourceNode, 0, 0, w, h);
22    }
23    // Coerse int[] to byte[]
24  0 return (byte[]) (Object) ctx.getImageData(0, 0, w, h).data;
25    }
26   
27    /**
28    * Install a source image (img, video, or canvas) into a matching BufferedImage
29    *
30    * @param sourceNode
31    * @param image
32    */
 
33  0 toggle static void setImageNode(DOMNode sourceNode, BufferedImage image) {
34    /**
35    * @j2sNative
36    *
37    * image._setImageNode$O$Z(sourceNode, false);
38    *
39    */ {
40    // image._setImageNode(sourceNode, false);
41    }
42    }
43   
44   
45   
 
46  0 toggle static HTML5Canvas createCanvas(int width, int height, String id) {
47  0 HTML5Canvas canvas = (HTML5Canvas) DOMNode.createElement("canvas", (id == null ? "img" + Math.random() : id + ""));
48  0 DOMNode.setStyles(canvas, "width", width + "px", "height", height + "px");
49    /**
50    * @j2sNative
51    *
52    * canvas.width = width;
53    * canvas.height = height;
54    *
55    */
56  0 return canvas;
57    }
58   
59    }