summaryrefslogtreecommitdiff
path: root/trunk
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:39 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:39 +0000
commitb2a5eec09446851751037c5b57f2576b54ef1f2b (patch)
tree89d935e55a08b87c85d63ef656437d239c060f93 /trunk
parent08df77fba7e2464c0823f0b2e6a8f37e1fbc33d9 (diff)
downloadpdf-over-b2a5eec09446851751037c5b57f2576b54ef1f2b.tar.gz
pdf-over-b2a5eec09446851751037c5b57f2576b54ef1f2b.tar.bz2
pdf-over-b2a5eec09446851751037c5b57f2576b54ef1f2b.zip
Display signature placeholder
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12703 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java11
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java43
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java4
3 files changed, 44 insertions, 14 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
index 922e278b..716e1388 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
+++ b/trunk/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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
index 1c6a6e9c..4c83e57f 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
+++ b/trunk/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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
index e08a0f69..39ce2b08 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
+++ b/trunk/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;