summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:37:05 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:37:05 +0000
commitbdc63f6ee4cde5751d8b0e2e0382ad894b70f2c2 (patch)
treeb44985df4207b18bff0cbb867cdd2e78a3813fc1 /trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
parent544258dbf3e0e478efb1f1ef6ef49be3b2f397f2 (diff)
downloadpdf-over-bdc63f6ee4cde5751d8b0e2e0382ad894b70f2c2.tar.gz
pdf-over-bdc63f6ee4cde5751d8b0e2e0382ad894b70f2c2.tar.bz2
pdf-over-bdc63f6ee4cde5751d8b0e2e0382ad894b70f2c2.zip
Allow creation of a new page
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12774 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java29
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java41
2 files changed, 64 insertions, 6 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
index b7adaddd..9d3fa864 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
@@ -70,6 +70,8 @@ public class PositioningComposite extends StateComposite {
private Composite mainArea = null;
+ Button btnNewPage = null;
+
Label lblPage = null;
ScrollBar scrollbar = null;
@@ -113,10 +115,26 @@ public class PositioningComposite extends StateComposite {
}
});
+ this.btnNewPage = new Button(bottomBar, SWT.TOGGLE);
+ this.btnNewPage.setText(Messages.getString("positioning.newPage")); //$NON-NLS-1$
+ FormData fd_btnNewPage = new FormData();
+ fd_btnNewPage.right = new FormAttachment(btnSign);
+ fd_btnNewPage.top = new FormAttachment(0);
+ this.btnNewPage.setLayoutData(fd_btnNewPage);
+ this.btnNewPage.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (PositioningComposite.this.currentPage > PositioningComposite.this.numPages)
+ showPage(PositioningComposite.this.numPages);
+ else
+ showPage(PositioningComposite.this.numPages + 1);
+ }
+ });
+
this.lblPage = new Label(bottomBar, SWT.CENTER);
FormData fd_lblPage = new FormData();
fd_lblPage.left = new FormAttachment(0);
- fd_lblPage.right = new FormAttachment(btnSign, 5);
+ fd_lblPage.right = new FormAttachment(this.btnNewPage, 5);
fd_lblPage.bottom = new FormAttachment(100);
this.lblPage.setLayoutData(fd_lblPage);
@@ -293,6 +311,15 @@ public class PositioningComposite extends StateComposite {
"Page %d of %d", //$NON-NLS-1$
PositioningComposite.this.currentPage,
PositioningComposite.this.numPages));
+ if (PositioningComposite.this.currentPage > PositioningComposite.this.numPages) {
+ PositioningComposite.this.btnNewPage.setText(
+ Messages.getString("positioning.removeNewPage")); //$NON-NLS-1$
+ PositioningComposite.this.btnNewPage.setSelection(true);
+ } else {
+ PositioningComposite.this.btnNewPage.setText(
+ Messages.getString("positioning.newPage")); //$NON-NLS-1$
+ PositioningComposite.this.btnNewPage.setSelection(false);
+ }
}
});
this.viewer.showPage(page);
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 33afce4a..353b2b66 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
@@ -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,