summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:11:51 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:11:51 +0000
commit870d13d78375bb57e776b0cfc30dd916f0e178e3 (patch)
tree09eeca489fe859111ddebf0d8a01b4f96640620c /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
parentac9ab8e6a53308ca0fb7387df3de9e14b881c27a (diff)
downloadpdf-over-870d13d78375bb57e776b0cfc30dd916f0e178e3.tar.gz
pdf-over-870d13d78375bb57e776b0cfc30dd916f0e178e3.tar.bz2
pdf-over-870d13d78375bb57e776b0cfc30dd916f0e178e3.zip
Allow creation of a new page
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@188 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java41
1 files changed, 36 insertions, 5 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 33afce4a..353b2b66 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
@@ -93,6 +93,10 @@ public class SignaturePanel extends JPanel {
int prevSigScreenHeight = 0;
/** Color of the signature placeholder border */
private Color sigPlaceholderBorderColor = Color.BLUE;
+ /** Current page */
+ int page = 0;
+ /** Number of pages in the document */
+ int numPages = 0;
/**
* Create a new PagePanel.
@@ -114,7 +118,8 @@ public class SignaturePanel extends JPanel {
public void setDocument(PDFFile pdf) {
this.pdf = pdf;
this.sigPagePos = null;
- showPage(pdf.getNumPages());
+ this.numPages = pdf.getNumPages();
+ showPage(this.numPages);
}
/**
@@ -144,11 +149,20 @@ public class SignaturePanel extends JPanel {
* @param page the number of the page to display
*/
public void showPage(int page) {
- //sigPagePos = null;
+ this.page = page;
showPage(this.pdf.getPage(page));
}
/**
+ * Add and display a new page at the end of the document
+ *
+ * This page has the same dimensions as the old last page
+ */
+ public void addNewLastPage() {
+ showPage(this.numPages + 1);
+ }
+
+ /**
* Translate the signature placeholder position
* @param sigXOffset signature placeholder horizontal position offset
* @param sigYOffset signature placeholder vertical position offset
@@ -195,8 +209,17 @@ public class SignaturePanel extends JPanel {
this.currentPage.stop(this.prevSize.width, this.prevSize.height, null);
}
+ boolean newPage = false;
// set up the new page
- this.currentPage = page;
+ if (this.page > this.numPages)
+ {
+ // New last page - use old last page as template
+ this.currentPage = this.pdf.getPage(this.numPages);
+ newPage = true;
+ }
+ else
+ this.currentPage = page;
+
if (this.currentPage == null) {
// no page
@@ -215,8 +238,16 @@ public class SignaturePanel extends JPanel {
null);
// get the new image
- this.currentImage = this.currentPage.getImage(pageSize.width, pageSize.height,
- null, this);
+ if (newPage)
+ {
+ this.currentImage = new BufferedImage(pageSize.width, pageSize.height, BufferedImage.TYPE_INT_RGB);
+ Graphics g = this.currentImage.getGraphics();
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, pageSize.width, pageSize.height);
+ }
+ else
+ this.currentImage = this.currentPage.getImage(pageSize.width, pageSize.height,
+ null, this);
// calculate the transform from page to screen space
this.currentXform = this.currentPage.getInitialTransform(pageSize.width,