From 0b716028cb197d4bebfbb88b317b3a0600f82d6a Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:06:00 +0000 Subject: Make signature placeholder transparency configurable git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@128 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../pdfover/gui/workflow/ConfigManipulator.java | 13 ++- .../asit/pdfover/gui/workflow/ConfigProvider.java | 6 ++ .../pdfover/gui/workflow/ConfigProviderImpl.java | 117 +++++++++++++-------- .../gui/workflow/ConfigurationContainer.java | 12 +++ .../gui/workflow/ConfigurationContainerImpl.java | 23 ++++ .../gui/workflow/states/PositioningState.java | 15 ++- 6 files changed, 138 insertions(+), 48 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java index b2f0f7a0..1e584f40 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java @@ -47,6 +47,11 @@ public interface ConfigManipulator { */ public static final String SIGNATURE_POSITION_CONFIG = "SIGNATURE_POSITION"; //$NON-NLS-1$ + /** + * This signature placeholder transparency config parameter (0-255) + */ + public static final String SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG = "SIGNATURE_PLACEHOLDER_TRANSPARENCY"; //$NON-NLS-1$ + /** * The mobile number config parameter */ @@ -77,7 +82,6 @@ public interface ConfigManipulator { */ public static final String OUTPUT_FOLDER_CONFIG = "OUTPUT_FOLDER"; //$NON-NLS-1$ - /** * Sets the default bku type * @param bku the bku type @@ -91,6 +95,13 @@ public interface ConfigManipulator { */ public void setDefaultSignaturePosition(SignaturePosition signaturePosition); + /** + * Sets the signature placeholder transparency + * + * @param transparency the signature placeholder transparency + */ + void setPlaceholderTransparency(int transparency); + /** * Sets the default mobile number * @param number the default mobile number diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java index 0ee116ad..910bdcbb 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java @@ -85,6 +85,12 @@ public interface ConfigProvider { */ public SignaturePosition getDefaultSignaturePosition(); + /** + * Get the transparency of the signature placeholder + * @return the transparency of the signature placeholder + */ + public int getPlaceholderTransparency(); + /** * Gets the default output folder for signed documents * @return the default output folder diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java index dc50b60b..553daeeb 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java @@ -78,6 +78,8 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { private String outputFolder = STRING_EMPTY; + private int placeholderTransparency = 170; + /** * Sets the default bku type * @@ -121,6 +123,25 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { return this.defaultSignaturePosition; } + /** + * Sets the signature placeholder transparency + * + * @param transparency + * the signature placeholder transparency + */ + @Override + public void setPlaceholderTransparency(int transparency) { + this.placeholderTransparency = transparency; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getPlaceholderTransparency() + */ + @Override + public int getPlaceholderTransparency() { + return this.placeholderTransparency; + } + /** * Sets the default mobile number * @@ -242,6 +263,48 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { return this.proxyPort; } + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#setDefaultOutputFolder + * (java.lang.String) + */ + @Override + public void setDefaultOutputFolder(String outputFolder) { + if (outputFolder == null || outputFolder.trim().equals("")) { //$NON-NLS-1$ + this.outputFolder = STRING_EMPTY; + } else { + this.outputFolder = outputFolder; + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultOutputFolder() + */ + @Override + public String getDefaultOutputFolder() { + return this.outputFolder; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMobileBKUURL() + */ + @Override + public String getMobileBKUURL() { + return this.mobileBKU; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() + */ + @Override + public String getConfigurationDirectory() { + return CONFIG_DIRECTORY; + } + /* * (non-Javadoc) * @@ -286,6 +349,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { props.setProperty(EMBLEM_CONFIG, this.getDefaultEmblem()); props.setProperty(MOBILE_NUMBER_CONFIG, this.getDefaultMobileNumber()); props.setProperty(OUTPUT_FOLDER_CONFIG, this.getDefaultOutputFolder()); + props.setProperty(SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG, Integer.toString(this.getPlaceholderTransparency())); SignaturePosition pos = this.getDefaultSignaturePosition(); @@ -307,32 +371,6 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { } - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigManipulator#setDefaultOutputFolder - * (java.lang.String) - */ - @Override - public void setDefaultOutputFolder(String outputFolder) { - if (outputFolder == null || outputFolder.trim().equals("")) { //$NON-NLS-1$ - this.outputFolder = STRING_EMPTY; - } else { - this.outputFolder = outputFolder; - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultOutputFolder() - */ - @Override - public String getDefaultOutputFolder() { - return this.outputFolder; - } - /* * (non-Javadoc) * @@ -401,6 +439,17 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { this.setDefaultBKU(defaultBKU); + // Set Signature placeholder transparency + int transparency = 170; + try { + transparency = Integer.parseInt(config + .getProperty(ConfigManipulator.SIGNATURE_PLACEHOLDER_TRANSPARENCY_CONFIG)); + } catch (NumberFormatException e) { + log.debug("Couldn't parse placeholder transparency", e); + // ignore parsing exception + } + this.setPlaceholderTransparency(transparency); + // Set Signature Position String signaturePosition = config .getProperty(ConfigManipulator.SIGNATURE_POSITION_CONFIG); @@ -459,20 +508,4 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { this.setDefaultSignaturePosition(position); } - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMobileBKUURL() - */ - @Override - public String getMobileBKUURL() { - return this.mobileBKU; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() - */ - @Override - public String getConfigurationDirectory() { - return CONFIG_DIRECTORY; - } - } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java index 796a4cec..693d5e16 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java @@ -94,6 +94,18 @@ public interface ConfigurationContainer { */ public void setAutomaticPosition(boolean automatic); + /** + * Gets the transparency of the placeholder + * @return transparency of the placeholder (0-255) + */ + public int getPlaceholderTransparency(); + + /** + * Sets the transparency of the placeholder + * @param transparency transparency of the placeholder (0-255) + */ + public void setPlaceholderTransparency(int transparency); + /** * Gets the default BKU * @return the default BKU diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java index 081f4072..ef7a8450 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java @@ -78,6 +78,11 @@ public class ConfigurationContainerImpl implements ConfigurationContainer { */ protected boolean automaticPositioning = false; + /** + * Holds the transparency of the signature placeholder + */ + protected int placeholderTransparency = 170; + /* (non-Javadoc) * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getEmblem() */ @@ -199,6 +204,24 @@ public class ConfigurationContainerImpl implements ConfigurationContainer { } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getPlaceholderTransparency() + */ + @Override + public int getPlaceholderTransparency() { + return this.placeholderTransparency; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setPlaceholderTransparency(int) + */ + @Override + public void setPlaceholderTransparency(int transparency) { + this.placeholderTransparency = transparency; + } + + /* (non-Javadoc) * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getBKUSelection() */ 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 d291956d..e35ec790 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 @@ -56,12 +56,18 @@ public class PositioningState extends State { this.positionComposite = this.stateMachine.getGUIProvider().createComposite(PositioningComposite.class, SWT.RESIZE, this); log.debug("Displaying " + this.stateMachine.getStatus().getDocument()); - SignatureParameter param = this.stateMachine.getPDFSigner().getPDFSigner().newParameter(); - Emblem emblem = new FileNameEmblem(this.stateMachine.getConfigProvider().getDefaultEmblem()); - param.setEmblem(emblem); this.positionComposite.displayDocument(this.stateMachine.getStatus().getDocument()); - this.positionComposite.setPlaceholder(param.getPlaceholder(), param.getPlaceholderDimension().getWidth(), param.getPlaceholderDimension().getHeight()); } + // Update possibly changed values + SignatureParameter param = this.stateMachine.getPDFSigner().getPDFSigner().newParameter(); + Emblem emblem = new FileNameEmblem(this.stateMachine.getConfigProvider().getDefaultEmblem()); + param.setEmblem(emblem); + this.positionComposite.setPlaceholder( + param.getPlaceholder(), + param.getPlaceholderDimension().getWidth(), + param.getPlaceholderDimension().getHeight(), + this.stateMachine.getConfigProvider().getPlaceholderTransparency()); + this.positionComposite.requestFocus(); return this.positionComposite; } @@ -75,7 +81,6 @@ public class PositioningState extends State { status.setSignaturePosition(null); } - if(status.getSignaturePosition() == null) { PositioningComposite position = null; try { -- cgit v1.2.3