summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:05:33 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:05:33 +0000
commit7c499c09c039d1a875d8f4463a0c2816337c8e6d (patch)
treec0b372f7338f6213c1bcaa1fe307c2725a92ee3b
parentcd2e3fbdf19d01cd5eac65358e313c993c9564e8 (diff)
downloadmocca-7c499c09c039d1a875d8f4463a0c2816337c8e6d.tar.gz
mocca-7c499c09c039d1a875d8f4463a0c2816337c8e6d.tar.bz2
mocca-7c499c09c039d1a875d8f4463a0c2816337c8e6d.zip
Restrict signature to page dimensions on change
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@125 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java29
1 files changed, 20 insertions, 9 deletions
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 cb23d055..e4060af5 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
@@ -207,6 +207,8 @@ public class SignaturePanel extends JPanel {
clamp((int) ((pageSize.getHeight() / 4) * 3), 0, this.currentImage.getHeight(null) - this.sigScreenHeight));
this.sigPagePos = this.currentXform.transform(this.sigScreenPos, this.sigPagePos);
}
+ else
+ updateSigPos((int) this.sigScreenPos.getX(), (int) this.sigScreenPos.getY());
this.prevSize = pageSize;
@@ -312,15 +314,9 @@ public class SignaturePanel extends JPanel {
private int dragYOffset = 0;
private void updateSigPos(int sigx, int sigy) {
- if (SignaturePanel.this.currentImage == null)
- return;
- sigx -= SignaturePanel.this.offX;
- sigx = clamp(sigx, 0, SignaturePanel.this.currentImage.getWidth(null) - SignaturePanel.this.sigScreenWidth);
- sigy -= SignaturePanel.this.offY;
- sigy = clamp(sigy, 0, SignaturePanel.this.currentImage.getHeight(null) - SignaturePanel.this.sigScreenHeight);
- SignaturePanel.this.sigScreenPos = new Point2D.Double(sigx, sigy);
- SignaturePanel.this.sigPagePos = SignaturePanel.this.currentXform.transform(SignaturePanel.this.sigScreenPos, SignaturePanel.this.sigPagePos);
- repaint();
+ SignaturePanel.this.updateSigPos(
+ sigx - SignaturePanel.this.offX,
+ sigy - SignaturePanel.this.offY);
}
/** Handles a mousePressed event */
@@ -379,6 +375,21 @@ public class SignaturePanel extends JPanel {
}
/**
+ * Update the signature placeholder position
+ * @param sigx X position on the document (screen coordinates)
+ * @param sigy Y position on the document (screen coordinates)
+ */
+ void updateSigPos(int sigx, int sigy) {
+ if (this.currentImage == null)
+ return;
+ sigx = clamp(sigx, 0, this.currentImage.getWidth(null) - this.sigScreenWidth);
+ sigy = clamp(sigy, 0, this.currentImage.getHeight(null) - this.sigScreenHeight);
+ this.sigScreenPos = new Point2D.Double(sigx, sigy);
+ this.sigPagePos = this.currentXform.transform(this.sigScreenPos, this.sigPagePos);
+ repaint();
+ }
+
+ /**
* Clamp x to be within [min-max]
* @param x int to clamp
* @param min minimum value