MCPcopy Create free account
hub / github.com/HumbleUI/Skija / execute

Method execute

tests/java/DocumentTest.java:10–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9public class DocumentTest implements Executable {
10 @Override
11 public void execute() throws Exception {
12 ByteArrayOutputStream out = new ByteArrayOutputStream();
13 try (OutputWStream stream = new OutputWStream(out);
14 Document doc = Document.makePDF(stream)) {
15
16 try (Canvas canvas = doc.beginPage(100, 100)) {
17 canvas.annotateNamedDestination(0, 0, "start");
18 Paint paint = new Paint().setColor(0xFFFF0000);
19 Rect rect = Rect.makeXYWH(10, 10, 80, 80);
20 canvas.drawRect(rect, paint);
21 canvas.annotateRectWithURL(rect, "https://example.org/");
22 canvas.annotateLinkToDestination(Rect.makeXYWH(0, 80, 100, 20), "start");
23 }
24 doc.endPage();
25 doc.close();
26 }
27
28 byte[] pdfBytes = out.toByteArray();
29 if (pdfBytes.length < 4) {
30 throw new RuntimeException("PDF output too short");
31 }
32 assertEquals((byte) '%', pdfBytes[0]);
33 assertEquals((byte) 'P', pdfBytes[1]);
34 assertEquals((byte) 'D', pdfBytes[2]);
35 assertEquals((byte) 'F', pdfBytes[3]);
36 }
37}

Callers

nothing calls this directly

Calls 10

makePDFMethod · 0.95
beginPageMethod · 0.80
drawRectMethod · 0.80
annotateRectWithURLMethod · 0.80
endPageMethod · 0.80
assertEqualsMethod · 0.80
setColorMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected