From 855d78ed79a8dbe11b35395bff133c95801889d7 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:11:13 +0000 Subject: Remember sig pos when going back to positioning git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@181 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../gui/composites/PositioningComposite.java | 22 +++++++++++++++++----- .../pdfover/gui/composites/SignaturePanel.java | 12 ++++++++++++ .../gui/workflow/states/PositioningState.java | 9 +++++++++ 3 files changed, 38 insertions(+), 5 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 ff708e93..988965b3 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,15 +70,16 @@ public class PositioningComposite extends StateComposite { private Composite mainArea = null; - private Label lblPage = null; + Label lblPage = null; + + ScrollBar scrollbar = null; + + private SignaturePosition position = null; int currentPage = 0; int numPages = 0; - private SignaturePosition position = null; - - ScrollBar scrollbar = null; /** * Create the composite. @@ -282,7 +283,7 @@ public class PositioningComposite extends StateComposite { PositioningComposite.this.scrollbar.setSelection( PositioningComposite.this.currentPage); PositioningComposite.this.lblPage.setText(String.format( - "Page %d of %d", + "Page %d of %d", //$NON-NLS-1$ PositioningComposite.this.currentPage, PositioningComposite.this.numPages)); } @@ -325,6 +326,17 @@ public class PositioningComposite extends StateComposite { PositioningComposite.this.state.updateStateMachine(); } + /** + * Set the signature position + * @param x the horizontal signature position + * @param y the vertical signature position + * @param page the page the signature is on + */ + public void setPosition(float x, float y, int page) { + showPage(page); + this.viewer.setSignaturePosition(x, y); + } + /** * Get the signature position * @return the signature position 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 b7edb669..33afce4a 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 @@ -138,6 +138,7 @@ public class SignaturePanel extends JPanel { public void setSignaturePlaceholderBorderColor(Color color) { this.sigPlaceholderBorderColor = color; } + /** * Change the currently displayed page * @param page the number of the page to display @@ -156,6 +157,17 @@ public class SignaturePanel extends JPanel { updateSigPos((int) this.sigScreenPos.getX() + sigXOffset, (int) this.sigScreenPos.getY() + sigYOffset); } + /** + * Set the signature placeholder position + * Call showPage afterwards to update actual position + * @param x the horizontal signature position + * @param y the vertical signature position + */ + public void setSignaturePosition(float x, float y) + { + this.sigPagePos = new Point2D.Double(x, y); + } + /** * Get the current horizontal position of the signature * @return signature x coordinate diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 9bf875fb..cd2e1907 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -30,6 +30,7 @@ import at.asit.pdfover.gui.workflow.Status; import at.asit.pdfover.signator.Emblem; import at.asit.pdfover.signator.FileNameEmblem; import at.asit.pdfover.signator.SignatureParameter; +import at.asit.pdfover.signator.SignaturePosition; /** * Decides where to position the signature block @@ -51,6 +52,8 @@ public class PositioningState extends State { private PositioningComposite positionComposite = null; + private SignaturePosition previousPosition = null; + private PositioningComposite getPositioningComposite() throws IOException { if (this.positionComposite == null) { this.positionComposite = @@ -67,6 +70,11 @@ public class PositioningState extends State { param.getPlaceholderDimension().getWidth(), param.getPlaceholderDimension().getHeight(), this.stateMachine.getConfigProvider().getPlaceholderTransparency()); + if (this.previousPosition != null) + this.positionComposite.setPosition( + this.previousPosition.getX(), + this.previousPosition.getY(), + this.previousPosition.getPage()); return this.positionComposite; } @@ -77,6 +85,7 @@ public class PositioningState extends State { if (!(status.getPreviousState() instanceof PositioningState) && !(status.getPreviousState() instanceof OpenState)) { + this.previousPosition = status.getSignaturePosition(); status.setSignaturePosition(null); } -- cgit v1.2.3