summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java43
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java4
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;