diff options
author | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-31 16:36:42 +0000 |
---|---|---|
committer | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-31 16:36:42 +0000 |
commit | 097a32997c8cad126e63814478f07d34c25570b0 (patch) | |
tree | 28a5fbfe5ce5210275a099d642ea9b1c3bf845f6 /trunk | |
parent | 7f3b44e74646e24f78e973c37a71c64643088b0c (diff) | |
download | pdf-over-097a32997c8cad126e63814478f07d34c25570b0.tar.gz pdf-over-097a32997c8cad126e63814478f07d34c25570b0.tar.bz2 pdf-over-097a32997c8cad126e63814478f07d34c25570b0.zip |
Restrict signature to page dimensions on change
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12711 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk')
-rw-r--r-- | trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java | 29 |
1 files changed, 20 insertions, 9 deletions
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 cb23d055..e4060af5 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 @@ -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 |