diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:04:48 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:04:48 +0000 |
commit | f1f26b60f22e8efe0b13f6afde916dab597d7737 (patch) | |
tree | 0f676321d09e23c1810c2161da22a7e241d0d303 /pdf-over-gui/src | |
parent | f24deb458da360d3b390654d6d245e30c57924d7 (diff) | |
download | pdf-over-f1f26b60f22e8efe0b13f6afde916dab597d7737.tar.gz pdf-over-f1f26b60f22e8efe0b13f6afde916dab597d7737.tar.bz2 pdf-over-f1f26b60f22e8efe0b13f6afde916dab597d7737.zip |
Display signature placeholder
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@117 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src')
3 files changed, 44 insertions, 14 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java index 922e278b..716e1388 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java @@ -35,7 +35,6 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.ScrollBar; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -217,4 +216,14 @@ public class PositioningComposite extends StateComposite { public SignaturePosition getPosition() { return this.position; } + + /** + * Set the signature placeholder image + * @param placeholder signature placeholder + */ + public void setPlaceholder(Image placeholder) { + if (this.viewer == null) + return; + this.viewer.setSignaturePlaceholder(placeholder); + } } 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); @@ -93,6 +94,15 @@ public class SignaturePanel extends JPanel { } /** + * 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. diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index e08a0f69..39ce2b08 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -56,7 +56,11 @@ public class PositioningState extends State { this.positionComposite = this.stateMachine.getGUIProvider().createComposite(PositioningComposite.class, SWT.RESIZE, this); log.debug("Displaying " + this.stateMachine.getStatus().getDocument()); + SignatureParameter param = this.stateMachine.getPDFSigner().getPDFSigner().newParameter(); + Emblem emblem = new FileNameEmblem(this.stateMachine.getConfigProvider().getDefaultEmblem()); + param.setEmblem(emblem); this.positionComposite.displayDocument(this.stateMachine.getStatus().getDocument()); + this.positionComposite.setPlaceholder(param.getPlaceholder()); } return this.positionComposite; |