MCPcopy Create free account
hub / github.com/ArtifexSoftware/mupdf / paint

Method paint

platform/java/example/PageCanvas.java:56–83  ·  view source on GitHub ↗
(Graphics g)

Source from the content-addressed store, hash-verified

54 }
55
56 public void paint(Graphics g) {
57 if (image == null)
58 return;
59
60 float imageScale = 1 / pixelScale;
61 final Graphics2D g2d = (Graphics2D)g.create(0, 0, image.getWidth(), image.getHeight());
62 g2d.scale(imageScale, imageScale);
63 g2d.drawImage(image, 0, 0, null);
64
65 if (hits != null) {
66 g2d.setColor(new Color(1, 0, 0, 0.4f));
67
68 for (Quad[] hit : hits)
69 for (Quad q : hit) {
70 int[] x = new int[]{(int)q.ul_x, (int)q.ur_x, (int)q.lr_x, (int)q.ll_x };
71 int[] y = new int[]{(int)q.ul_y, (int)q.ur_y, (int)q.lr_y, (int)q.ll_y };
72 g2d.fillPolygon(x, y, 4);
73 }
74 }
75
76 if (links != null) {
77 g2d.setColor(new Color(0, 0, 1, 0.1f));
78 for (Rect link : links)
79 g2d.fillRect((int)link.x0, (int)link.y0, (int)(link.x1-link.x0), (int)(link.y1-link.y0));
80 }
81
82 g2d.dispose();
83 }
84
85 public Dimension getMinimumSize() { return getPreferredSize(); }
86 public Dimension getMaximumSize() { return getPreferredSize(); }

Callers 1

updateMethod · 0.95

Calls 5

scaleMethod · 0.80
disposeMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
setColorMethod · 0.45

Tested by

no test coverage detected