diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:11:51 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:11:51 +0000 |
commit | 870d13d78375bb57e776b0cfc30dd916f0e178e3 (patch) | |
tree | 09eeca489fe859111ddebf0d8a01b4f96640620c /pdf-over-gui/src/main/java/at/asit/pdfover | |
parent | ac9ab8e6a53308ca0fb7387df3de9e14b881c27a (diff) | |
download | mocca-870d13d78375bb57e776b0cfc30dd916f0e178e3.tar.gz mocca-870d13d78375bb57e776b0cfc30dd916f0e178e3.tar.bz2 mocca-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')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java | 29 | ||||
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java | 41 |
2 files changed, 64 insertions, 6 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 b7adaddd..9d3fa864 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 @@ -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/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, |