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.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
*/