summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:06:11 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:06:11 +0000
commit6ed8fd2ff36fae464b9e74795385c2eb57ee649d (patch)
tree077c2a8a368553732b4c5748e8435cd64321f9e2 /pdf-over-gui
parent3aa8217f8920559df6a1d77814746ea501007442 (diff)
downloadpdf-over-6ed8fd2ff36fae464b9e74795385c2eb57ee649d.tar.gz
pdf-over-6ed8fd2ff36fae464b9e74795385c2eb57ee649d.tar.bz2
pdf-over-6ed8fd2ff36fae464b9e74795385c2eb57ee649d.zip
Allow setting signature position with keyboard
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@130 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java9
2 files changed, 43 insertions, 2 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 33506f00..9d96fb94 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
@@ -45,8 +45,7 @@ import at.asit.pdfover.signator.SignaturePosition;
import com.sun.pdfview.PDFFile;
/**
- *
- *
+ * Composite which allows to position the signature on a preview of the document
*/
public class PositioningComposite extends StateComposite {
/**
@@ -55,6 +54,9 @@ public class PositioningComposite extends StateComposite {
static final Logger log = LoggerFactory
.getLogger(PositioningComposite.class);
+ /** How far to displace the signature with the arrow keys */
+ private static final int SIGNATURE_KEYBOARD_POSITIONING_OFFSET = 15;
+
private SignaturePanel viewer = null;
private PDFFile pdf = null;
@@ -139,6 +141,8 @@ public class PositioningComposite extends StateComposite {
@Override
public void keyPressed(KeyEvent e) {
int newPage = PositioningComposite.this.currentPage;
+ int sigXOffset = 0;
+ int sigYOffset = 0;
switch (e.keyCode)
{
@@ -164,10 +168,29 @@ public class PositioningComposite extends StateComposite {
case SWT.KEYPAD_CR:
PositioningComposite.this.setFinalPosition();
break;
+
+ case SWT.ARROW_LEFT:
+ sigXOffset -= SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
+ break;
+
+ case SWT.ARROW_RIGHT:
+ sigXOffset += SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
+ break;
+
+ case SWT.ARROW_UP:
+ sigYOffset -= SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
+ break;
+
+ case SWT.ARROW_DOWN:
+ sigYOffset += SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
+ break;
}
if (newPage != PositioningComposite.this.currentPage)
showPage(newPage);
+
+ if (sigXOffset != 0 || sigYOffset != 0)
+ PositioningComposite.this.translateSignaturePosition(sigXOffset, sigYOffset);
}
};
@@ -224,6 +247,15 @@ public class PositioningComposite extends StateComposite {
}
/**
+ * Translate the signature placeholder position
+ * @param sigXOffset signature placeholder horizontal position offset
+ * @param sigYOffset signature placeholder vertical position offset
+ */
+ public void translateSignaturePosition(int sigXOffset, int sigYOffset) {
+ PositioningComposite.this.viewer.translateSignaturePosition(sigXOffset, sigYOffset);
+ }
+
+ /**
* Set the signature position and continue to the next state
* @param position the signature position
*/
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 b2f5270f..c9c223b8 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
@@ -136,6 +136,15 @@ public class SignaturePanel extends JPanel {
}
/**
+ * Translate the signature placeholder position
+ * @param sigXOffset signature placeholder horizontal position offset
+ * @param sigYOffset signature placeholder vertical position offset
+ */
+ public void translateSignaturePosition(int sigXOffset, int sigYOffset) {
+ updateSigPos((int) this.sigScreenPos.getX() + sigXOffset, (int) this.sigScreenPos.getY() + sigYOffset);
+ }
+
+ /**
* Get the current horizontal position of the signature
* @return signature x coordinate
*/