From 967a0f646db5bbd802e7ee562ef1891078b51c10 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Thu, 30 Jun 2016 14:44:04 +0200 Subject: Fail safety --- .../at/asit/pdfover/gui/composites/PositioningComposite.java | 9 ++++++--- .../main/java/at/asit/pdfover/gui/composites/SignaturePanel.java | 4 ++++ 2 files changed, 10 insertions(+), 3 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 1ca05015..7f42db8f 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 @@ -409,9 +409,12 @@ public class PositioningComposite extends StateComposite { * the signature position */ void setFinalPosition() { - this.position = new SignaturePosition( - this.viewer.getSignaturePositionX(), - this.viewer.getSignaturePositionY(), this.currentPage); + if (this.currentPage == 0) + this.position = new SignaturePosition(); + else + this.position = new SignaturePosition( + this.viewer.getSignaturePositionX(), + this.viewer.getSignaturePositionY(), this.currentPage); PositioningComposite.this.state.updateStateMachine(); } 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 264ccd2f..34c1112f 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 @@ -198,6 +198,8 @@ public class SignaturePanel extends JPanel { * @return signature x coordinate */ public float getSignaturePositionX() { + if (this.sigPagePos == null) + return 0; return Math.max((float) this.sigPagePos.getX(), 0); } @@ -206,6 +208,8 @@ public class SignaturePanel extends JPanel { * @return signature y coordinate */ public float getSignaturePositionY() { + if (this.sigPagePos == null) + return 0; return Math.max((float) this.sigPagePos.getY(), 0); } -- cgit v1.2.3