| 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(); } |