summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java4
2 files changed, 11 insertions, 4 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 85b950a6..5be8a4c7 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
@@ -26,6 +26,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
+import java.awt.geom.Point2D;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.eclipse.swt.SWT;
@@ -123,6 +124,8 @@ public class PositioningComposite extends StateComposite {
requestFocus();
}
+ @Override public void onDisplay() { if (this.viewer.getSigPagePos() == null) this.btnSign.setEnabled(false); }
+
/**
* Set the PDF Document to display
*
@@ -132,6 +135,7 @@ public class PositioningComposite extends StateComposite {
public void displayDocument(final PDDocument document) {
EventQueue.invokeLater(() -> {
this.viewer.setDocument(document);
+ getDisplay().asyncExec(() -> this.btnSign.setEnabled(true));
});
if (document != null)
@@ -333,9 +337,12 @@ public class PositioningComposite extends StateComposite {
if (this.currentPage == 0) {
this.position = new SignaturePosition();
} else {
+ Point2D pos = this.viewer.getSigPagePos();
+ if (pos == null) return;
+
this.position = new SignaturePosition(
- this.viewer.getSigPageX(),
- this.viewer.getSigPageY(),
+ pos.getX(),
+ pos.getY(),
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 72811050..6f4064bc 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
@@ -29,6 +29,7 @@ import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
+import javax.annotation.CheckForNull;
import javax.swing.JPanel;
import org.apache.pdfbox.pdmodel.PDDocument;
@@ -110,8 +111,7 @@ public class SignaturePanel extends JPanel {
private int offY = 0;
/** The position of the top-left corner of the signature, in absolute page space */
private Point2D sigPagePos = null;
- public double getSigPageX() { return this.sigPagePos.getX(); }
- public double getSigPageY() { return this.sigPagePos.getY(); }
+ public @CheckForNull Point2D getSigPagePos() { return this.sigPagePos; }
/** The signature placeholder image */
private Image sigPlaceholder = null;
/** Width of the signature placeholder in page space */