From f1f26b60f22e8efe0b13f6afde916dab597d7737 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:04:48 +0000 Subject: Display signature placeholder git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@117 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../pdfover/gui/composites/SignaturePanel.java | 43 +++++++++++++++------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java index 1c6a6e9c..4c83e57f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java @@ -49,23 +49,25 @@ public class SignaturePanel extends JPanel { private static final long serialVersionUID = 1L; /** The PDF file being displayed */ - private PDFFile pdf; + private PDFFile pdf = null; /** The image of the rendered PDF page being displayed */ - Image currentImage; + Image currentImage = null; /** The current PDFPage that was rendered into currentImage */ - private PDFPage currentPage; + private PDFPage currentPage = null; /** The current transform from screen to page space */ - AffineTransform currentXform; + AffineTransform currentXform = null; /** The horizontal offset of the image from the left edge of the panel */ - int offx; + int offx = 0; /** The vertical offset of the image from the top of the panel */ - int offy; + int offy = 0; /** The size of the image */ - private Dimension prevSize; + private Dimension prevSize = null; /** The position of the signature, in document space */ - Point2D sigPagePos; + Point2D sigPagePos = null; /** The position of the signature, in screen space */ - Point2D sigScreenPos; + Point2D sigScreenPos = null; + /** The signature placeholder image */ + private Image sigPlaceholder = null; /** * Create a new PagePanel, with a default size of 800 by 600 pixels. @@ -73,8 +75,7 @@ public class SignaturePanel extends JPanel { */ public SignaturePanel(PDFFile pdf) { super(new BorderLayout()); - this.pdf = pdf; - this.sigPagePos = null; + setDocument(pdf); setPreferredSize(new Dimension(800, 600)); setFocusable(true); addMouseListener(this.mouseListener); @@ -92,6 +93,15 @@ public class SignaturePanel extends JPanel { showPage(pdf.getNumPages()); } + /** + * Set the signature placeholder image + * @param placeholder signature placeholder + */ + public void setSignaturePlaceholder(Image placeholder) + { + this.sigPlaceholder = placeholder; + } + /** * Change the currently displayed page * @param page the number of the page to display @@ -204,12 +214,19 @@ public class SignaturePanel extends JPanel { if ((imwid == sz.width && imhgt <= sz.height) || (imhgt == sz.height && imwid <= sz.width)) { + // draw document g.drawImage(this.currentImage, this.offx, this.offy, this); - g.setColor(Color.red); + // draw signature int sigx = (int) (this.offx + this.sigScreenPos.getX()); int sigy = (int) (this.offy + this.sigScreenPos.getY()); - g.drawRect(sigx - 10, sigy - 10, 20, 20); + if (this.sigPlaceholder == null) { + g.setColor(Color.red); + g.drawRect(sigx - 10, sigy - 10, 20, 20); + } + else { + g.drawImage(this.sigPlaceholder, sigx, sigy, null); + } } else { // the image is bogus. try again, or give up. -- cgit v1.2.3