summaryrefslogtreecommitdiff
path: root/trunk
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:44 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:44 +0000
commitf4e2d015a9d307a6091971448364409fae553dd8 (patch)
treea4937687536ccff67138e2b04dd31bedc14b95b4 /trunk
parent20db2e230e1247e2d9351442db3ff7e03fa669f0 (diff)
downloadpdf-over-f4e2d015a9d307a6091971448364409fae553dd8.tar.gz
pdf-over-f4e2d015a9d307a6091971448364409fae553dd8.tar.bz2
pdf-over-f4e2d015a9d307a6091971448364409fae553dd8.zip
Allow setting signature position with keyboard
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12716 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.java36
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java9
2 files changed, 43 insertions, 2 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 33506f00..9d96fb94 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
@@ -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/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 b2f5270f..c9c223b8 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
@@ -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
*/